optiwindnet.MILP¶

Submodules¶

Package Contents¶

class optiwindnet.MILP.FeederLimit[source]¶

Bases: enum.StrEnum

Whether to limit the maximum number of feeders, if set to “specified”,

Initialize self. See help(type(self)) for accurate signature.

UNLIMITED¶
SPECIFIED¶
MINIMUM¶
MIN_PLUS1¶
MIN_PLUS2¶
MIN_PLUS3¶
DEFAULT¶
class optiwindnet.MILP.FeederRoute[source]¶

Bases: enum.StrEnum

If feeder routes must be “straight” or can be detoured (“segmented”).

Initialize self. See help(type(self)) for accurate signature.

STRAIGHT¶
SEGMENTED¶
DEFAULT¶
class optiwindnet.MILP.ModelMetadata[source]¶
R: int¶
T: int¶
capacity: int¶
linkset: tuple[_Link, Ellipsis]¶
flow_: collections.abc.Mapping[_Link, Any]¶
model_options: dict[str, Any]¶
fun_fingerprint: dict[str, str | bytes]¶
weight_: tuple[float, Ellipsis] = ()¶
solution_hint: dict[Any, float]¶
warmed_by: str = ''¶
class optiwindnet.MILP.ModelOptions(**kwargs)[source]¶

Bases: dict

Hold options for the modelling of the cable routing problem.

Use ModelOptions.help() to get the options and their permitted and default values. Use ModelOptions() without any parameters to use the defaults.

Initialize self. See help(type(self)) for accurate signature.

hints¶
simple¶
classmethod help()[source]¶
exception optiwindnet.MILP.OWNSolutionNotFound[source]¶

Bases: Exception

Common base class for all non-exit exceptions.

Initialize self. See help(type(self)) for accurate signature.

exception optiwindnet.MILP.OWNWarmupFailed[source]¶

Bases: Exception

Common base class for all non-exit exceptions.

Initialize self. See help(type(self)) for accurate signature.

class optiwindnet.MILP.SolutionInfo[source]¶
runtime: float¶
bound: float¶
objective: float¶
relgap: float¶
termination: str¶
class optiwindnet.MILP.Solver[source]¶

Bases: abc.ABC

Common interface to multiple MILP solvers

name: str¶
metadata: ModelMetadata¶
solver: Any¶
options: dict[str, Any]¶
stopping: dict[str, Any]¶
solution_info: SolutionInfo¶
applied_options: dict[str, Any]¶
abstractmethod set_problem(P: networkx.PlanarEmbedding, A: networkx.Graph, capacity: int, model_options: ModelOptions, warmstart: networkx.Graph | None = None)[source]¶

Define the problem geometry, available edges and tree properties

Parameters:
  • P – planar embedding of the location

  • A – available edges for the location

  • capacity – maximum number of terminals in a subtree

  • model_options – tree properties - see ModelOptions.help()

  • warmstart – initial feasible solution to pass to solver

abstractmethod solve(time_limit: float, mip_gap: float, options: dict[str, Any] = {}, verbose: bool = False) SolutionInfo[source]¶

Run the MILP solver search.

Parameters:
  • time_limit – maximum time (s) the solver is allowed to run.

  • mip_gap – relative difference from incumbent solution to lower bound at which the search may be stopped before time_limit is reached.

  • options – additional options to pass to solver (see solver manual).

Returns:

General information about the solution search (use get_solution() for

the actual solution).

abstractmethod get_solution(A: networkx.Graph | None = None) tuple[networkx.Graph, networkx.Graph][source]¶

Output solution topology A and routeset G.

Parameters:

A – optionally replace the A given via set_problem() (if normalized A)

Returns:

Topology graph S and routeset G.

class optiwindnet.MILP.Topology[source]¶

Bases: enum.StrEnum

Set the topology of subtrees in the solution.

Initialize self. See help(type(self)) for accurate signature.

RADIAL¶
BRANCHED¶
DEFAULT¶
optiwindnet.MILP.solver_factory(solver_name: str) _core.Solver[source]¶

Create a Solver object tied to the specified external MILP solver.

Note that the only solver that is a dependency of OptiWindNet is ‘ortools’. Check OptiWindNet’s documentation on how to install optional solvers.

Legacy compatibility: if solver_name == ‘ortools’ then the CP-SAT backend is used.

Parameters:

solver_name – one of ‘ortools.cp_sat’, ‘ortools.gscip’, ‘ortools.highs’, ‘cplex’, ‘gurobi’, ‘cbc’, ‘scip’, ‘highs’.

Returns:

Solver instance that can produce solutions for the cable routing problem.