pyepo.model.grb.vrp¶
Capacitated vehicle routing problem with binding-constraint tracking for CaVE
Classes¶
Abstract Gurobi-backed model for the capacitated vehicle routing problem. |
|
CVRP formulation with 2-degree constraints and lazy rounded-capacity cuts. |
|
CVRP formulation on a directed graph with MTZ-style capacity constraints |
|
LP relaxation of |
Module Contents¶
- class pyepo.model.grb.vrp.vrpABModel(num_nodes: int, demands: list[float] | numpy.ndarray, capacity: float, num_vehicle: int, *args, **kwargs)¶
Bases:
pyepo.model.bases.vrpABBase,pyepo.model.grb.grbmodel.optGrbModelAbstract Gurobi-backed model for the capacitated vehicle routing problem.
A single-customer route is excluded so all edge variables stay strictly binary; if a single-stop route is actually needed, duplicate the depot.
- class pyepo.model.grb.vrp.vrpRCIModel(num_nodes: int, demands: list[float] | numpy.ndarray, capacity: float, num_vehicle: int, recycle_cuts: bool = False)¶
Bases:
vrpABModelCVRP formulation with 2-degree constraints and lazy rounded-capacity cuts.
Uses one undirected Var per edge (
x[j,i]aliasesx[i,j]). Subtour elimination and rounded capacity inequalities are added lazily during branch-and-cut; the cuts added at the optimum are tracked onmodel._lazy_constrsfor downstream CaVE cone extraction. Withrecycle_cutsthe cuts found in one solve join the model’s lazy pool, so later solves on new cost vectors skip rediscovering them.- recycle_cuts = False¶
- setObj(c: numpy.ndarray | torch.Tensor | list) None¶
A method to set the objective function
- Parameters:
c – cost vector aligned with
self.edges
- solve() tuple[numpy.ndarray, float]¶
A method to solve the model
- Returns:
edge-selection vector (uint8) and objective value (float)
- Return type:
- class pyepo.model.grb.vrp.vrpMTZModel(num_nodes: int, demands: list[float] | numpy.ndarray, capacity: float, num_vehicle: int, *args, **kwargs)¶
Bases:
vrpABModelCVRP formulation on a directed graph with MTZ-style capacity constraints (no lazy cuts). Cost vector is per undirected edge: cost
c[k]is assigned to bothx[i,j]andx[j,i].- setObj(c: numpy.ndarray | torch.Tensor | list) None¶
A method to set the objective function
- Parameters:
c – cost vector aligned with
self.edges(one cost per undirected edge)
- solve() tuple[numpy.ndarray, float]¶
A method to solve the model
- Returns:
edge-selection vector (uint8) and objective value (float)
- Return type:
- relax() vrpMTZModelRel¶
A method to get linear relaxation model
- class pyepo.model.grb.vrp.vrpMTZModelRel(num_nodes: int, demands: list[float] | numpy.ndarray, capacity: float, num_vehicle: int, *args, **kwargs)¶
Bases:
vrpMTZModelLP relaxation of
vrpMTZModel.- solve() tuple[numpy.ndarray, float]¶
A method to solve the model — returns fractional edge selections
- relax() NoReturn¶
A forbidden method to relax MIP model
- getTour(sol: numpy.ndarray | torch.Tensor | list) list[list[int]]¶
A forbidden method to get a tour from solution