Skip to main content

Binary Variable Activation

Answered

Comments

4 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    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.
  • Simranjit Kaur
    • Gurobi Staff

    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,
    Simran

    0
  • Juan De Dios Diaz
    • Gurobi-versary
    • First Question
    • First Comment

    Can you give me de code line please?

    0
  • Simranjit Kaur
    • Gurobi Staff

    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.