Skip to main content

Partially modify LHS of a constraint set?




  • Mario Ruthmair
    Gurobi Staff Gurobi Staff

    Hi Amirhossein,

    Indeed, we strongly recommend updating your model in place without rebuilding it from scratch. You can do this similar to the following:

    1. Add the new column/variable to the model via mdl_master.addVar().
    2. Iterate through the relevant constraints (mdl_master.addConstrs() returns a tupledict of constraints indexed by i).
    3. In all constraints where the new variable should have a non-zero coefficient, change the coefficient via mdl_master.chgCoeff(). If you do nothing for a constraint, then the new variable automatically has a coefficient of zero.

    Best regards,

  • Amirhossein Moosavi
    First Comment
    First Question

    Thanks a lot, Mario. Got it but have another question. What if I want to remove a column from the restricted master problem (removing the variable itself and from all constraints)? It seems that I can remove a variable by rmp.remove(). But what about removing it from the constraint?


Please sign in to leave a comment.