cutstock Namespace Reference

Functions

def get_master_model ()
 
def get_sub_model ()
 

Variables

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

Function Documentation

◆ get_master_model()

def cutstock.get_master_model ( )

Definition at line 14 of file cutstock.py.

15  return '''
16 $Title Cutting Stock - Master problem
17 
18 Set i widths
19 Parameter
20  w(i) width
21  d(i) demand
22 Scalar
23  r raw width;
24 $gdxin csdata
25 $load i w d r
26 
27 $if not set pmax $set pmax 1000
28 Set p possible patterns /1*%pmax%/
29  pp(p) dynamic subset of p
30 Parameter
31  aip(i,p) number of width i in pattern growing in p;
32 
33 * Master model
34 Variable xp(p) patterns used
35  z objective variable
36 Integer variable xp; xp.up(p) = sum(i, d(i));
37 
38 Equation numpat; numpat.. z =e= sum(pp, xp(pp));
39 Equation demand(i); demand(i).. sum(pp, aip(i,pp)*xp(pp)) =g= d(i);
40 
41 model master /numpat, demand/;'''
42 

◆ get_sub_model()

def cutstock.get_sub_model ( )

Definition at line 43 of file cutstock.py.

Variable Documentation

◆ aip

cutstock.aip = master_job.out_db["aip"].first_record((" ", xp.key(0)))

Definition at line 155 of file cutstock.py.

◆ all_model_types

cutstock.all_model_types

Definition at line 76 of file cutstock.py.

◆ cutstock_data

cutstock.cutstock_data = ws.add_database("csdata")

Definition at line 75 of file cutstock.py.

◆ d

dictionary cutstock.d = {"i1": 97, "i2": 610, "i3":395, "i4": 211}

Definition at line 83 of file cutstock.py.

◆ databases

cutstock.databases

Definition at line 102 of file cutstock.py.

◆ demand

cutstock.demand = cutstock_data.add_parameter("d", 1, "demand")

Definition at line 89 of file cutstock.py.

◆ demand_dual

cutstock.demand_dual = sub_mi.sync_db.add_parameter("demdual", 1, "dual of demand from master")

Definition at line 120 of file cutstock.py.

◆ end

cutstock.end

Definition at line 154 of file cutstock.py.

◆ master_cp

cutstock.master_cp = ws.add_checkpoint()

Definition at line 100 of file cutstock.py.

◆ master_init_job

cutstock.master_init_job = ws.add_job_from_string(get_master_model())

Definition at line 101 of file cutstock.py.

◆ master_job

cutstock.master_job = ws.add_job_from_string("execute_load 'csdata', aip, pp; solve master min z using %solveMasterAs%;", master_cp)

Definition at line 103 of file cutstock.py.

◆ maxpattern

int cutstock.maxpattern = 35

Definition at line 78 of file cutstock.py.

◆ opt

cutstock.opt = ws.add_options()

Definition at line 74 of file cutstock.py.

◆ optcr

cutstock.optcr

Definition at line 77 of file cutstock.py.

◆ pattern

cutstock.pattern = cutstock_data.add_set("pp", 1, "pattern index")

Definition at line 105 of file cutstock.py.

◆ pattern_added

bool cutstock.pattern_added = True

Definition at line 124 of file cutstock.py.

◆ pattern_count

int cutstock.pattern_count = 0

Definition at line 109 of file cutstock.py.

◆ pattern_data

cutstock.pattern_data = cutstock_data.add_parameter("aip", 2, "pattern data")

Definition at line 106 of file cutstock.py.

◆ r

int cutstock.r = 100

Definition at line 85 of file cutstock.py.

◆ raw_width

cutstock.raw_width = cutstock_data.add_parameter("r", 0, "raw width")

Definition at line 88 of file cutstock.py.

◆ s

cutstock.s = pattern.add_record(str(pattern_count))

Definition at line 140 of file cutstock.py.

◆ sub_cp

cutstock.sub_cp = ws.add_checkpoint()

Definition at line 114 of file cutstock.py.

◆ sub_job

cutstock.sub_job = ws.add_job_from_string(get_sub_model())

Definition at line 115 of file cutstock.py.

◆ sub_mi

cutstock.sub_mi = sub_cp.add_modelinstance()

Definition at line 117 of file cutstock.py.

◆ value

cutstock.value

Definition at line 92 of file cutstock.py.

◆ w

dictionary cutstock.w = {"i1": 47, "i2": 36, "i3": 31, "i4": 14}

Definition at line 84 of file cutstock.py.

◆ width

cutstock.width = cutstock_data.add_parameter("w", 1, "width")

Definition at line 90 of file cutstock.py.

◆ widths

cutstock.widths = cutstock_data.add_set("i", 1, "widths")

Definition at line 87 of file cutstock.py.

◆ ws

cutstock.ws = GamsWorkspace(system_directory = sys.argv[1])

Definition at line 70 of file cutstock.py.

def get_master_model()
Definition: cutstock.py:14