[gecode-users] question about counting constraint

Guido Tack tack at ps.uni-sb.de
Sun Nov 29 15:39:52 CET 2009


Hi Alberto,

that was a bug in the global count posting functions.  The values array (and thus the corresponding array of occurrence variables) had to be sorted.  I fixed this in the trunk to accept unsorted arrays, and it will be part of the upcoming 3.2.2 release.

Cheers,
	Guido

Alberto Delgado wrote:

> Hi all,
> 
> Let's say i have an IntVarArray vars,  an integer value b and an
> IntVar car.  According to the documentation,  if i post the
> constraint: count(*this,vars,b,IRT_EQ,car),  the variable car will
> represent the number of occurrences of b in vars.
> 
> Now,  instead of b being an integer value let's assume it's an IntArgs
> with all the elements of the domain of variables from vars, and that
> car is now an IntVarArray that will represent the number of
> occurrences of all values from b in vars.  I wanted to constrain the
> occurrences of each value from b in vars according to car,  so i
> implemented a for loop and posted a count constraint for each value in
> b and variable in car:  count(*this,vars,b[i],IRT_EQ,car[i]).
> 
> Then I realized that it is possible to use just one count constraint:
> count(*this,vars,car,b),  that should be equivalent to posting a count
> constraint for each value in b.
> 
> Attached to this email there is an example that reflects what i
> described above. When i run the example with line 64 uncommented and
> line 67 commented,  this is using a loop to post a count constraint
> for each value in b,  the solver finds a solution without failing at
> all. If i comment line 64 and uncomment line 67,  posting just one
> count constraint,  the solver fails right away.
> 
> Did i get wrong the definition of count(*this,vars,car,b) and it is
> not equivalent to post a constraint for each value in b?
> 
> Thanks in advance,
> 
> Alberto
> <test.cc>_______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users




More information about the users mailing list