Pulp Add Constraint That At Least One Lpaffineexpression Is Equal To One
Say I have a PuLP model defined as thus: model = pulp.LpProblem('',pulp.LpMaximize) And I have added an objective function (it does not matter) Now I have a list of LpAffineExpress
Solution 1:
There is no "OR" in linear or integer programming. However, you can use binary variables to simulate such an OR construct. (Or SOS1 variables if big-M's are undesirable; I am not sure to what extend Pulp supports SOS1 variables).
The idea is:
1 - M * (1-δ(i)) <= L(i) <= 1 + M * (1-δ(i))
sum(i, δ(i)) >= 1
δ(i) ∈ {0,1}
- Obviously the
L(i)
are yourl1,l2,l3,...
δ(i)
is a binary variable indicating ifL(i)=1
. We haveδ(i)=1 ⇒ L(i)=1
.- The constants
M
can be set to lower and upper bounds ofL(i)
.
Post a Comment for "Pulp Add Constraint That At Least One Lpaffineexpression Is Equal To One"