set COLS := { "5000", "3100", "2010", "2001", "1200", "1110", "0300", "0110", "0101", "0011" }; set LENGTHS := { 20, 32, 45, 55 }; set BOXES := { 1 .. 3}; param lengths[LENGTHS] := <20> 20, <32> 32, <45> 45, <55> 55; param l := 100; param available := 15; param demands[LENGTHS*BOXES] := | 1,2,3| |20| 4,1,0| |32| 1,1,2| |45| 0,2,3| |55| 0,1,1|; param gains[BOXES] := <1> 112, <2>197,<3>199; param requests[BOXES] := <1> 6, <2>2,<3>2; param counts[LENGTHS*COLS] := | "5000", "3100", "2010", "2001", "1200", "1110", "0300", "0110", "0101", "0011"| |20| 5, 3, 2, 2, 1, 1, 0, 0, 0, 0| |32| 0, 1, 0, 0, 2, 1, 3, 1, 1, 0| |45| 0, 0, 1, 0, 0, 1, 0, 1, 0, 1| |55| 0, 0, 0, 1, 0, 0, 0, 0, 1, 1|; var count[COLS] integer >= 0; var boxes[BOXES] integer >= 0; subto colsXboxes: forall in LENGTHS: (sum in BOXES: demands[j,i]*boxes[i]) - (sum in COLS: counts[j,i]*count[i]) <= 0; ### Problem 1 #maximize gains: # sum in BOXES: boxes[i] * gains[i]; #subto avail: # sum in COLS: count[i] <= available; ### End of problem 1 ### Problem 2 minimize number_used: sum in COLS: count[i]; subto requests: forall in BOXES: boxes[i] >= requests[i]; ### End of problem 2