:- use_module(library(thread)).(can be autoloaded)
For example, if it is unclear whether it is better to search a graph breadth-first or depth-first we can use:
search_graph(Grap, Path) :- first_solution(Path, [ breadth_first(Graph, Path), depth_first(Graph, Path) ], ).
Options include thread stack-sizes passed to
thread_create, as well as the options
that specify what to do if a solver fails or triggers an error. By
default execution of all solvers is terminated and the result is
returned. Sometimes one may wish to continue. One such scenario is if
one of the solvers may run out of resources or one of the solvers is
known to be incomplete.
stop(default), terminate all threads and stop with the failure. If
continue, keep waiting.
- As above, re-throwing the error if an error appears.
- first_solution/3 cannot deal with non-determinism. There is no obvious way to fit non-determinism into it. If multiple solutions are needed wrap the solvers in findall/3.