No Matches
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.


str cutstock.GAMS_MASTER_MODEL
str cutstock.GAMS_SUB_MODEL
sys cutstock.sys_dir = sys.argv[1] if len(sys.argv) > 1 else None
GamsWorkspace cutstock.ws = GamsWorkspace(system_directory=sys_dir)
GamsWorkspace cutstock.opt = ws.add_options()
GamsWorkspace cutstock.cutstock_data = ws.add_database("csdata")
int cutstock.max_pattern = 35
int cutstock.r = 100
GamsWorkspace cutstock.raw_width = cutstock_data.add_parameter("r", 0, "raw width")
dict cutstock.d = {"i1": 97, "i2": 610, "i3": 395, "i4": 211}
GamsWorkspace cutstock.demand = cutstock_data.add_parameter("d", 1, "demand")
GamsWorkspace cutstock.widths = cutstock_data.add_set("i", 1, "widths")
dict cutstock.w = {"i1": 47, "i2": 36, "i3": 31, "i4": 14}
GamsWorkspace cutstock.width = cutstock_data.add_parameter("w", 1, "width")
GamsWorkspace cutstock.cp_master = ws.add_checkpoint()
GamsWorkspace cutstock.job_master_init = ws.add_job_from_string(GAMS_MASTER_MODEL)
GamsWorkspace cutstock.job_master
GamsWorkspace cutstock.pattern = cutstock_data.add_set("pp", 1, "pattern index")
GamsWorkspace cutstock.pattern_data = cutstock_data.add_parameter("aip", 2, "pattern data")
int cutstock.pattern_count = 0
GamsWorkspace cutstock.cp_sub = ws.add_checkpoint()
GamsWorkspace cutstock.job_sub = ws.add_job_from_string(GAMS_SUB_MODEL)
GamsWorkspace cutstock.mi_sub = cp_sub.add_modelinstance()
GamsWorkspace cutstock.demand_dual
 cutstock.else :
GamsWorkspace cutstock.s = pattern.add_record(str(pattern_count))
GamsWorkspace cutstock.aip = job_master.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.