Getting Binding Constraints
AnsweredHi, I want to get tight constraints at optimality for a linear model . It is possible to check equalities of constraints, but it would be better to have a simple Gurobi function to give binding constraints. Is there a function like this or is it possible to build?
Thank you
0
-
After optimizing, you can check if each (linear) constraint's Slack attribute is sufficiently close to \(0\). For example, in Python:
binding = [c for c in model.getConstrs() if abs(c.Slack) < 1e-6]
1 -
Thank you Mr Towle
0 -
Dear Mr. Towle, when I executed the code, It thrown me an error
AttributeError: 'ConcreteModel' object has no attribute 'getConstrs'
0 -
any help for the error.
0 -
Hi Muhammed,
It sounds like you are mixing Pyomo code with gurobipy code (we don't have a ConcreteModel object in gurobipy) which will not work.
- Riley
0
Please sign in to leave a comment.
Comments
5 comments