[gecode-users] "nvalues" global constraint

Guido Tack tack at ps.uni-sb.de
Thu Jan 17 17:08:53 CET 2008


Jérémie Vautard wrote:
> Is there an implementation of the nvalues global constraint in
> Gecode ? (This constraint is used to specify the number of different
> values in an array of variables, and described in the Global
> constraint catalog here : http://www.emn.fr/x-info/sdemasse/gccat/
> sec5.186.html )

No, we don't have it yet.  You can emulate it using set constraints.  
Here's the pseudo code:

IntVarArgs x;
SetVar y;
IntVar n;
rel(home, SOT_UNION, x, y);
cardinality(home, y, n);

The variable n is now equal to the number of different values in x.   
If the number of values is fixed, you can of course use a constant  
cardinality for y instead.  This decomposition certainly doesn't  
achieve domain consistency, but it should work.

Cheers,
	Guido

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2436 bytes
Desc: not available
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20080117/799a36ba/attachment.bin>


More information about the gecode-users mailing list