conditional statement
回答済みHi,
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
-
正式なコメント
This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
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
投稿コメントは受け付けていません。
コメント
2件のコメント