concurrent_maplist. When did these kind of predicates enter the language?
concurrent_maplist/2 was added 2012-01-15; the various concurrency predicates are older. (I found one commit that referenced concurrent/3 dated 2007-06-27; the multi-threading support appears to have been added in mid-1999.)
Hi all,
I’m trying to use findnsols/3 for finding only 100 answers for a KG completion task.
However, I have found a case where there are 3 answers but findnsols(100,…) finds 0.
A file to reproduce it is at lp4kg/fbk237/bug.pl at b85ee8a89e2d1cfb465b456132c5599fe3ea2310 · friguzzi/lp4kg · GitHub
by calling mainfa(Ans) you get all answers, by calling mainfn(Ans) you get the first 100 solutions.
Unfortunately, the first query returns 3 answers, while the latter 0.
How is it possible?
Fabrizio
The sort could be removing duplicates (resulting in potentially 1 element, for example), and filter_atoms could be filtering out the remainder.
Look at the result of findnsols/4 itself.
You’re right, the problem was in sorting.
However, how to find n distinct solutions?
Anything that can reduce the number of solutions should be inside the findnsols/4 (i.e. being called by it) rather than after it.
Here is my stab at it
I think you are looking for distinct/2. Unfortunately it is rather slow, using a Prolog base hash-table and non-backtrackable destructive assignment. Possibly we should add a fast version using all available low-level tricks.
In the end I implemented a solution using asserts for checking uniqueness and the number of solutions. However, I got different results using maplist and concurrent_maplist, see the post Difference in success between maplist and concurrent_maplist