Loading...
Searching...
No Matches
tsp.py File Reference

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

Go to the source code of this file.

Variables

str tsp.GAMS_MODEL
 
sys tsp.sys_dir = sys.argv[1] if len(sys.argv) > 1 else None
 
GamsWorkspace tsp.ws = GamsWorkspace(system_directory=sys_dir)
 
int tsp.cuts_per_round = 10
 
int tsp.cur_cut = 0
 
int tsp.cmax = 0
 
GamsWorkspace tsp.cut_data = ws.add_database()
 
GamsWorkspace tsp.cc = cut_data.add_set("cc", 1)
 
GamsWorkspace tsp.acut = cut_data.add_parameter("acut", 3)
 
GamsWorkspace tsp.rhscut = cut_data.add_parameter("rhscut", 1)
 
list tsp.n = []
 
GamsWorkspace tsp.job = ws.add_job_from_string(GAMS_MODEL)
 
GamsWorkspace tsp.cp = ws.add_checkpoint()
 
GamsWorkspace tsp.opt = ws.add_options()
 
 tsp.gams_options
 
 tsp.checkpoint
 
GamsWorkspace tsp.mi = cp.add_modelinstance()
 
GamsWorkspace tsp.mi_acut = mi.sync_db.add_parameter("acut", 3)
 
GamsWorkspace tsp.mi_rhscut = mi.sync_db.add_parameter("rhscut", 1)
 
dict tsp.graph = {}
 
list tsp.not_visited = list(n)
 
list 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 sub tour elimination algorithm for the Traveling Salesman Problem (TSP) problem.

Similar to benders_2stage.py example, we have a placeholder for the sub tour 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 sub tours are eliminated.

Definition in file tsp.py.