conditional statement
AnsweredHi,
m.addConstr((C==1)>>(D==5)) Where C is the optimized variable variable. D is assigned 5 when C is 1. When C is 0 then D must be zero. It gives garbage value.. Please let me know how it can be assured the binary variable is 0 then D==5 expression should not execute or it's value shoud be zero.
0
-
Hi Ramesh,
To ensure that D is zero when the binary variable C is zero, you can add another indicator constraint:
m.addConstr( (C==0) >> (D==0) )
Alternatively, you can add a Big-M constraint, m.addConstr( D <= M*C ), where M is a sufficiently large number.
Cheers,
Simran
0
Please sign in to leave a comment.
Comments
1 comment