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 |
|---|---|---|
|
|
Maximum number of iterations (default: |
|
|
Routing style:• |
|
|
If |
✅ 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()
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]: