--
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/da88bab7-c12f-4f8a-af01-4d422fa6e240%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
So, short answer, yes you can call StopSearch() asynchronously.
Le mar. 14 mai 2019 à 14:46, Simon Jesenko <simon....@gmail.com> a écrit :
--I did some more testing and uncovered an unrelated bug in my threading code that called `StopSearch` on timeout. Now the solution outlined above (ie. calling StopSearch from another thread) does indeed work for my use case!Thank you for this great library!Best regards,Simon
On Tuesday, May 14, 2019 at 2:16:37 PM UTC+2, Simon Jesenko wrote:Hi,is there a way to terminate cp-sat search in Python if no improved solution is obtained for some predefined timeout? I am using individual solver runs for local search, and if no improvement is found for some time, I would like to stop current search and start new search in new neighbourhood.`max_time_in_sec` is not well suited as I do not know in advance how solution will progress in each neighbourhood. There is `StopSearch()` in CpSolverSolutionCallback.OnSolutionCallback, which can however only be called when new solution is obtained. I would like to stop search before next solution is obtained...Is it maybe possible to store reference to SolutionCallback and call `StopSearch()` after some timeout from another thread? I tried using `Timer`, and delayed call to `StopSearch` worked for small timeouts (e.g. 1 sec), however for larger timeouts, solver just stops responding and does not terminate...Best regards,Simon
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.
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/IQVyGoJTe9w/unsubscribe.
To unsubscribe from this group and all its topics, 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/964a39c7-8e25-4caa-af7b-e8b6c6ec23c8%40googlegroups.com.
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/24391BCF-7C7E-464F-9957-327B19CD762C%40gmail.com.
To unsubscribe from this group and all its topics, send an email to or-tools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/964a39c7-8e25-4caa-af7b-e8b6c6ec23c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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.
To unsubscribe from this group and all its topics, 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/8813a1a2-9323-4c26-8320-a22322c5d56d%40googlegroups.com.
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/6AD5BE13-055C-4F57-8766-6DD66E79578E%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/CABcmEeYtAp0Y-7_uW-MEEQ91xQ28MPGHyXZH_Zk%2B4zGbCQR4sg%40mail.gmail.com.
Great, thanks!
On 14 Jun 2019, at 09:05, 'Laurent Perron' via or-tools-discuss <or-tools...@googlegroups.com> wrote:
Thanks, I will add the flag for 7.2.
Le jeu. 13 juin 2019 à 22:45, Simon Jesenko <simon....@gmail.com> a écrit :
Hi Evann,I have been running custom build of or-tools with threading support for SWIG wrapper in production for a month now and noticed no performance penalty or other issues…Stoping of solver between solutions with enabled threading support works flawlessly.Regards,Simon
To unsubscribe from this group and all its topics, send an email to or-tools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/8813a1a2-9323-4c26-8320-a22322c5d56d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/6AD5BE13-055C-4F57-8766-6DD66E79578E%40gmail.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/IQVyGoJTe9w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to or-tools...@googlegroups.com.
Thanks, I will add the flag for 7.2.
Le jeu. 13 juin 2019 à 22:45, Simon Jesenko <simon....@gmail.com> a écrit :
Hi Evann,I have been running custom build of or-tools with threading support for SWIG wrapper in production for a month now and noticed no performance penalty or other issues…Stoping of solver between solutions with enabled threading support works flawlessly.Regards,Simon
To unsubscribe from this group and all its topics, send an email to or-tools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/8813a1a2-9323-4c26-8320-a22322c5d56d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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.
from threading import Timer class ObjectiveEarlyStopping(cp_model.CpSolverSolutionCallback): def __init__(self, time_limit=10, print_objective=False): cp_model.CpSolverSolutionCallback.__init__(self) self._time_limit = time_limit self._print_objective = print_objective self._timer = None def on_solution_callback(self): if self._print_objective: print(self.ObjectiveValue()) if not self._timer: self._timer = Timer(self._time_limit, self.stop) self._timer.start() else: self._timer.cancel() self._timer = Timer(self._time_limit, self.stop) self._timer.start() def stop(self): print( 'Objective {} not changed in {} seconds, stopping solver...'.format( int(self.ObjectiveValue()), self._time_limit ) ) self.StopSearch()
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/f433e353-a2e0-432c-b57c-3f744b51ae5e%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/CABcmEeb5dPTXkWLY9peui1yJEAvnuz9njgAZ2e0CMQh0ORxbEw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/CADXFh5y7rZiYwSj12RMv%3Dm4AF3-go%3DOtgGc4Fi3VXx%3Dxk8vG_w%40mail.gmail.com.