Deleting containerized constraints

Please provide a minimum working example:

In particular

  • what solver are you using?
  • how long does it take to rebuild the model vs delete the constraints?
  • the way you are deleting in the loop is the correct syntax

just to add, I know there is set_coefficient and the hack with .fix to change the RHS… but what’s the point of a high level modeling language if I need to aggregate up the coefficients and constants myself

Using fix to change the RHS is not a hack. It is the official way to change the RHS. Why?

  • @constraint(model, 2x + 1 <= 3) Is the RHS 3 or 3-1=2?
  • @constraint(model, 1 <= 2x + 1 <= 3). What is the RHS?

If you have lots of duplicate variables, it should be possible to restructure your code to simplify things.