Originally posted by: SystemAdmin
Hello,
The formulation I gave is correct, it just computes for each value a boolean expression saying whether or not this value is taken by at least one variable. And then it sums up these boolean expressions.
On your example:
x0 = 1; x1 = 1; x2 = 2; x3 = 3; Values =
{1, 2, 3
} x = [x0,x1,x2,x3]
With first formulation:
v count(x,v) (0<count(x,v)); 1 2 1 2 1 1 3 1 1 ------------------------------------ y=3
With second formulation:
v (x0==v) (x1==v) (x2==v) (x3==v) (or(i in 0..3) xi==v) 1 1 1 0 0 1 2 0 0 1 0 1 3 0 0 0 1 1 ---------------------------------------------------------------- y=3
#CPOptimizer#DecisionOptimization