メインコンテンツへスキップ

Variable elimination in Gurobi

回答済み

コメント

3件のコメント

  • 正式なコメント
    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

    You can use any of the two to get the same effect. However, the two approaches differ.

    With model.remove you completely remove a given variable from the model meaning that you cannot re-use it later in the your algorithm and would have to re-add it to the model.

    For the second approach to work you would either have to add a constraint which sets \(x\) to \(0\) or set its lower and upper bound to \(0\).

    model.addConstr(x[i,j] == 0)

    or

    x[i,j].lb = 0
    x[i,j].ub = 0

    This way you would keep the variables in your model and presolve would take care of those (i.e., presolve would remove these fixed variables from the model). Note that if you turn presolve off then these variables will still hang around in the model, possibly slowing it down.

    Usually, I would go with the second approach. This way, you will have all variables in your model and will not have to think about which ones did you remove or not, i.e., you will not significantly alter your model formulation.

    Best regards, 
    Jaromił

    0
  • Krypt
    • Gurobi-versary
    • Investigator
    • Conversationalist

    Got it. Thank you for such a clear interpretation!

    0

投稿コメントは受け付けていません。