Skip to main content

Appending variables to the optimizing variable

Answered

Comments

1 comment

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Dipanjan,

    The issue with simply "appending" u5 to your variables is that u5 is not a variable but a LinExpr object. Thus, you cannot just apply the @ operator to it later on.

    You could define 5 variables and add an equality constraint stating

    \[\begin{align*}
    u_5 = X - \sum_{i=1}^{4} u_i
    \end{align*}\]

    Like this, you wouldn't have to modify your code and you are not making the model noticeably more complex.

    Best regards, 
    Jaromił

    0

Please sign in to leave a comment.