[gecode-users] Counting booleans

Mikael Zayenz Lagerkvist zayenz at gmail.com
Thu Feb 14 07:45:15 CET 2008


Hi,

On Thu, Feb 14, 2008 at 7:01 AM, Malcolm Ryan <malcolmr at cse.unsw.edu.au> wrote:
> In answer to my own question, BoolVar extends IntVar, so the standard
>  Gecode.count() methods will work.

Counting BoolVars is slightly overkill, since linear relations work
equally well.

Also, from Gecode 2.0 BoolVars are no longer IntVars, and there are no
counting constraints for the new BoolVars (again since that is
captured by linear relations).

>  On 14/02/2008, at 4:55 PM, Malcolm Ryan wrote:
>  > Another question: I have two lists of variables X1 ... Xn and Y1 ...
>  > Yn. I want to constrain them so that at most one (or exactly one) of
>  > the Xi's differs from the corresponding Yi.
>  >
>  > This is one of those things that would propagate better with a
>  > specialised constraint. Does such a constraint exist (in Gecode/J)?

The closest constraint available is a count constraint that counts the
number of x_i=y_i that holds for a variable array x and array of
constants y.

If both of the arrays are variables, you will have to use the reified
version that you described.

Cheers,
Mikael

-- 
Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/




More information about the gecode-users mailing list