11 from cutstock_class
import Cutstock
14 d = {
"i1": 97,
"i2": 610,
"i3": 395,
"i4": 211 }
15 w = {
"i1": 47,
"i2": 36,
"i3": 31,
"i4": 14 }
18 if __name__ ==
"__main__":
20 ws = GamsWorkspace(system_directory = sys.argv[1])
25 cs.raw_width.add_record().value = r
27 cs.widths.add_record(i)
28 for k,v
in iter(d.items()):
29 cs.demand.add_record(k).value = v
30 for k,v
in iter(w.items()):
31 cs.width.add_record(k).value = v
32 cs.opt.all_model_types =
"cplex"
35 cs.run(output=sys.stdout)
36 for rep
in cs.pat_rep:
37 print(rep.key(0) +
", pattern " + rep.key(1) +
": " + str(rep.value))
39 except GamsException
as e:
40 raise Exception(
"Problem in GAMS: " + str(e))
41 except Exception
as e:
42 raise Exception(
"System Error: " + str(e))