[gecode-users] semantics for count(Home home, const IntVarArgs &x, IntVar y, IntRelType r, IntVar z)

Christian Schulte cschulte at kth.se
Tue Nov 22 09:49:31 CET 2011


This is a fundamental missunderstanding of what an integer set and an
integer variable denotes. 

It might be that the current domain of an integer variable is a set, however
the variable denotes a single integer (which you do not know yet). That's
fundamental and very different from a set.

With that in mind, count behaves exactly like one would expect.

In your example, the constraint does not succeed (as in being entailed). It
just does not fail yet. Let's take the more general example (2 is replaced
by an integer variable Z):

Y :: [3,4], count([3,0,3,3,4], Y, =, Z)

Then it will propagate that Z has the domain [0..4] as there are four
elements in the array that still could be equal to Y with domain 3 or 4 and
one is already known to be different (the element 0) from 3 or 4.

Christian

--
Christian Schulte, www.ict.kth.se/~cschulte/


-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Kish Shen
Sent: Tuesday, November 22, 2011 8:09 AM
To: users at gecode.org
Subject: [gecode-users] semantics for count(Home home, const IntVarArgs &x,
IntVar y, IntRelType r, IntVar z)

Hi,

I have been looking at the behaviour of

count(Home home, const IntVarArgs &x, IntVar y, IntRelType r, IntVar z)

and cannot understand what is happening when IntVar y has more than one
value in its domain. Until now, I have only tested this constraint with y
having a singleton value in its domain, and in this case, the constraint
behaves the same as the case where y is Int, i.e. the number of occurrences
of the value y in x is counted.

However, one of my user wanted to use the constraint where y has multiple
values (i.e. the counts constraint in the global constraint catalog). I know
this constraint is provided with y being an IntSet, but my user did not know
about this constraint, so he used the version where y is a IntVar instead.

I had expected that mulitple domain values in y would behave like multiple
values in the IntSet for this constraint, but this does not seem to be the
case. For example, the constraint succeeds with the following (in ECLiPSe
syntax, but the argument order of Gecode's
constraint):

Y :: [3,4], count([3,0,3,3,4], Y, =, 2)

where [3,0,3,3,4] is x, IntRelType is IRT_EQ.

I don't understand why this succeeds -- the count for 3 is 3, and for 4 is
1, and for both 3 and 4 is 4, none of which is equal to 2. So what is the
semantics?

The equivalent call using y as an IntSet [3,4] fails as expected. Also, for
the same count constraint, if y has a single domain value (e.g. 3 or 4),
then the constraint behave as I expected, i.e. z = 3 for y = 3, and z = 1
for y = 1.

Thanks and cheers,

Kish


--
This e-mail may contain confidential and privileged material for the sole
use of the intended recipient. Any review, use, distribution or disclosure
by others is strictly prohibited. If you are not the intended recipient (or
authorized to receive for the recipient), please contact the sender by reply
e-mail and delete all copies of this message.
Cisco Systems Limited (Company Number: 02558939), is registered in England
and Wales with its registered office at 1 Callaghan Square, Cardiff, South
Glamorgan CF10 5BT.

_______________________________________________
Gecode users mailing list
users at gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users




More information about the users mailing list