1 /* Food Manufacture 1, section 12.1 in
2 * Williams, "Model Building in Mathematical Programming"
4 * Sebastian Nowozin <nowozin@gmail.com>
10 /* Buying prices of the raw oils in the next six month. */
11 param buyingprices{month,oils};
13 /* Actual amount bought in each month. */
14 var buys{month,oils} >= 0;
16 /* Stock for each oil. */
17 var stock{month,oils} >= 0;
19 /* Price of the produced product */
20 param productprice >= 0;
23 param oilhardness{oils} >= 0;
25 /* Actual amount of output oil produced in each month */
26 var production{m in month} >= 0;
27 var useoil{m in month, o in oils} >= 0;
30 sum{m in month} productprice*production[m]
31 - sum{m in month, o in oils} buyingprices[m,o]*buys[m,o]
32 - sum{m in month, o in oils} storagecost*stock[m,o];
36 /* 1. Starting stock */
37 s.t. startstock{o in oils}:
39 s.t. endstock{o in oils}:
40 stock[6,o] + buys[6,o] - useoil[6,o] >= 500;
42 /* 2. Stock constraints */
43 s.t. stocklimit{m in month, o in oils}:
46 s.t. production1{m in month, o in oils}:
47 useoil[m,o] <= stock[m,o] + buys[m,o];
48 s.t. production2{m1 in month, m2 in month, o in oils : m2 = m1+1}:
49 stock[m2,o] = stock[m1,o] + buys[m1,o] - useoil[m1,o];
51 s.t. production3a{m in month}:
52 sum{o in oils} oilhardness[o]*useoil[m,o] >= 3*production[m];
53 s.t. production3b{m in month}:
54 sum{o in oils} oilhardness[o]*useoil[m,o] <= 6*production[m];
56 s.t. production4{m in month}:
57 production[m] = sum{o in oils} useoil[m,o];
59 /* 3. Refining constraints */
60 s.t. refine1{m in month}:
61 useoil[m,"VEG1"]+useoil[m,"VEG2"] <= 200;
62 s.t. refine2{m in month}:
63 useoil[m,"OIL1"]+useoil[m,"OIL2"]+useoil[m,"OIL3"] <= 250;
68 printf "Month %d\n", m;
69 printf "PRODUCE %4.2f tons, hardness %4.2f\n", production[m],
70 (sum{o in oils} oilhardness[o]*useoil[m,o]) / (sum{o in oils} useoil[m,o]);
72 printf "\tVEG1\tVEG2\tOIL1\tOIL2\tOIL3\n";
76 printf "\t%4.2f", stock[m,o];
80 printf "\t%4.2f", buys[m,o];
85 printf "\t%4.2f", useoil[m,o];
90 printf "Total profit: %4.2f\n",
91 (sum{m in month} productprice*production[m]
92 - sum{m in month, o in oils} buyingprices[m,o]*buys[m,o]
93 - sum{m in month, o in oils} storagecost*stock[m,o]);
94 printf " turnover: %4.2f\n",
95 sum{m in month} productprice*production[m];
96 printf " buying costs: %4.2f\n",
97 sum{m in month, o in oils} buyingprices[m,o]*buys[m,o];
98 printf " storage costs: %4.2f\n",
99 sum{m in month, o in oils} storagecost*stock[m,o];
104 param : oils : oilhardness :=
111 set month := 1 2 3 4 5 6;
115 : VEG1 VEG2 OIL1 OIL2 OIL3 :=
117 1 110 120 130 110 115
120 4 120 110 120 120 125
121 5 100 120 150 110 105
122 6 90 100 140 80 135 ;
124 param productprice := 150;
125 param storagecost := 5;