Skip to main content

Partially modify LHS of a constraint set?

Answered

Comments

4 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.
  • Mario Ruthmair
    • 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,
    Mario

    0
  • Amirhossein Moosavi
    • Gurobi-versary
    • 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?

    0

Post is closed for comments.