pyepo.model.grb.vrp

Capacitated vehicle routing problem with binding-constraint tracking for CaVE

Classes

vrpABModel

Abstract Gurobi-backed model for the capacitated vehicle routing problem.

vrpRCIModel

CVRP formulation with 2-degree constraints and lazy rounded-capacity cuts.

vrpMTZModel

CVRP formulation on a directed graph with MTZ-style capacity constraints

vrpMTZModelRel

LP relaxation of vrpMTZModel.

Module Contents

class pyepo.model.grb.vrp.vrpABModel(num_nodes: int, demands: list[float] | numpy.ndarray, capacity: float, num_vehicle: int)

Bases: pyepo.model.grb.grbmodel.optGrbModel

Abstract 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.

Variables:
  • num_nodes – number of nodes (including depot at index 0)

  • nodes – list of node indices

  • edges – undirected edges as (i, j) with i < j

  • demands – customer demands (excluding depot)

  • capacity – per-vehicle capacity

  • num_vehicle – number of vehicles

num_nodes
nodes
edges
demands
capacity
num_vehicle
property num_cost: int

number of costs to be predicted

getTour(sol: numpy.ndarray | torch.Tensor | list) list[list[int]]

Reconstruct vehicle tours from an undirected edge-selection vector.

Parameters:

sol – per-edge selection values aligned with self.edges

Returns:

list of tours; each tour is a node sequence starting and ending at the depot

copy() Self

A method to copy the model

class pyepo.model.grb.vrp.vrpRCIModel(num_nodes: int, demands: list[float] | numpy.ndarray, capacity: float, num_vehicle: int)

Bases: vrpABModel

CVRP formulation with 2-degree constraints and lazy rounded-capacity cuts.

Uses one undirected Var per edge (x[j,i] aliases x[i,j]). Subtour elimination and rounded capacity inequalities are added lazily during branch-and-cut; the cuts added at the optimum are tracked on model._lazy_constrs for downstream CaVE cone extraction.

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:

tuple

class pyepo.model.grb.vrp.vrpMTZModel(num_nodes: int, demands: list[float] | numpy.ndarray, capacity: float, num_vehicle: int)

Bases: vrpABModel

CVRP 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 both x[i,j] and x[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:

tuple

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)

Bases: vrpMTZModel

LP 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