optiwindnet.baselines.lkhΒΆ
Module ContentsΒΆ
- optiwindnet.baselines.lkh.lkh3(A: networkx.Graph, *, capacity: int, time_limit: float, vehicles: int | None = None, seed: int | None = None, keep_log: bool = False, repair: bool = True, max_retries: int = 10, balanced: bool = False, scale: float = 100000.0, runs: int = 50, per_run_limit: float = 15.0, precision: int = 1000, complete: bool = False, ringed: bool = False, warmstart: networkx.Graph | None = None) networkx.Graph[source]ΒΆ
Solve the O/CVRP using LKH-3 with links from
A.Wraps the LKH-3 executable, which is not distributed with OptiWindNet. Get it from http://akira.ruc.dk/~keld/research/LKH-3/ and make sure the
LKHexecutable is in the environmentβs PATH.Uses the Lin-Kernighan-Helsgaun meta-heuristic to solve an Open-CVRP (i.e., vehicles do not return to the depot), yielding radial layouts. With
ringed=Trueit solves the closed CVRP instead (TYPE=CVRP): every route returns to the depot, forming a ring whose capacity is doubled internally (2 * capacity) so each of the two arms holds at mostcapacityterminals. Normalization of the input graph is recommended before calling this function (useas_normalized()).For single-root problems, the solver runs on the full graph. For multi-root problems, the graph is clustered (one cluster per root) and each cluster is solved concurrently.
For multi-root instances, the vehicles (feeders) parameter is forced per cluster (a warning is issued if a different value is requested): to the minimum feasible value, except for a cluster that fits within
capacity, which is offered enough feeders to use as many as lower the cable length.If
repair=True(the default), the solution is iteratively repaired until no crossings remain (ormax_retriesis reached). This may cause the actual runtime to be up to(max_retries + 1)times the giventime_limit.- Parameters:
A β graph with allowed edges (if it has 0 edges, use
complete=True).capacity β maximum vehicle capacity.
time_limit β [s] solver run time limit (per cluster).
vehicles β number of vehicles (if None or at the minimum, use the per-cluster default described above; ignored for multi-root problems).
seed β random seed for reproducibility (if None, picks a random one).
keep_log β attach solver log to the solution graph.
repair β iteratively fix crossings (default True).
max_retries β maximum repair iterations.
balanced β currently not implemented for this solver.
scale β factor to scale lengths (LKH manual).
runs β number of LKH runs (LKH manual).
per_run_limit β [s] LKH per-run time limit.
precision β LKH precision parameter.
complete β make the full graph over A available (missing edges assumed direct).
warmstart β optional previous solution graph used to seed the initial tour. For multi-root instances each cluster receives the portion of the warmstart attached to its root.
- Returns:
Solution topology S.