java-gurobi MIP: defining TimeLimit 5s ONLY IF feasible solution is found?

375 views
Skip to first unread message

ulibr...@gmail.com

unread,
Nov 15, 2013, 8:56:39 AM11/15/13
to gur...@googlegroups.com
Hello,

I'm calling Gurobi multiple times from Java to solve different small subproblems; I would like to keep runtimes low, so I limited the runtime to 5 seconds with set(GRB.DoubleParam.TimeLimit, 5).

Where this yields mostly results with MIPGap < 10% which is totally sufficient for me, sometimes it is not enough to get a feasible solution at all.

Is there a way to restrict it to something like (Timelimit=5 ONLY IF feasible solution has been found)? If it takes longer than 5 seconds I'd be happy with ANY feasible solution, no matter of quality.

--Already using callbacks, so maybe I could read runtime in there and decide to abort or not?

thanks,
Uli

Jakob Sch.

unread,
Nov 15, 2013, 10:01:16 AM11/15/13
to gur...@googlegroups.com
Hi Uli,

maybe you could write a simple callback that checks the time and the attribute SolCount (http://www.gurobi.com/documentation/5.6/reference-manual/solcount#attr:SolCount) for whether the model has found a solution or your timelimit is reached (use http://www.gurobi.com/documentation/5.6/reference-manual/runtime#attr:Runtime).

Best regards,
Jakob

Sonja Mars

unread,
Nov 15, 2013, 10:19:47 AM11/15/13
to gur...@googlegroups.com
Hi Uli,

I can think of different ways to implement this. One way without using a callback is, you could use a solution limit instead of a time limit. So the idea is:

Set the SolutionLimit parameter to 1
(http://www.gurobi.com/documentation/5.6/reference-manual/solutionlimit#parameter:SolutionLimit)
call model.optimize()
after termination check status code and runtime,
if runtime is smaller than 5s,
set timelimit to 5s minus runtime and increase SolutionLimit
call model.optimize() again (it will start from where it stopped)

-- Sonja

Reply all
Reply to author
Forward
0 new messages