pyepo.model.grb.tsp¶
Traveling salesman problem
Classes¶
Gurobi-backed TSP abstract base. Provides paired-variable |
|
Gavish-Graves (GG) formulation. |
|
LP relaxation of the GG formulation. |
|
Danzig-Fulkerson-Johnson (DFJ) formulation with lazy subtour elimination. |
|
Miller-Tucker-Zemlin (MTZ) formulation. |
|
LP relaxation of the MTZ formulation. |
Module Contents¶
- class pyepo.model.grb.tsp.tspABModel(num_nodes: int, *args, **kwargs)¶
Bases:
pyepo.model.bases.tspABBase,pyepo.model.grb.grbmodel.optGrbModelGurobi-backed TSP abstract base. Provides paired-variable
setObj/solve/_addExtraConstrshared by GG and MTZ. DFJ overrides those.- setObj(c: numpy.ndarray | torch.Tensor | list) None¶
A method to set the objective function
- Parameters:
c – cost vector
- solve() tuple[numpy.ndarray, float]¶
A method to solve model
- class pyepo.model.grb.tsp.tspGGModel(num_nodes: int, *args, **kwargs)¶
Bases:
tspABModelGavish-Graves (GG) formulation.
- relax() tspGGModelRel¶
A method to get linear relaxation model
- class pyepo.model.grb.tsp.tspGGModelRel(num_nodes: int, *args, **kwargs)¶
Bases:
tspGGModelLP relaxation of the GG formulation.
- solve() tuple[numpy.ndarray, float]¶
A method to solve model — returns fractional solution.
- relax() NoReturn¶
A forbidden method to relax MIP model
- getTour(sol: numpy.ndarray | torch.Tensor | list) list[int]¶
A forbidden method to get a tour from solution
- class pyepo.model.grb.tsp.tspDFJModel(num_nodes: int, *args, **kwargs)¶
Bases:
tspABModelDanzig-Fulkerson-Johnson (DFJ) formulation with lazy subtour elimination.
Uses one undirected Var per edge (
x[j,i]aliasesx[i,j]), so the paired-varssetObj/solve/_addExtraConstrinherited fromtspABModelare overridden here.- setObj(c: numpy.ndarray | torch.Tensor | list) None¶
A method to set the objective function
- Parameters:
c – cost vector
- solve() tuple[numpy.ndarray, float]¶
A method to solve model
- class pyepo.model.grb.tsp.tspMTZModel(num_nodes: int, *args, **kwargs)¶
Bases:
tspABModelMiller-Tucker-Zemlin (MTZ) formulation.
- relax() tspMTZModelRel¶
A method to get linear relaxation model
- class pyepo.model.grb.tsp.tspMTZModelRel(num_nodes: int, *args, **kwargs)¶
Bases:
tspMTZModelLP relaxation of the MTZ formulation.
- solve() tuple[numpy.ndarray, float]¶
A method to solve model — returns fractional solution.
- relax() NoReturn¶
A forbidden method to relax MIP model
- getTour(sol: numpy.ndarray | torch.Tensor | list) list[int]¶
A forbidden method to get a tour from solution