[mercury-users] Re: can one_solution/2 and unsorted_solutions/2 be det?

Lee Naish lee at cs.mu.oz.au
Wed Oct 29 11:41:27 AEDT 1997


In message <199710282112.IAA16306 at mundook.cs.mu.OZ.AU>Andrew write:
>potential_solution(Constraints, Solution) :-
>	generate_solution(Solution),
>	satisfies(Constraints, Solution).
>
>So how to pick an arbitrary solution without generating the whole list
>of solutions?  We could use committed choice nondeterminism, however,
>the driver program that your player would be tested with (hi Tom!) had
>its main being det.

In increasing order of complexity of your algorithm, the solution is

1) Change the interface to cc_multi.
2) Implement a "first solution" construct.  Unfortunately this depends
on the clause and literal selection strategy, which Mercury does not
currently allow the programmer to fix.  You would have to fix this in
order to make this construct declarative (as done in Trilogy).  The
disadvantage of first solution primitives is the semantics is
complicated.  The advantages are they are quite useful and very cheap to
implement.  Its a very pragmatic approach.  I suspect Bart would be
happy with it.
3) Program your own search algorithm rather than relying on built in
backtracking.

	lee



More information about the users mailing list