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
> [email protected]
> http://www.mozart-oz.org/mailman/listinfo/mozart-users
>
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to