Loading...
Searching...
No Matches
simple_cutstock.m
1function simple_cutstock(varargin)
2
3 % check workspace info from arguments
4 if nargin > 0
5 wsInfo = gams.control.WorkspaceInfo();
6 wsInfo.systemDirectory = varargin{1};
7 ws = gams.control.Workspace(wsInfo);
8 else
9 ws = gams.control.Workspace();
10 end
11
12 cs = CutstockModel(ws);
13
14 % define input data
15 d = containers.Map({'i1', 'i2', 'i3', 'i4'}, {97, 610, 395, 211});
16 w = containers.Map({'i1', 'i2', 'i3', 'i4'}, {45, 36, 31, 14});
17 r = 100;
18
19 for key = keys(d)
20 cs.widths.addRecord(key{1});
21 rec = cs.demand.addRecord(key{1});
22 rec.value = d(key{1});
23 end
24 for key = keys(w)
25 rec = cs.width.addRecord(key{1});
26 rec.value = w(key{1});
27 end
28 rec = cs.raw_width.addRecord();
29 rec.value = r;
30
31 cs.opt.setAllModelTypes('cplex');
32 cs.run(gams.control.PrintStream());
33
34 for pr = cs.pat_rep.records;
35 fprintf("%s, pattern %s: %g\n", pr{1}.keys{:}, pr{1}.value);
36 end
37end