Dear Jeffery,

you may consider modelling your set as a list of FD integers and then apply 
you constraints to list elements by iteration. I prefer higher-order 
procedures instead, because the code is then more descriptive.  

%% aux defs
proc {For2Neighbours Xs Proc}
   for X in {List.take Xs {Length Xs}-1}
      Y in Xs.2
   do {Proc X Y}
   end
end
proc {ForCartesianProduct Xs Ys P}
   {List.forAllInd Xs
    proc {$ I X}
       {List.forAllInd Ys
        proc {$ J Y}
           {P X Y}
        end}
    end}
end
proc {Increasing Xs}
   {For2Neighbours Xs proc {$ X Y} X <: Y end}
end

%% your set
Xs = {FD.list 52 0#FD.sup}

%%
%% constraint applications to your set
%%

{Increasing Xs}

%% constraints between 
{For2Neighbours {List.take Xs 10}
 proc {$ X Y}
    Z = {FD.int 2#FD.sup}
 in
    X + Y =: Z
%    {FD.plusD X Y Z}
 end}

%% constraint between all set element pairs
{ForCartesianProduct
 proc {$ X Y}
    %% your constraint here
    skip
 end}

Best
Torsten

On Monday 07 May 2007 03:34, Jeffery Candiloro wrote:
> G'Day,
>
> Please excuse the newbie question - I am trying to learn as fast as I can!
>
> I have a set with 52 elements that I need sorted according to various
> rules.  One of those rules is that the distance between any two of the
> first 10 elements should be at least 2.
>
> I have been trying to figure out the algorithm to run this to no avail.
>  Short of writing 66 {FD.distance ....} propagators can anyone suggest a
> better way?
>
> Thanks in advance.
>
> Cheers
>
> Jeffery
>
> ___________________________________________________________________________
>______ mozart-users mailing list                              
> [email protected]
> http://www.mozart-oz.org/mailman/listinfo/mozart-users

-- 
Torsten Anders
http://strasheela.sourceforge.net/
http://torsten-anders.de/
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to