I'm trying to linearize a multiplication constraint I have in pulp.
It looks something like this:
prob += (1 - Y) * (3 - X)
Which is equal to:
prob += 3 - 3*Y - X + X*Y
Where Y is a binary variable, In the formula everything is linear except for the following part: Y*X
. I tried to solve this by using the formula I found in another question:
So I tried using X1*X2 = Y
, Using my code this gives X*Y = A
. I used the log substitution method. This gave me the following code:
prob += math.log(float(A)) = math.log(float(X)) + math.log(float(y))
And the other constraint:
prob += 3 - 3*Y - X + A
Only this doesn't seem to work because a float can only be a string or a number and not a LpVariable
. Is there a way to solve this problem using the first substitution method given in the image of the formula?