pyepo.model.copt.tsp¶
Traveling salesman problem
Attributes¶
Classes¶
COPT-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.copt.tsp.tspABModel(num_nodes: int, *args, **kwargs)¶
Bases:
pyepo.model.bases.tspABBase,pyepo.model.copt.coptmodel.optCoptModelCOPT-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.copt.tsp.tspGGModel(num_nodes: int, *args, **kwargs)¶
Bases:
tspABModelGavish-Graves (GG) formulation.
- relax() tspGGModelRel¶
A method to get linear relaxation model
- class pyepo.model.copt.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.copt.tsp.tspDFJModel(num_nodes: int, *args, **kwargs)¶
Bases:
tspABModelDanzig-Fulkerson-Johnson (DFJ) formulation with lazy subtour elimination.
Uses one undirected Var per edge, so the paired-vars
setObj/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.copt.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.copt.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
- pyepo.model.copt.tsp.num_nodes = 5¶