I want to limit the "execution" of the algorithm in the prolog. Can you give me a hint how to do this? I found this predicate: call_with_time_limit How can I catch the time_limit_exceeded exception? Thanks
UPDATE:
I try like this:
timeout(t) :- catch(call_with_time_limit(t, sleep(5)), X, error_process(X)). error_process(time_limit_exceeded) :- write('Timeout exceeded'), nl, halt. error_process(X) :- write('Unknown Error' : X), nl, halt.
but note that when I call the timeout (1):
prolog :- timeout(1),
but when I do it like this:
runStart :- call_with_time_limit(1, sleep(5)). timeout(1) :- catch(runStart, X, error_process(X)). error_process(time_limit_exceeded) :- write('Timeout exceeded'), nl, halt. error_process(X) :- write('Unknown Error' : X), nl, halt.
and again the call waiting time (1) is all right. What for? thanks UPDATE 2:
The problem is solved, it is necessary to provide an "argument" with upper case ...
source share