EWRouter example¶
This notebook uses OptiWindNet to route the collector system cables via EWRouter.
⚡ EWRouter (Esau-Williams Heuristic)¶
EWRouter is a fast and lightweight heuristic router based on the Esau-Williams algorithm. It builds a spanning tree that connects turbines to substations while respecting cable capacity constraints. This method is especially suitable for electrical network optimization in quick prototyping and large-scale turbine layouts where optimization speed is more important than global optimality.
EWRouteris the default router used inWindFarmNetwork. If no router is specified when creating aWindFarmNetworkinstance,.optimize()will automatically run withEWRouter.
🔧 Constructor: EWRouter(...)¶
Required arguments:
None -> You can instantiate
EWRouter()without any arguments.
Optional arguments:
Argument |
Type |
Description |
|---|---|---|
|
|
Heuristic variant (see table below, default: |
|
|
Maximum number of iterations (default: |
|
|
Routing style:• |
|
|
Fractional margin within which edges are treated as equivalent (used by |
|
|
If |
Method |
Topology |
Description |
|---|---|---|
|
branched |
Closest to original Esau-Williams (modified to prevent crossings) |
|
branched |
EW with root-ward bias on quasi-ties |
|
branched |
EW with capacity-dependent root-ward bias |
|
radial |
EW with radial subtrees (simple paths) |
|
ringed |
Clarke-Wright like savings formula |
✅ Example
# Implicit use of EWRouter as default
wf = WindFarmNetwork(cables=..., turbinesC=..., substationsC=...)
wf.optimize() # Uses EWRouter by default
# Explicitly use with custom options
router = EWRouter(feeder_route='straight', maxiter=5000)
wf = WindFarmNetwork(cables=..., turbinesC=..., substationsC=..., router=router)
wf.optimize()
# Ringed (closed-loop) topology
router = EWRouter(method='ringed')
wf = WindFarmNetwork(cables=..., turbinesC=..., substationsC=..., router=router)
wf.optimize()
While
EWRouteris very efficient, it’s a heuristic and does not guarantee globally optimal solutions. Use it when you need speed or when solving large problems where exact methods are too slow.
[1]:
from optiwindnet.api import WindFarmNetwork, EWRouter
create an instance of wfn using .from_pbf()
[2]:
wfn = WindFarmNetwork.from_pbf(filepath='data/DTU_letters.osm.pbf', cables=[(7, 2000.0)])
[3]:
wfn
[3]:
Optimize with EWRouter¶
Optimize with default settings.¶
[4]:
router = EWRouter()
res = wfn.optimize(router=router)
print(wfn.length())
wfn
1647.108905210097
[4]:
Optimize with user-defined settings.¶
[5]:
router = EWRouter(
maxiter=20000,
feeder_route='straight',
verbose=True)
res = wfn.optimize(router=router)
print(wfn.length())
wfn
1707.0505869707563
[5]: