Gurobi stuck after time limit has reached and a feasible solution is foundAnswered
I am trying to solve a MIP in Gurobi using Python in the university cluster. I cut the optimization with a time limit, and I receive a feasible solution after the time limit has reached. But, at that stage, the code gets stuck with no errors and doesn't continue with the next line of code?
Any ideas why that be? I tried running the model with many memory size allocations and thread counts, but the results is still the same.
Could you elaborate on how and where Gurobi "gets stuck"? Does the execution of your code not proceed beyond the optimize() call? Are you using any callbacks in your code?
In my code, I have a time limit of 200 seconds and before the optimize() call, I print 'before optimization'. And after the optimize() call, I print 'after optimization'. These 3 consecutive lines of code is below:
model.Params.timeLimit = 200.0
When the time limit of 200 seconds has reached, I receive the best found solution and the gap% as you can see below in the output . After the execution of optimize() call, I would expect the code to proceed to the next line and print 'after optimization', but this never happens. It continues running without any output for several hours until I cancel the job or it is cancelled automatically by the Slurm system because of the time limit. The code doesn't give any errors until I or the Slurm system cancel the execution.
That is odd, what happens if you run this locally on your machine? The log indicates that Gurobi finished the optimization, I have no idea why it is not returning. Do you run any kind of multi-processing, is this the only model that is solved or is anything running in parallel? Also, can you monitor the machine resources while this phase where it hangs?
Another test you could to is to write out an MPS file using
before you call optimize(). And then try to run it again using the Gurobi command line gurobi_cl.
I have the same problem! And I run on a distributed computing environment. I have one head node and 8 worker nodes. The head node basically distributes the workers and does a synchronization while the worker nodes run Gurobi instances in parallel and report the results to the head node. The whole program is written in Python.
The program runs quite fine until one Gurobi instance comes across a problem unable to be solved within the given time period. And then it gets stuck and the head node waits indefinitely for a response from the worker.
Time limit reached
Best objective 5.705811978590e+10, best bound 5.339642852052e+10, gap 6.4175%0
Hello, have you found the solution to your problem? I'm having a similar problem. I'm trying to solve a variant of the vehicle routing problem. I use a callback function to add capacity constraints as lazy constraints. When I set the time limit to e.g. 10 seconds a solution is found after that, but Python is still running and nothing happens after that. I have some additional code that comes after the line with model.optimize(callback) to print and plot the solution but that doesnt happen. When I run the code without the callback function everything works fine. When I use the callback function and Gurobi finds the optimal solution before the time limit everything works fine too.0
Can you post a minimal, self-contained code example that reproduces the issue? It's difficult to say what's going on without examining the code.0
Hello, Ive found the issue which was my own fault. The model.cbLazy() that I use were formulated incorrectly. After outputting a solution, the code would get stuck in a while loop. So it was a model issue, not a Gurobi issue. Nonetheless, thanks for the reply.0
Please sign in to leave a comment.