can i use an indicator Constraint with Min/Max Constraint in Gurobi?

Answered

Comments

2 comments

  • Tobias Achterberg

    The conclusion of an indicator constraint must be a linear constraint. But you can easily get around this by introducing another set of variables that are defined identically to `a`; let's call them `b`. Then you would write

    m.addConstrs((x[k,i,j] == 1) >> (a[k,j] == b[k,j]) for k in range(K) for i in range(V) for j in range(1,V) if i!=j)
    m.addConstrs(b[k,j] == max_((a[k,i] + 5), 15) for k in range(K) for i in range(V) for j in range(1,V) if i!=j)

     

    1
    Comment actions Permalink
  • Mhd Adnan Almouazen Alayoubi

    thank you for your help that was very helpful.
    after i worked with your suggestion, i end up getting the Error:

    TypeError: object of type 'gurobipy.LinExpr' has no len()

    after digging in the internet, i found that this Error was caused by the max_() function. I can only pass a list of variables as arguments for this function and not a LinExpr as i do.

    (thanks to Robert Luce for his answer on google group https://groups.google.com/forum/#!topic/gurobi/oO3d2ItJiqs )

    thank you again for your help Tobias Achterberg

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk