Skip to main content

Appending variables to the optimizing variable

Answered

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 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

Post is closed for comments.