Skip to main content

Gurobi says the model is infeasible, yet I can come up with a solution by hand (Python)

Answered

Comments

3 comments

  • Chung-Kyun Han
    • Gurobi Staff

    Thank you for reaching us.

    The default lower bound of a variable is zero (please refer to our manual about Model.addVar()).
    If you add variables like as follows, you will get the optimal solution you want.

    a = m.addVar(lb=-GRB.INFINITY, name="a", vtype=GRB.INTEGER)
    b = m.addVar(lb=-GRB.INFINITY, name="b", vtype=GRB.INTEGER)
    c = m.addVar(lb=-GRB.INFINITY, name="c", vtype=GRB.INTEGER)

    Whenever you have any questions, feel free to contact us.

     

    Best regards,
    Chung-Kyun Han

    0
  • yechan pyeong
    • Gurobi-versary
    • First Question
    • First Comment

    Thank you very much!

    0
  • Riley Clement
    • Gurobi Staff

    Hi Yechan,

    You should also take a look at our article How do I determine why my model is infeasible?

    With this knowledge, you will run

    m.computeIIS()
    m.write("model.ilp")

    and inspect the file that is written.

    - Riley

    0

Please sign in to leave a comment.