On 4/20/07, Torsten Anders <[EMAIL PROTECTED]> wrote:
Dear Joshua,
There are a number of problems with your example.
- You never call a solver
- You don't encapsulate your CSP in a script (your proc Dinner is not a
script!)
- You post constraints after calling FD.distribute
I didn't realize I needed to use a solver. I observed that the domain
was getting partially solved already. I thought that was sufficient.
Oops. I applied a solver to it and that immediately worked once I took
your other suggestions.
Or rather, I noticed that I was getting the same "waiting" behavior
from blindly applying a solver and thought it was the same problem as
I was seeing with FD.distribute. I also didn't realize that
FD.distinct needed to be applied after the other constraints.
For the edification of perhaps some other newbie out there, here's my
working code which has the additional refinement of abstracting off my
rules application a little bit.
functor
import
Application
System
FD
Property
Search
define
fun {Dinner N Rules}
proc {$ Guests}
{FD.tuple dinner N 1#N Guests}
{Rules Guests}
{FD.distinct Guests}
{FD.distribute ff Guests}
end
end
in
{Property.put 'print.width' 100}
{System.show {Search.base.one {Dinner 20
proc {$ Guests}
proc {LeftOf Left Right}
Left <: Right
end
proc {Adjacent Left Right}
Left =: Right - 1
end
in
%% Guests 1 to 12 sit left of
each other with people possibly
%% between them.
for L in 1..11 do
R
in
R = L + 1
{LeftOf Guests.L Guests.R}
end
%% 17th guest is in seat 1
Guests.17 =: 1
%% 18 is immediately to the left of 19.
{Adjacent Guests.18 Guests.19}
end}}}
{Application.exit 0}
end
Josh
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users