Skip to main content

Binary Variable Activation

Answered

Comments

3 comments

  • 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

Please sign in to leave a comment.