0

I used a list of a constraint numbers or a list of constraint names but this does not work with command m.remove_constraints().

m.add(sumbs[i] <= a[i], "ct_sum_%d" %i)

A.append("ct_sum_%d" %i)

Then later on when I want to change the model: m.remove_constraints(A)

What is the correct way of doing this?

pudu39
  • 15
  • 3

1 Answers1

0

Model.add_constraints() returns the list of newly added constraints.

Similarly, Model.remove_constraints takes a collection of constraint objects, not names , not indices. For example:

cts = mdl.add_constraints(...)
mdl.remove_constraints(cts[:3]) # remove the first three
Philippe Couronne
  • 826
  • 1
  • 5
  • 6