CBC mixed integer: having Solver terminate early if solutions are no longer improving

876 views
Skip to first unread message

Kenneth Wronka

unread,
Jan 19, 2021, 9:26:01 AM1/19/21
to Pyomo Forum
I have a mixed-integer Pyomo model using CBC that solves pretty slowly; it seems like it gets to a reasonable solution pretty fast and but hits diminishing returns closing the gap and then just goes on solving for a very long time (would probably take days--I usually interrupt it).

I have started adding a time limit to the solver of a couple hours and find I usually get acceptable solutions this way. However, it feels bad to just guess how long I have to run it ahead of time and run it for that long. It makes the results process very fragile: I cannot pause it, I cannot continue where I left off if I haven't found a solution yet, and I cannot stop it early if it found a pretty good solution that is not improving anymore but doesn't quite hit what I guessed for MIP gap.

Therefore, I'd prefer to set up a more intelligent termination situation where the model at least looks at whether it has a feasible solution yet and if it is still making progress. Anything that can make the solution problem more robust for early stoppage. I know I can make the gap tolerance much larger but I have a bunch of different parameters and objective functions and cannot really predict what gap it will make it up to ahead of time.

I found this question on Stack Overflow, but the answers were not ideal:

From this it seems like it might be something I'd have to do myself but do not know where to start on this. At this point in time it basically feels like I hand off control to the solver and hope for the best. I would not know where to even begin to try to add this functionality to the solver process. Any guidance or help would be greatly appreciated!


Message has been deleted

MP

unread,
Jan 27, 2021, 1:29:45 PM1/27/21
to Pyomo Forum
In a similar case, I'm using "ratio gap" limit in addition to time limit:

solver = po.SolverFactory('cbc')
solver.options['Seconds'] = 60
solver.options['RatioGap'] = 0.01
results = solver.solve(m, tee=True)

I hope this works for you too.

omowu...@gmail.com

unread,
Jan 28, 2021, 3:49:59 AM1/28/21
to Pyomo Forum
Please I am having the same challenge but using Gurobi solver. I have been running a model for about three weeks now. Please is there a way to terminate the model while running and still extract the results it has so far?

Thank you
Reply all
Reply to author
Forward
0 new messages