backtrackable call_with_time_limit/2

21 views
Skip to first unread message

Eyal Dechter

unread,
Apr 22, 2015, 2:48:46 PM4/22/15
to swi-p...@googlegroups.com
Hi all, 

I would like to impose a time limit on every branch of a backtracking predicate. call_with_time_limit/2 only executes its goal once, so there's no way to proceed to the remaining alternatives. What's the best way to achieve this? Does it require a different implementation of call_with_time_limit, or is there some way to save the choice points of the Goal? 

Thanks,
Eyal

Markus Triska

unread,
Apr 22, 2015, 4:32:23 PM4/22/15
to swi-p...@googlegroups.com
Hi Eyal,

if at all possible, I recommend call_with_inference_limit/3. See its documentation for more information. It overcomes the limitation you mention, and results are also much more reproducible if you use it instead of a time limit.

I hope this helps.

All the best,
Markus

Eyal Dechter

unread,
Apr 22, 2015, 8:32:50 PM4/22/15
to Markus Triska, swi-p...@googlegroups.com
Ok, thanks, I guess the number inferences per second is stable enough to allow for rough time limits. 

Eyal

--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.
Visit this group at http://groups.google.com/group/swi-prolog.
For more options, visit https://groups.google.com/d/optout.

Jan Wielemaker

unread,
Apr 23, 2015, 3:42:47 AM4/23/15
to Eyal Dechter, Markus Triska, swi-p...@googlegroups.com
On 04/23/2015 02:32 AM, Eyal Dechter wrote:
> Ok, thanks, I guess the number inferences per second is stable enough to
> allow for rough time limits.

It depends what you are doing. If you run plain Prolog code, inference
number gives, as Markus claims, a nicely reproducible limit. If your code
contains network interaction or other expensive operations (largely)
written in C, a wall time limit is typically to be preferred.

call_with_time_limit/2 is written on top of the alarm primitives. You
can surely write a version that will re-inforce the limit on backtracking.
See time/1 for code that times backtrackable goals.

Cheers --- Jan
> <mailto:swi-prolog+...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/swi-prolog.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swi-prolog+...@googlegroups.com
> <mailto:swi-prolog+...@googlegroups.com>.
Reply all
Reply to author
Forward
0 new messages