How do I model if and only if statements in Gurobi
回答済みhii, I'm having trouble modeling if and only if statements. I modeled it like the code below
for i in range(I):
for j in range(J):
m.addConstr((h[j] + eps - M * ( 1 - b) <= g[i]), "bigM_constr1" )
m.addConstr((h[j] + M * b >= g[i]), "bigM_constr2" )
'''
m.addConstr((b==1) >> (x[i,j] == 1), "indicator_constr1")
m.addConstr((b==0) >> (x[i,j] == 0), "indicator_constr2")
'''
m.addGenConstrIndicator(b,True , x[i,j], GRB.EQUAL, 1.0)
Why when I run it there is an errorKey : (0.9) ?
Please help me
-
正式なコメント
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 Anggita,
We discuss how to debug a key error in the Knowledge Base article Tutorial: Preparing a Minimal Reproducible Example.
Best regards,
Jaromił0 -
Hi, I want to ask more. To describe conditional statements whether there are additional indicator limits besides this
m.addConstr((b == 1 ) >> (z == w1), name= "indicator_constr1" ) m.addConstr((b == 0 ) >> (z == w2), nama= "indicator_constr2" )
0 -
To describe conditional statements whether there are additional indicator limits besides this
Could you elaborate what exactly you mean by "additional indicator limits"?
Maybe the Knowledge Base article How do I model conditional statements in Gurobi? can help.
0
投稿コメントは受け付けていません。
コメント
4件のコメント