[gecode-users] modelling question
Denys Duchier
denys.duchier at univ-orleans.fr
Fri Nov 28 12:05:55 CET 2008
Patrik Haslum <patrik.haslum at anu.edu.au> writes:
> I have a finite set variable X, with domain {0..N-1} (though I could
> replace it by an array of booleans if that turns out to be more
> convenient). Every element i in the domain of X has a certain weight,
> w(i) (which is in the range 0..K; K is typically small). I want to post
> the constraint
>
> Y = min_{i in X} w(i) if X is non-empty
> 0 if X is empty.
For example, you could do it this way:
X' = X U {N}
S = U<{w(0)},{w(1)},...,{w(N-1)},{K+1}>[X'] (elementsUnion)
Y' = min(S)
Y = <0,Y'>[Y'<(K+1)] (element)
Cheers,
--Denys
More information about the gecode-users
mailing list