20 Logical Conditions in an LP (logic6)

Run LPL Code  ,  PDF Document

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:

  1. The food may never be made up of more than three oils (ingredients).

  2. If an oil is used at least 20 tons and at most 200 tons must be used.

  3. 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

  1. For each ingredient i I there is a variable xi 0 which is the quantity of the ingredient.

  2. For each ingredient i a binary variable di 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 di = 0) or at least 20 and at most 200) (for di = 1)”.

  3. The binary variable di is linked to xi in the following way: di (20 xi 200) with i I, that is, if di is true then xi must be between 20 and 200.


Listing 13: The Complete Model implemented in LPL [13]
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 xi is not the same as the minimal and maximal quantity used in the blend. Therefore, the second condition is translated into:

xi ≤ 20δi          forall i ∈ I
x +  100δ ≤  300   forall f i ∈ I
 i       i

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;