Efficiently use concurrency predicates to find n solutions

We have first_solution/3 to efficiently perform concurrent searches for a solution. We have findnsols/4 to find (up to) the first n solutions.

It stands to reason that someone might want to perform concurrent searches for (up to) n solutions. I’m currently that someone.

It seems there’s plenty to work with in SWI-Prolog’s multithreading library for a DIY implementation. I just want to avoid reinventing the wheel if there’s something else I should be looking into. Is there?

An important note is that the separate goals (strategies) I’d use to generate solutions have a very low likelihood of creating redundant solutions between themselves, (and I don’t care if they do).

There is nothing out of the box. It is basically a variant on first_solution/3 though, where you merely have to wait for N rather than 1 (and again decide what to do with failure or errors).

I’m happy to handle a PR that adds this. It seems a reasonable thing to have.

1 Like