Skip to main content

Modeling conditional constraints with products of variables inside

Answered

Comments

3 comments

  • Simranjit Kaur
    • Gurobi Staff Gurobi Staff

    Indicator constraints, Model.addGenConstrIndicator(), require LinExpr object. You may find this post helpful. It discusses how to use the Big-M method instead of indicator constraints for conditional relations involving quadratic constraints.

    0
  • Simranjit Kaur
    • Gurobi Staff Gurobi Staff

    We can also work around the LinExpr requirement for Model.addGenConstrIndicator() by introducing auxiliary variables in the model that hold the value of the quadratic expressions and use them in the indicator constraints instead.

    mdl.addConstrs( w[e,i,j] = x_e[e,(i,j)]*(z[e,i]+r[i]*2.25*(0.8-b[e,i])*100) for i in V for j in N for e in E if i!=j )
    mdl.addConstrs( y[e,i,j] = x_e[e,(i,j)]*(z[e,i]+r[i]*6*(b[e,i])*100) for i in V for j in N for e in E if i!=j )

    mdl.addConstrs((ind[e,i] == 1) >> (z[e,j] >= w[e,i,j]) for i in V for j in N for e in E if i!=j)
    mdl.addConstrs((ind[e,i] == 0) >> (z[e,j] >= y[e,i,j]) for i in V for j in N for e in E if i!=j)

    Please note the default lower bound for variables in Gurobi is zero. Please update the lower bounds of the auxiliary variables if they can take negative values.

    0
  • Krypt
    • Investigator
    • Gurobi-versary
    • Conversationalist

    Thank you!

    0

Please sign in to leave a comment.