pyepo.model.omo.tsp

Traveling salesman problem

Attributes

_HAS_PYOMO

num_nodes

Classes

tspABModel

This abstract class is an optimization model for the traveling salesman problem.

tspGGModel

This class is an optimization model for the traveling salesman problem based on Gavish-Graves (GG) formulation.

tspGGModelRel

This class is relaxation of tspGGModel.

tspMTZModel

This class is an optimization model for the traveling salesman problem based on Miller-Tucker-Zemlin (MTZ) formulation.

tspMTZModelRel

This class is relaxation of tspMTZModel.

Module Contents

pyepo.model.omo.tsp._HAS_PYOMO = True
class pyepo.model.omo.tsp.tspABModel(num_nodes, solver='glpk')

Bases: pyepo.model.omo.omomodel.optOmoModel

This abstract class is an optimization model for the traveling salesman problem. This model is for further implementation of different formulation.

_model

Pyomo model

Type:

Pyomo model

solver

optimization solver in the background

Type:

str

num_nodes

Number of nodes

Type:

int

edges

List of edge index

Type:

list

num_nodes
nodes
edges
property num_cost

number of costs to be predicted

copy()

A method to copy model

Returns:

new copied model

Return type:

optModel

getTour(sol)

A method to get a tour from solution

Parameters:

sol (list) – solution

Returns:

a TSP tour

Return type:

list

class pyepo.model.omo.tsp.tspGGModel(num_nodes, solver='glpk')

Bases: tspABModel

This class is an optimization model for the traveling salesman problem based on Gavish-Graves (GG) formulation.

_model

Pyomo model

Type:

Pyomo model

solver

optimization solver in the background

Type:

str

num_nodes

Number of nodes

Type:

int

edges

List of edge index

Type:

list

_getModel()

A method to build Pyomo model

Returns:

optimization model and variables

Return type:

tuple

setObj(c)

A method to set the objective function

Parameters:

c (list) – cost vector

solve()

A method to solve model

addConstr(coefs, rhs)

A method to add new constraint

Parameters:
  • coefs (ndarray) – coefficients of new constraint

  • rhs (float) – right-hand side of new constraint

Returns:

new model with the added constraint

Return type:

optModel

relax()

A method to get linear relaxation model

class pyepo.model.omo.tsp.tspGGModelRel(num_nodes, solver='glpk')

Bases: tspGGModel

This class is relaxation of tspGGModel.

_model

Pyomo model

Type:

Pyomo model

solver

optimization solver in the background

Type:

str

num_nodes

Number of nodes

Type:

int

edges

List of edge index

Type:

list

_getModel()

A method to build Pyomo model

Returns:

optimization model and variables

Return type:

tuple

solve()

A method to solve model

Returns:

optimal solution (list) and objective value (float)

Return type:

tuple

relax()

A forbidden method to relax MIP model

getTour(sol)

A forbidden method to get a tour from solution

class pyepo.model.omo.tsp.tspMTZModel(num_nodes, solver='glpk')

Bases: tspABModel

This class is an optimization model for the traveling salesman problem based on Miller-Tucker-Zemlin (MTZ) formulation.

_model

Pyomo model

Type:

Pyomo model

solver

optimization solver in the background

Type:

str

num_nodes

Number of nodes

Type:

int

edges

List of edge index

Type:

list

_getModel()

A method to build Pyomo model

Returns:

optimization model and variables

Return type:

tuple

setObj(c)

A method to set the objective function

Parameters:

c (list) – cost vector

solve()

A method to solve model

addConstr(coefs, rhs)

A method to add new constraint

Parameters:
  • coefs (ndarray) – coefficients of new constraint

  • rhs (float) – right-hand side of new constraint

Returns:

new model with the added constraint

Return type:

optModel

relax()

A method to get linear relaxation model

class pyepo.model.omo.tsp.tspMTZModelRel(num_nodes, solver='glpk')

Bases: tspMTZModel

This class is relaxation of tspMTZModel.

_model

Pyomo model

Type:

Pyomo model

solver

optimization solver in the background

Type:

str

num_nodes

Number of nodes

Type:

int

edges

List of edge index

Type:

list

_getModel()

A method to build Pyomo model

Returns:

optimization model and variables

Return type:

tuple

solve()

A method to solve model

Returns:

optimal solution (list) and objective value (float)

Return type:

tuple

relax()

A forbidden method to relax MIP model

getTour(sol)

A forbidden method to get a tour from solution

pyepo.model.omo.tsp.num_nodes = 5