Dear Mark,

Just in case: there is a little typo in Raphael's code, a missing parenthesis

Xs={E one({Queens 20} $}

This should read

Xs={E one({Queens 20} $)}

I can confirm that this example works on Mozart 1.3.2, but please remember that problems for parallel search have been reported for Mozart 1.4.0.

Best,
Torsten

--
Torsten Anders
Interdisciplinary Centre for Computer Music Research
University of Plymouth
Office: +44-1752-586219
Private: +44-1752-558917
http://strasheela.sourceforge.net
http://www.torsten-anders.de





On 31 Oct 2008, at 11:23, Raphael Collet wrote:

Dear Mark,

The functor that you give to the search engine must export the script of the problem. Here you export a function that creates the script! You should remove the function from your functor, and keep the procedure only:

declare
functor Queensdist
import FD
export Script
define
   proc {Script Row}
      L1N=...
      ...
   end
end

You can even write a function that returns a functor. This makes it possible to generate a script functor for a given size N of the problem (no more hardcoded):

declare
fun {Queens N}
   functor
   import FD
   export Script
   define
      proc {Script Row}
         L1N={MakeTuple c N}
         LM1N={MakeTuple c N}
      in
         {FD.tuple queens N 1#N Row}
         for I in 1..N do
            L1N.I=I LM1N.I=~I
         end
         {FD.distinct Row}
         {FD.distinctOffset Row LM1N}
         {FD.distinctOffset Row L1N}
         {FD.distribute generic(value:mid) Row}
      end
   end
end

E={New Search.parallel init(localhost: 2)}
Xs={E one({Queens 20} $}          % solves Queens for N=20
{Browse Xs}

Cheers,
raph

On Thu, Oct 30, 2008 at 11:50 PM, mark richardson <[EMAIL PROTECTED]> wrote:
Hi,
I'm still learning about the FD aspect of Mozart-Oz (amongst other things) and I've been toying with using parallel search with the n- queens script from the documentation, but with little success. This is the code I'm using:

declare Queensdist E Xs M Host
functor Queensdist
import FD
export Script
define
 fun {Script}
    proc {$ Row}
   L1N ={MakeTuple c 200}
   LM1N={MakeTuple c 200}
    in
   {FD.tuple queens 200 1#200 Row}
   {For 1 200 1 proc {$ I}
             L1N.I=I LM1N.I=~I
          end}
   {FD.distinct Row}
   {FD.distinctOffset Row LM1N}
   {FD.distinctOffset Row L1N}
   {FD.distribute generic(value:mid) Row}
    end
 end
end

[M]={Module.apply [Queensdist]}
E={New Search.parallel init(localhost:2)}

Xs={E one(Queensdist $)}

{Browse Xs}

Browsing Xs just gives me [<P/1>]. Can anyone offer any suggestions?

I'm not certain about the use of localhost as this isn't my host name, but the actual hostname doesn't seem to be accepted at all and the documentation says that localhost refers to the host that spawned the oz process.

Before this version, I had kept the parametrised version which worked on it's own with a {Browse {SearchOne {M.script 200}}} but I amended the script to have a fixed value of 200 instead. Needless to say, the script won't work either way now??? So, can this script still be parametrised like the original n- queens script and if so how?

Regards
Mark

--
Mark Richardson
Final year undergraduate
University of Teesside
______________________________________________________________________ ___________ mozart-users mailing list mozart- [EMAIL PROTECTED]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

<ATT00001.txt>

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to