This question is about the python package constraint (see http://labix.org/python-constraint), in particular the built-in "AllEqualConstraint". In a problem involving 4 variables, I would like to enforce the first two and the second two to be equal, i.e.:
p = Problem()
p.addVariables([1,2,3,4], [0,1])
p.addConstraint(AllEqualConstraint(), [1,2])
p.addConstraint(AllEqualConstraint(), [3,4])
I only get two solutions:
for sol in p.getSolutions():
print sol
> {1: 1, 2: 1, 3: 1, 4: 1}
> {1: 0, 2: 0, 3: 0, 4: 0}
where I would expect to see four, namely:
> {1: 1, 2: 1, 3: 1, 4: 1}
> {1: 1, 2: 1, 3: 0, 4: 0}
> {1: 0, 2: 0, 3: 1, 4: 1}
> {1: 0, 2: 0, 3: 0, 4: 0}
My question is: Can anyone confirm that this is what the package intends to compute and what the reasoning behind it is?
Ps: I have contacted the authors of this package, but got no reply yet. I know that this package is fairly well known and that there have been questions about it on StackOverflow before.
In answer to LVC: The constraint does not always apply the constraint to all variables:
p = Problem()
p.addVariables([1,2,3], [0,1])
p.addConstraint(AllEqualConstraint(), [1,2])
gives
> {1: 1, 2: 1, 3: 1}
> {1: 1, 2: 1, 3: 0}
> {1: 0, 2: 0, 3: 1}
> {1: 0, 2: 0, 3: 0}
as expected. If the AllEqualConstraint
didn't respect variables, it would be very limited.