Apparently num_constraints only accepts concrete types, which means it’s not straightforward to return the total number of constraints in the model. Is there a straightforward way of doing this, or do we need to resort to something like
If there is no one-line way of doing this, I think it would be interesting to have a method for that (e.g. just num_constraints(m) without passing any types)
sum(num_constraints(model, F, S) for (F, S) in list_of_constraint_types(model))
You have to be a little careful with this, because it’s going to return an answer you might not expect. in particular, it will also count things like variable bounds and integrality as constraints, not just affine rows in the constraint matrix.