max_time_in_seconds not working for MIP solver

321 views
Skip to first unread message

Mike Prince

unread,
Dec 31, 2019, 10:19:29 AM12/31/19
to or-tools-discuss
Hello,

I am using the MIP solver and trying to set a time limit on the solve.  I could not find any documentation for this exactly, but saw an example with the CP solver in which the following line of code was used:

 self.solver.parameters.max_time_in_seconds = 5

When I tried this (Python 3.7) for my model, it threw the following error:  "Failed to run set-cover 'Solver' object has no attribute 'parameters'"

So I removed ".parameters" and the following no longer throws an error:  

self.solver = pywraplp.Solver('simple_mip_program', pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)
self.solver.max_time_in_seconds = 60.0


That being said, it doesn't actually seem to cap the solve time, as I've had solves take several hours. Any ideas on what I'm doing wrong here?

Thanks





Maciej Reich

unread,
Dec 31, 2019, 10:22:53 AM12/31/19
to or-tools...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/866820a5-004f-496f-a351-421e7f5264b1%40googlegroups.com.

Mike Prince

unread,
Dec 31, 2019, 10:28:34 AM12/31/19
to or-tools-discuss
I will try that.  Thanks for the quick response!


On Tuesday, December 31, 2019 at 7:22:53 AM UTC-8, Maciej Reich wrote:
I think you may want to do

self.solver.SetTimeLimit( integer_time_in_ms )

On 31 Dec 2019, at 15:19, Mike Prince <mike....@convoy.com> wrote:

Hello,

I am using the MIP solver and trying to set a time limit on the solve.  I could not find any documentation for this exactly, but saw an example with the CP solver in which the following line of code was used:

 self.solver.parameters.max_time_in_seconds = 5

When I tried this (Python 3.7) for my model, it threw the following error:  "Failed to run set-cover 'Solver' object has no attribute 'parameters'"

So I removed ".parameters" and the following no longer throws an error:  

self.solver = pywraplp.Solver('simple_mip_program', pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)
self.solver.max_time_in_seconds = 60.0


That being said, it doesn't actually seem to cap the solve time, as I've had solves take several hours. Any ideas on what I'm doing wrong here?

Thanks






--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages