Reputation: 1337
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.
Upvotes: 0
Views: 191
Reputation: 16797
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.
Upvotes: 1
Reputation: 1718
What you are describing is disjunctive programming. Pyomo provides support for that through Pyomo.GDP: https://pyomo.readthedocs.io/en/latest/modeling_extensions/gdp.html, with more logical expression support upcoming.
For simple problems, the direct algebraic formulation suggested by Erwin is probably easiest.
Upvotes: 0