Skip to main content

Modelling with gurobipy

Awaiting user input

Comments

1 comment

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

Please sign in to leave a comment.