You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There appears to be a problem with the Machine Query Interface (at least when called from Python using the swiplserver library) that results in queries reaching a timeout, while the same queries produce an almost instant result in the GUI. The following example illustrates the problem:
Example
Consider the following Prolog implementation of the TAK-function (I am aware that it is not a correct implementation of the function).
tak(X,Y,Z,Y).tak(X,Y,Z,R) :-X<Y,
X1 is X-1,
Y1 is Y-1,
Z1 is Z-1,
tak(X1, Y, Z, R1),
tak(Y1, Z, X, R2),
tak(Z1, X, Y, R3),
tak(R1, R2, R3, R).
When executing the query tak(1, 2, 3, R). , the GUI version of SWI-Prolog returns an almost instant result:
\
However, when executing the same query through the MQI interface using the python library swiplserver, and the following implementation, the query results in a timeout even when setting a high timeout time (maximum that I tried is 1000 seconds).
fromswiplserverimportPrologMQI# Todo Replace with absolute path on your systemprolog_file_path="C:/Users/daji01/Documents/tak.pl"mqi=PrologMQI()
withmqi.create_thread() asprolog_thread:
prolog_thread.query(f'consult("{prolog_file_path}").')
result=prolog_thread.query("tak(1, 2, 3, R).", query_timeout_seconds=5)
print(result)
Other Prolog programs work fine with this implementation. I am using SWI-Prolog version 9.2.1 for x64-win64 on Windows 11 Pro Version 10.0.22631 Build 22631.
The text was updated successfully, but these errors were encountered:
You'd probably better ask on Discourse as more people look there. Didn't MQI do a findall/3? You implementation produces an infinite number of results, so a findall/3 will not complete (well, eventually runs out of memory).
Thank you for the hint! However, I wonder why the GUI version returns a single result if an infinite number of results are produced and the MQI does not. Is the difference in behavior intended?
Sorry, I was not aware that you could enter ";" and get more results. I was pressing Enter, and it would stop after one result. It seems there was no Problem after all, and I misjudged the issue because I am not that familiar with SWI-Prolog. Sorry for the confusion.
There appears to be a problem with the Machine Query Interface (at least when called from Python using the swiplserver library) that results in queries reaching a timeout, while the same queries produce an almost instant result in the GUI. The following example illustrates the problem:
Example
Consider the following Prolog implementation of the TAK-function (I am aware that it is not a correct implementation of the function).
When executing the query
tak(1, 2, 3, R).
, the GUI version of SWI-Prolog returns an almost instant result:\
However, when executing the same query through the MQI interface using the python library swiplserver, and the following implementation, the query results in a timeout even when setting a high timeout time (maximum that I tried is 1000 seconds).
Other Prolog programs work fine with this implementation. I am using SWI-Prolog version 9.2.1 for x64-win64 on Windows 11 Pro Version 10.0.22631 Build 22631.
The text was updated successfully, but these errors were encountered: