As you know from Describing the Problem, there are a variety of constraints in this problem.
For each type of oil, there must be 500 tons in storage at the end of the plan. That idea can be expressed like this:
for (p = 0; p < nbProducts; p++) {
store[nbMonths-1][p].setBounds(500, 500);
}
|
The constraints on production in each month can all be expressed as statements in a for-loop:
-
Not more than 200 tons of vegetable oil can be refined.
model.add(use[i][v1] + use[i][v2] <= 200);
|
-
Not more than 250 tons of non-vegetable oil can be refined.
model.add(use[i][o1] + use[i][o2] + use[i][o3] <= 250);
|
-
A blend cannot use more than three oils; or equivalently, of the five oils, two cannot be used in a given blend.
model.add((use[i][v1] == 0) +
(use[i][v2] == 0) +
(use[i][o1] == 0) +
(use[i][o2] == 0) +
(use[i][o3] == 0) >= 2);
|
-
Blends composed of vegetable oil 1 (v1) or vegetable oil 2 (v2) must also include non vegetable oil 3 (o3).
model.add(IloIfThen(env, (use[i][v1] >= 20) || (use[i][v2] >= 20),
use[i][o3] >= 20));
|
-
The constraint that if an oil is used at all in a blend, at least 20 tons of it must be used is expressed like this:
for (p = 0; p < nbProducts; p++)
model.add((use[i][p] == 0) || (use[i][p] >= 20));
|
Note |
If there were an upper bound on use, as well as this lower bound of 20, then this logical constraint could be replaced by semi-continous variables.
|
-
The fact that a limited amount of raw oil can be stored for later use is expressed like this:
if (i == 0) {
for (IloInt p = 0; p < nbProducts; p++)
model.add(500 + buy[i][p] == use[i][p] + store[i][p]);
}
else {
for (IloInt p = 0; p < nbProducts; p++)
model.add(store[i-1][p] + buy[i][p] ==
use[i][p] + store[i][p]);
}
|