Skip to main content

Gurobi stuck after time limit has reached and a feasible solution is found

Answered

Comments

8 comments

  • Official comment
    Simranjit Kaur
    Gurobi Staff Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?.
  • Matthias Miltenberger
    Gurobi Staff Gurobi Staff

    Hi Ozgur,

    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?

    Thanks,
    Matthias

    0
  • Ozgur Satici
    Gurobi-versary
    First Question
    First Comment

    Hi Matthias,

    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
    print('before optimization')
    model.optimize()
    print('after optimization')

    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.

    Thank you

    Ozgur

    0
  • Sonja Mars
    Gurobi Staff Gurobi Staff

    Hi Ozgur,

    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

    model.write("mymodel.mps")

    before you call optimize(). And then try to run it again using the Gurobi command line gurobi_cl.

    Best,

      Sonja

    0
  • Pramod Herath
    Gurobi-versary
    First Comment

    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
  • Scott Merks
    Gurobi-versary
    First Comment

    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
  • Eli Towle
    Gurobi Staff Gurobi Staff

    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
  • Scott Merks
    Gurobi-versary
    First Comment

    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

Post is closed for comments.