• Gurobi Staff

Gurobi does lazy updates to the model. You won't see that this constraint was deleted until the update is processed. To force the update to process immediately, call model.update().

I understand. My question is, how can I add this constraint back to the model?

• Gurobi Staff

If you want to remove a constraint and add it later, you need to get the elements of a constraint. For a linear constraint, it looks like this:

c = m.getConstrs()[0] # for examplelhs, sense, rhs, name = m.getRow(c), c.Sense, c.RHS, c.ConstrNamem.remove(c)# Optional, to show the current statem.update()m.printStats()# Add the constraintc = m.addConstr(lhs, sense, rhs, name)# Also optional, to show the current statem.update()m.printStats()

But if I want to add constraint back in a .NET environment, how can I do to get the lhs of the constraint c?
I found that there's no attribute 'LHS' in a constraint of .NET environment so I don't know how to do that....

Thanks!

• Gurobi Staff

Hi,

You can get the LHS by using the getRow() function.

Best regards,
Jaromił