Thanks to visit codestin.com
Credit goes to github.com

Skip to content

(At least) ExactSumConstraint doesn't handle negative numbers properly #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ltskinol opened this issue Aug 26, 2017 · 3 comments
Open

Comments

@ltskinol
Copy link

ltskinol commented Aug 26, 2017

myth1 python-constraint-master # python
Python 2.7.12 (default, Dec 17 2016, 17:32:09)
[GCC 4.9.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from constraint import *
>>> p = Problem()
>>> p.addVariable('a', [-1,0,1])
>>> p.addVariable('b', [-1,0,1])
>>> p.addConstraint(ExactSumConstraint(0), ['a', 'b'])
>>> print p.getSolutions()
[{'a': 0, 'b': 0}]
>>>

Shouldn't a==-1, b==1 and a==1, b==-1 also be solutions?

Thanks.

@s-celles
Copy link
Member

What is your opinion @niemeyer about this?

@agriffis
Copy link
Contributor

ExactSumConstraint implicitly assumes the inputs are non-negative and optimizes internally for that assumption. I didn't write it, but my guess is that finding exact sums from sets of non-negative numbers fits a certain problem domain, and this was intended for that.

It might be better to update the documentation for ExactSumConstraint than to change its behavior, and @ltskinol could write a separate constraint class for their problem domain.

@fjwillemsen
Copy link
Member

This seems like the ExactSumConstraint doesn't behave as can be expected from the name. I don't have the time to look into it, if someone else could that would be great.

@fjwillemsen fjwillemsen added the bug label Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants