Skip to main content

Modelling with gurobipy

Awaiting user input

Comments

2 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.
  • Jaromił Najman
    • Gurobi Staff

    Hi Emma,

    Could you please elaborate on what exactly are you trying to model? Given your code, you are trying to model

    \[\begin{align*}
    \sum_{l,r,i,j} \left( x_{r,l} \leq \max\{0, w_i + time_r - w_j - time_{l,0} +1\}\right)
    \end{align*}\]

    You cannot sum over inequalities.

    In order to use the max operator, you have to use the addGenConstrMax method which accepts only single optimization variables or constants. This means that for every \(\max\) term, you have to introduce 2 auxiliary variables \(q_{i,r,j,l}, p_{i,r,j,l}\) and model the constraints

    \[\begin{align*}
    p_{i,r,j,l} &= w_i + time_r - w_j - time_{l,0} +1\\
    q_{i,r,j,l} &= \max\{0, p_{i,r,j,l}\}
    \end{align*}\]

    Best regards, 
    Jaromił

    0

Post is closed for comments.