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?
Asked
Active
Viewed 141 times
0
-
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 Answers
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,433
- 2
- 20
- 23
-
2that'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