Is there a way one can show all solutions and/or find how many there are in SICSTus prolog? For instance, the code below maybe used to solve the map colouring problem.
:- use_module(library(clpfd)).
solve_AUSTRALIA(WA,NT,Q,SA,NSW,V):-
domain([WA,NT,Q,SA,NSW,V], 1, 4),%colours represented by integers from 1 to 4
WA #\= NT,
WA #\= SA,
NT #\= SA,
NT #\= Q,
SA #\= Q,
SA #\= NSW,
SA #\= V,
Q #\= NSW,
NSW #\= V,
labeling([],[WA,NT,Q,SA,NSW,V]).
At the moment,I am typing ;
every time to see further solutions till Prolog says no. Is there a way I can tell prolog to show all solutions at once, or better, a way I can find how many there. Like prolog tells me there are five solutions to the problem.
findall/3
,findall/4
,bagof/3
orsetof/3
. They are similar. For ex, what you want to do is put your solution predicate infindall(+Templagte, :Solution, -Bag)
, and original data set asTemplate
, and collective solution as-Bag
. – RandomEliassert(clpfd:full_answer)
at the toplevel to get the full answer including all constraints attached! – false