0

I wanna solve a quadratic optimization problem with Gurobi in Python. If the problem is solvable in a reasonable time like 3600s, I wanna solve it to optimality. However, if I cannot solve it within 3600s, I wanna solve it with a relative gap = 0.05. How can I set these conditions in Gurobi?

Joe Ferndz
  • 8,163
  • 2
  • 11
  • 32
  • See https://stackoverflow.com/questions/492519/timeout-on-a-function-call, maybe you can wrap your Gurobi call with this timeout, and then change the relative gap. – K.Cl Mar 31 '21 at 21:22

1 Answers1

3

This is covered in the Gurobi knowledge base article How do I set multiple termination criteria for a model?. (Disclaimer: I work for Gurobi and I wrote that KB article).

Greg Glockner
  • 5,229
  • 2
  • 19
  • 22
  • 2
    that's so awesome to see the KB article owner respond to the question. – Joe Ferndz Mar 31 '21 at 21:25
  • Thank you so much. Could you please let me know where you have specified the optimality gap? – Katan katalan Apr 01 '21 at 04:26
  • @Katankatalan That's explained in the KB article: set TimeLimit=3600; optimize; check the Status; if necessary, optimize again with MIPGap=0.05 and whatever new value you need for TimeLimit. – Greg Glockner Apr 01 '21 at 22:04