> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On
> Behalf Of Raphael Collet
> Sent: Thursday, May 24, 2007 3:32 AM
> To: Mozart users
> Subject: Re: Computing shifted dot product
> 
> Dear George,
> 
> George Rudolph wrote:
> > I suppose some of the reasons the code may be confusing are the
> > following:
> >
> > 1. I was creating only one list of domain variables (Histogram),
instead
> >    of using two Lists (Histogram and a shifted copy of Histogram).
This
> > means writing the constraints for the shifted copy in terms of
indexes
> > in the original list.
> > I thought that doing this would save space, and I wasn't sure that
> > shifting domain variables in a list, the way you show in the code
below,
> > would work
> > the way I expect.  Apparently it does, which is good.
> 
> Actually creating a list with the shifted elements is cheap, because
> that list is used once by List.zip, then it is no longer referenced.
> This list is not copied when the spaces are cloned by the search
engine,
> for instance.
> 
> > 2. I'm not computing and constraining the shifted dot product just
once,
> > but actually computing/constraining a sequence of shifted dot
> > products--that is,
> > the product of Histogram and Histogram shifted once, the product of
> > Histogram and Histogram shifted twice, and so on, up to
> > (length-of-Histogram) - 1 shifts.
> >
> > This version of the code is more like what I want, though it
> > doesn't seem to work, in that no solutions are found
> > when I call it with
> >
> > {Autocorrelate Count (2*T - 1)}
> >
> > It fails with a red square, as opposed to a light green diamond.
> >
> >
> > ---------- begin code ------------------
> > proc {Autocorrelate Xs Val}
> >      NumberOfShifts = {List.length Xs} - 1
> >  in
> >     for I in 1..NumberOfShifts do
> >        %rotate the list Xs by: splitting the list at position I
> >        %then slicing the list back together with the parts swapped
> >     CopyOfXsRotatedISlots={Append {List.drop Xs I} {List.take Xs I}}
> >     Matches={List.zip Xs CopyOfXsRotatedISlots fun {$ X Y} X=:Y end}
> >      in
> >         {FD.decl Val}
> >     {FD.sum Matches '=:' Val}
> >     {Browse Matches}
> >         end
> > end
> 
> George, you are constraining *all* the shifted dot products to be
equal
> to Val.  Is this what you meant?

Yes, I do mean to constrain all the dot products to be equal to Val in
this case.
I mentioned that currently, the solver is failing (red square).
Mathematically, it should work, unless my logic is flawed or
the theorem I have proven is flawed.
Basically, the theorem proves that if the sequence of dot products is
constant/flat (all values are the same), other internal
balances/properties
of the sequence are guaranteed.

> 
> You can make Autocorrelate return a list of the products by using the
> 'collect' feature of the for loop as:
> 
> fun {Autocorrelate Xs}
>     NumberOfShifts = {List.length Xs} - 1
> in
>     for
>        I in 1..NumberOfShifts
>        collect:Collect
>     do
>        %% rotate the list Xs by: splitting the list at position I then
>        %% slicing the list back together with the parts swapped
>        CopyOfXsRotatedISlots={Append {List.drop Xs I} {List.take Xs
I}}
>        Matches={List.zip Xs CopyOfXsRotatedISlots fun {$ X Y} X=:Y
end}
>        Val
>     in
>        {FD.decl Val}
>        {FD.sum Matches '=:' Val}
>        {Collect Val}
>     end
> end

Ah, that is a nice feature!
I don't know that I can use the information for anything
in this program yet, except it will be nice for debugging, at least,
but you never know.
Thanks!
> 
> 
> I hope this helps,
> raph
> 
>
________________________________________________________________________
__
> _______
> mozart-users mailing list                               mozart-
> [EMAIL PROTECTED]
> http://www.mozart-oz.org/mailman/listinfo/mozart-users

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

Reply via email to