[gecode-users] count/atleast: partial propagation towards y ?

Didier Loiseau didier.loiseau at student.uclouvain.be
Sat Feb 2 18:15:56 CET 2008


Hi,

I am trying to post a propagator for the constraint
   x' = x or x' = epsilon
with x and x' integer variables and epsilon some constant not in dom(x).

I first thought to use reified equality constraints but it would achieve
very few propagation (for example, removing values from x would not
remove them from x' as long as epsilon is in dom(x'))

Then I thought I could do the same with the count constraint: posting
   #(X | x_i = y) = 1
with X = [x, epsilon] and y = x'

But the count propagator (for #(X | x_i = y) >= 1) does not seem to
achieve domain-consistency towards y in this case: values that are not
present in the union of the domains of the x_i's are not removed from y.

To test this I wrote this little program:

class TestCount : public Example {
protected:
  IntVar v, w, x;
public:
  TestCount(const Options& opt)
    : v(this, 1, 10), w(this, 2, 4), x(this, 7, 9) {
        IntVarArray tab(this, 2);
        tab[0] = w; tab[1] = x;
        exactly(this, tab, v, 1);
        branch(this, tab, INT_VAR_SIZE_MIN, INT_VAL_MIN);
  }

  // …
}

and I obtain solutions like v=[1..10] w=2 x=7. Shouldn't it propagate
v={2,7} ? Did I do something wrong ?

If what I am trying to do is not possible using count, what is the best
way to implement it, achieving domain consistency ?

Thank you in advance for your help.

Didier





More information about the gecode-users mailing list