Skip to main content

Updating Lists Under Conditional Statements

Answered

Comments

1 comment

  • 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

Please sign in to leave a comment.