Skip to main content

Getting Binding Constraints

Answered

Comments

5 comments

  • Eli Towle
    • Gurobi Staff Gurobi Staff

    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
  • MEHMET RIFAT KAMBER
    • First Comment
    • Gurobi-versary
    • First Question

    Thank you Mr Towle

    0
  • Muhammad Dzulqarnain Firdausi
    • Gurobi-versary
    • First Comment
    • First Question

    Dear Mr. Towle, when I executed the code, It thrown me an error

    AttributeError: 'ConcreteModel' object has no attribute 'getConstrs'
    0
  • Muhammad Dzulqarnain Firdausi
    • Gurobi-versary
    • First Comment
    • First Question

    any help for the error.

     

    0
  • Riley Clement
    • Gurobi Staff Gurobi Staff

    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.