solver.Add(solver.Sum()) is crazy slow

549 views
Skip to first unread message

Nathan Petty

unread,
Sep 27, 2017, 11:14:09 AM9/27/17
to or-tools-discuss
Potential game breaker here:

using python, adding constraints of any real world size is prohibitively slow using solver.Add(solver.Sum(blah))

adding a mere 2k constraints takes 60s on top tier i7.  That's slower than the solve itself!  Each constraint has about 10k vars (the problem itself has 90k vars)

RIP or-tools?  bug fix in the works?  maybe a workaround for now?

Thanks, Nathan

Nathan Petty

unread,
Oct 12, 2017, 10:20:12 AM10/12/17
to or-tools-discuss
Still struggling with this.  Is anyone else noticing very slow runtime on adding constraints of any substantial size?  The big problem with this and the reason it could temporarily be a game breaker for or-tools, is that loading the problem is taking longer than solving the problem.   Any ideas would be greatly appreciated.  Thanks

Laurent Perron

unread,
Oct 12, 2017, 11:16:42 AM10/12/17
to or-tools-discuss
I have no good answer that do not use python for it.
I profiled it, just storing the data in the hash map, and rereading it to pass to the C++ makes for most of the time.

At best, I can gain a 2x, but I am not sure we can do better with python. I would love to be proven wrong.

Thanks

Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00


--
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-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nathan Petty

unread,
Oct 12, 2017, 11:24:31 AM10/12/17
to or-tools...@googlegroups.com
Thanks Laurent for looking into it. Does this mean I should go to c++ ?
>> email to or-tools-discu...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "or-tools-discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/or-tools-discuss/s0ayJRElsDo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> or-tools-discu...@googlegroups.com.

Laurent Perron

unread,
Oct 12, 2017, 11:29:51 AM10/12/17
to or-tools...@googlegroups.com
Can you write the same loop in C++ and see if it is worth it?
Reply all
Reply to author
Forward
0 new messages