tsp.py File Reference

This example demonstrates how to use a GamsModelInstance to implement the subtour elimination algorithm for the Traveling Salesman Problem (TSP) problem. More...

Go to the source code of this file.

Functions

def tsp.get_model_text ()
 

Variables

 tsp.ws = GamsWorkspace(system_directory = sys.argv[1])
 
int tsp.cuts_per_round = 10
 
int tsp.curcut = 0
 
int tsp.cmax = 0
 
 tsp.cut_data = ws.add_database()
 
 tsp.cc = cut_data.add_set("cc", 1, "")
 
 tsp.acut = cut_data.add_parameter("acut", 3, "")
 
 tsp.rhscut = cut_data.add_parameter("rhscut", 1, "")
 
list tsp.n = []
 
 tsp.tsp_job = ws.add_job_from_string(get_model_text())
 
 tsp.cp = ws.add_checkpoint()
 
 tsp.opt = ws.add_options()
 
 tsp.gams_options
 
 tsp.checkpoint
 
 tsp.mi = cp.add_modelinstance()
 
 tsp.mi_acut = mi.sync_db.add_parameter("acut", 3, "")
 
 tsp.mi_rhscut = mi.sync_db.add_parameter("rhscut", 1, "")
 
dictionary tsp.graph = {}
 
 tsp.not_visited = list(n)
 
 tsp.i = not_visited[0]
 
list tsp.sub_tour = [i]
 
 tsp.value
 
 tsp.end
 

Detailed Description

This example demonstrates how to use a GamsModelInstance to implement the subtour elimination algorithm for the Traveling Salesman Problem (TSP) problem.

Similar to benders_2stage example, we have a placeholder for the subtour elimination constraint that gets generated in each iteration of the algorithm. In contrast to the Benders example, here we regenerate the GamsModelInstance if the original number of placeholders was not big enough. We continue this process until all subtours are eliminated.

Definition in file tsp.py.