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.

EWRouter is the default router used in WindFarmNetwork. If no router is specified when creating a WindFarmNetwork instance, .optimize() will automatically run with EWRouter.

🔧 Constructor: EWRouter(...)¶

Required arguments:

  • None -> You can instantiate EWRouter() without any arguments.

Optional arguments:

Argument

Type

Description

maxiter

int

Maximum number of iterations (default: 10000). Controls how long the heuristic explores the search space.

feeder_route

str

Routing style:• "segmented" (default)• "straight"

verbose

bool

If True, prints potential warnings during routing (default: False).

✅ 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 EWRouter is 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]:
../_images/notebooks_b01_EWRouter_9_0.svg

Optimize with EWRouter¶

Optimize with default settings.¶

[4]:
router = EWRouter()
res = wfn.optimize(router=router)
print(wfn.length())
wfn
1647.108905210097
[4]:
../_images/notebooks_b01_EWRouter_12_1.svg

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]:
../_images/notebooks_b01_EWRouter_14_1.svg