Skip to main content

Updating Lists Under Conditional Statements

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

    But i also need to apply:

      numWarehouses +=1
                    storageCapacity.append(newStorage)
                    palletCapacity.append(newPallet)
                    operationCapacity.append(newOperation) 

    It is not possible to alter the model data during optimization in this way. Thus, what you are trying to achieve is not possible.

    The optimization model and all constraints have to be present and fixed when starting the optimization.

    In order to model your scheme, you have to define optimization variables and constraints which describe the behavior you want. This is similar to the \(\texttt{if}\)-clause, which has to be modeled via binary variables and additional (indicator) constraints, because optimization variables don't have any value prior to an optimization run.

    Alternatively, maybe you can achieve what you want through callbacks. You can access incumbent values from the MIPSOL callback and then you can add lazy constraints and/or user cuts to the model. Note that you cannot change constraints or variables which are already present in the model. You also cannot add new variables in a callback.

    Best regards, 
    Jaromił

    0

Post is closed for comments.