Search code examples
optimizationconstraintsmathematical-optimizationpyomo

How to write constraint which says if p or q then r in pyomo?


Hi I am learning optimization using pyomo and i have a problem where one variable should get value only when one of the other two variables or both get a value.

it's like (P V Q) => R in tautology. can someone please help how to write it as a constraint in pyomo.

example : if i am using 3 ingredients to make a product, 3rd one should always be used if any of 1,2 are used or both 1,2 are used.


Solution

  • I don't know what "get a value" is in optimization. All variables in the model "get a value". Look at it as a system of equations + an objective.

    But, of course,

     (P V Q) => R
    

    is equivalent to

      R >= P
      R >= Q
    

    where R,P and Q are binary variables.