cutstock.py File Reference

This example implements a column generation approach to solve the cutting stock problem. More...

Go to the source code of this file.

Functions

def cutstock.get_master_model ()
 
def cutstock.get_sub_model ()
 

Variables

 cutstock.ws = GamsWorkspace(system_directory = sys.argv[1])
 
 cutstock.opt = ws.add_options()
 
 cutstock.cutstock_data = ws.add_database("csdata")
 
 cutstock.all_model_types
 
 cutstock.optcr
 
int cutstock.maxpattern = 35
 
dictionary cutstock.d = {"i1": 97, "i2": 610, "i3":395, "i4": 211}
 
dictionary cutstock.w = {"i1": 47, "i2": 36, "i3": 31, "i4": 14}
 
int cutstock.r = 100
 
 cutstock.widths = cutstock_data.add_set("i", 1, "widths")
 
 cutstock.raw_width = cutstock_data.add_parameter("r", 0, "raw width")
 
 cutstock.demand = cutstock_data.add_parameter("d", 1, "demand")
 
 cutstock.width = cutstock_data.add_parameter("w", 1, "width")
 
 cutstock.value
 
 cutstock.master_cp = ws.add_checkpoint()
 
 cutstock.master_init_job = ws.add_job_from_string(get_master_model())
 
 cutstock.databases
 
 cutstock.master_job = ws.add_job_from_string("execute_load 'csdata', aip, pp; solve master min z using %solveMasterAs%;", master_cp)
 
 cutstock.pattern = cutstock_data.add_set("pp", 1, "pattern index")
 
 cutstock.pattern_data = cutstock_data.add_parameter("aip", 2, "pattern data")
 
int cutstock.pattern_count = 0
 
 cutstock.sub_cp = ws.add_checkpoint()
 
 cutstock.sub_job = ws.add_job_from_string(get_sub_model())
 
 cutstock.sub_mi = sub_cp.add_modelinstance()
 
 cutstock.demand_dual = sub_mi.sync_db.add_parameter("demdual", 1, "dual of demand from master")
 
bool cutstock.pattern_added = True
 
 cutstock.s = pattern.add_record(str(pattern_count))
 
 cutstock.end
 
 cutstock.aip = master_job.out_db["aip"].first_record((" ", xp.key(0)))
 

Detailed Description

This example implements a column generation approach to solve the cutting stock problem.

In this example, the column generation approach has been entirely implemented in the program using GamsJob for the master and GamsModelInstance for the pricing problem. GAMS is used to build the master and pricing problems. The logic of the column generation method is in the application program.

Definition in file cutstock.py.