cptp._cptp¶
CPTP Branch-and-Cut Solver
Attributes¶
Classes¶
Create a collection of name/value pairs. |
|
Functions¶
|
Load a CPTP instance from file (auto-detect format), with all its capacity rows |
Module Contents¶
- class cptp._cptp.Status¶
Bases:
enum.EnumCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- Optimal = 0¶
- Feasible = 1¶
- Infeasible = 2¶
- Unbounded = 3¶
- TimeLimit = 4¶
- Error = 5¶
- class cptp._cptp.SeparatorStats¶
- property cuts_added: int¶
- property rounds_called: int¶
- property time_seconds: float¶
- class cptp._cptp.SolveResult¶
-
- property objective: float¶
- property bound: float¶
- property gap: float¶
- property time_seconds: float¶
- property nodes: int¶
- property tour: Annotated[numpy.typing.NDArray[numpy.int32], dict(shape=None, writable=False)]¶
- property tour_arcs: Annotated[numpy.typing.NDArray[numpy.int32], dict(shape=None, writable=False)]¶
- property total_cuts: int¶
- property separation_rounds: int¶
- property separator_stats: dict[str, SeparatorStats]¶
- is_optimal() bool¶
- has_solution() bool¶
- class cptp._cptp.Problem¶
- class cptp._cptp.Problem(num_nodes: int, edges: Annotated[numpy.typing.NDArray[numpy.int32], dict(shape=None, 2)], edge_costs: Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=None, order='C')], profits: Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=None, order='C')], demands: Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=None, order='C')], capacity: float, source: int = 0, target: int = 0, name: str = '')
- class cptp._cptp.Problem(num_nodes: int, edges: Annotated[numpy.typing.NDArray[numpy.int32], dict(shape=None, 2)], edge_costs: Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=None, order='C')], profits: Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=None, order='C')], demands: Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=None, None)], capacities: Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=None, order='C')], source: int = 0, target: int = 0, name: str = '')
- property name: str¶
- property num_nodes: int¶
- property num_edges: int¶
- property source: int¶
- property target: int¶
- property capacity: float¶
Capacity of row 0 (the only row when num_capacities == 1)
- property num_capacities: int¶
Number of capacity rows m; a solution satisfies all of them
- property capacities: Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=None, writable=False)]¶
(m,) capacities Q_k, a read-only view
- property is_tour: bool¶
- property edge_costs: Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=None, writable=False)]¶
- property profits: Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=None, writable=False)]¶
- property demands: Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=None, writable=False)]¶
(n,) demands of row 0, a read-only view
- property demand_rows: Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=None, None)]¶
(m, n) demands d^k_i of every row, a copy
- graph_edges() Annotated[numpy.typing.NDArray[numpy.int32], dict(shape=None, 2)]¶
Return a (num_edges, 2) numpy array of (tail, head) pairs
- class cptp._cptp.Model¶
-
- set_graph(num_nodes: int, edges: Annotated[numpy.typing.NDArray[numpy.int32], dict(shape=None, 2)], edge_costs: Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=None, order='C')]) None¶
- set_source(arg: int, /) None¶
- set_target(arg: int, /) None¶
- set_depot(arg: int, /) None¶
- set_profits(profits: Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=None, order='C')]) None¶
- add_capacity_resource(demands: Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=None, order='C')], limit: float) None¶
Add a capacity row sum_i demands[i] * y_i <= limit; every row added is enforced
- solve(options: collections.abc.Sequence[tuple[str, str]] = []) SolveResult¶
Solve with (key, value) options: the solver’s own (cptp-solve –help lists them, among them the multi-capacity capacity_cut_rows, capacity_cut_surrogate, labeling_rows, labeling_join and labeling_2cycle), the rest passed to HiGHS
- cptp._cptp.has_highs: bool = True¶