Binary Variable Activation
AnsweredHi, i need to activate the Variable Z[i,j] according to:
G(i,j)>MG(i,j), then Z[i,j]=1
G(i,j)<=MG(i,j) then Z[i,j]=0
I need to do it with the big M technique
PD: G(i,j) and MG(i,j) are parameters.
0
-
Official comment
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 Juan,
If G[i,j] and MG[i,j] are parameters, you do not need a Big-M constraint to model your condition. You can simply compare the values of G[i,j] and MG[i,j] and set the binary variable Z[i,j] to zero or one accordingly.
Best regards,
Simran0 -
Can you give me de code line please?
0 -
You can do something like this in Python, for example,
if G[i,j] > MG[i,j]:
model.addConstr(Z[i,j]==1)
else
model.addConstr(Z[i,j]==0)0
Post is closed for comments.
Comments
4 comments