[gecode-users] FW: Help:How to compute Autocorrelation of a v-length sequence

George Rudolph george.rudolph at citadel.edu
Wed Oct 24 02:41:30 CEST 2007


Below I am posting an answer from Christian Schulte to some questions
that I thought I had also posted to the mailing list, but did not.
So here they are.

George

-----------------------------------------------------------------------

Dear George,

thank you for your constructive attitude, I would also like to apologize
to
you for being quite rude: I fear that we have to be focused in what kind
of
discussions take place on the mailing list: Gecode does not target
people
not knowing constraint programming in general; we would like to keep the
discussions on a level that assumes prior knowledge.

However, questions those such as you phrase below are very good! After
you
took the effort to isolate questions their answers can be reused and
capture
nicely some knowledge required to implement a model in Gecode (or
Gecode/J).

So let me try.

1. You can't. You have (as you hint yourself) create an additional
IntVar
and constraint it to a single value (either by how you initialize it or
by
operations such as rel or dom). While doing otherwise is difficult in a
statically typed language such as C++ or Java, Mozart will do quite
often
exactly the same thing without you knowing.

2. I assume that you mean posting a constraint that compares for
equality
when you refer to "compare". 
   The following steps should work:
   - You declare an array of BoolVarArgs, say b, of the right size.
   - You iterate over all element with a loop.
   - You initialize (yes, BoolVarArgs does not initialize its elements)
each
b[i], say with
		b[i].init(this,0,1)
   - You post a comparison constraint between x[i] and y[i]
		rel(this, x[i], IRT_EQ, y[i], b[i]);
   - Counting is then just a linear constraint, say you have an IntVar c
for
the result
		linear(this, b, IRT_EQ, c);

Hope that helps.

All the best
Christian

-----Original Message-----
From: George Rudolph [mailto:george.rudolph at citadel.edu] 
Sent: Sunday, October 21, 2007 4:13 AM
To: cschulte at kth.se
Subject: RE: [gecode-users] Help:How to compute Autocorrelation of a
v-length sequence

Christian,

No need to apologize. I know that development time is precious.
Especially yours.
I completely agree that it is a modeling issue.
Unquestionably. And non-trivial, or not simple.
My intent was to ask for help from the community,
and I do not intend someone to spend time they don't have.

I do not understand what you mean by "Gecode-specific", however.
For example, I have Oz Mozart code that computes this algorithm,
and in fact I'm doing a translation to Gecode/J because
it allows me to use Java tools, and I'm hoping it's more
efficient, and syntactically cleaner than what I have.
And it will help me learn the language/API.
>From that perspective, I thought I was asking Gecode-specific questions,
and not about general modeling questions. I can specify the constraints
mathematically, I just don't know how to implement/model them in
Gecode/J.
I suppose it would be helpful if I broke the larger problem down into
more specific questions, such as:
1.  Suppose I have a list like [0,x,y] where 0 is a definite integer and
x
and y
    are finite domain variables. How do I represent such a list in
Gecode/J?
    (Note: By definite integer, I mean that I know the element is 0, so
it
doesn't
    have to be a finite domain variable.)
2.  Suppose I want compare the list [0,x,y], defined as above, with
another
    list [y,0,x], element by element, and count the number of positions
in
which
    they match. How should I do this comparison in Gecode/J?
    (Note: I have tried comparing two list element-by-element,
generating a
Boolean
     list of the results by position, where true = match, and false =
mismatch,
     then casting the BooleanVar array to an IntVar array, where 0=false
and
1=true,
     then counting the 1's, but this did not work as I expected.)




More information about the gecode-users mailing list