Problem
In a food blending problem, where several ingredients are mixeed to produce a food, the modeler wants – in addition to the common mathematical balancing and capacity restrictions – to impose the following logical constraints:
The food may never be made up of more than three oils (ingredients).
If an oil is used at least 20 tons and at most 200 tons must be used.
If either Veg1 or Veg2 is used (two vegetal oils) then Oil3 (a non-vegetal oil) must also be used in the blend.
How can these conditions be formulated mathematically? This model part belongs to a model presented in [7]
Modeling Steps
For each ingredient i ∈ I there is a variable x_{i} ≥ 0 which is the quantity of the ingredient.
For each ingredient i a binary variable d_{i} is introduced with the meaning “there is (or is not) a certain quantity of the ingredient i in a blend (that means, zero quantity (for d_{i} = 0) or at least 20 and at most 200) (for d_{i} = 1)”.
The binary variable d_{i} is linked to x_{i} in the following way: d_{i} → (20 ≤ x_{i} ≤ 200) with i ∈ I, that is, if d_{i} is true then x_{i} must be between 20 and 200.
model Logic6 "Logical Conditions in an LP";
set i := /Veg1 Veg2 Oil1 Oil2 Oil3/ "Ingredients in a blend";
parameter
Lo:=20 "Lower bound in use";
Up:=200 "Upper bound in use";
variable x{i} [0..300] "Quantity of ingredient used in the blend";
binary variable d{i}; //: Lo <= x <= Up;
constraint
Cond1: sum{i} d <= 3;
Cond2{i}: d -> (Lo <= x <= Up);
Cond3: d['Veg1'] or d['Veg2'] -> d['Oil3'];
solve; //minimize obj: sum{i} x "Minimize the output";
//Writep(obj, x, d);
end
Note that the lower and upper bounds of x_{i} is not the same as the minimal and maximal quantity used in the blend. Therefore, the second condition is translated into:
Further Comments
In LPL the second condition can also be integrated in the decraation of the binary variable as follows;
binary variable d{i}: Lo <= x <= Up
In this case, the assignment is interpreted as an implication. In both cases, LPL generates the following linear model:
Cond1: + d[Veg1] + d[Veg2] + d[Oil1] + d[Oil2] + d[Oil3] <= 3;
Cond2[Veg1]: - x[Veg1] + 20 d[Veg1] <= 0;
Cond2[Veg2]: - x[Veg2] + 20 d[Veg2] <= 0;
Cond2[Oil1]: - x[Oil1] + 20 d[Oil1] <= 0;
Cond2[Oil2]: - x[Oil2] + 20 d[Oil2] <= 0;
Cond2[Oil3]: - x[Oil3] + 20 d[Oil3] <= 0;
Cond3: - d[Veg1] + d[Oil3] >= 0;
X45X[Veg1]: + x[Veg1] + 100 d[Veg1] <= 300;
X45X[Veg2]: + x[Veg2] + 100 d[Veg2] <= 300;
X45X[Oil1]: + x[Oil1] + 100 d[Oil1] <= 300;
X45X[Oil2]: + x[Oil2] + 100 d[Oil2] <= 300;
X45X[Oil3]: + x[Oil3] + 100 d[Oil3] <= 300;
X46X: - d[Veg2] + d[Oil3] >= 0;