Skip to content
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

ac3 in csp.py #256

Closed
onursurme opened this issue Sep 2, 2016 · 3 comments
Closed

ac3 in csp.py #256

onursurme opened this issue Sep 2, 2016 · 3 comments

Comments

@onursurme
Copy link

at line 171 in csp.py, in the function AC3, it is written as :
if Xk != Xi:

there is no need to exclude Xi because Xi already can't be a neighbour to itself.
but I guess it should be
if Xk != Xj:
because Xi is already revised with Xj, so there is no need to add Xi, Xj to the queue again.

we can also see this in the book at Figure6.3 as :
for each Xk in Xi.NEIGHBORS - {Xj} do
here again, Xj is excluded.

@darius
Copy link
Collaborator

darius commented Sep 2, 2016

You appear to be right -- thank you!

We're also missing a test that would provoke this bug. Would you like to make a pull request with a new test case, or should I?

@onursurme
Copy link
Author

I'll try to create a test. I'll inform you about the result.

Sent from Yahoo Mail on Android

On Fri, 2 Sep, 2016 at 6:14, Darius Baconnotifications@github.com wrote:
You appear to be right -- thank you!

We're also missing a test that would provoke this bug. Would you like to make a pull request with a new test case, or should I?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@onursurme
Copy link
Author

Here is a test case which I think reveals the bug :

from csp import *

def t1f(A,a,B,b):
    return int(a)>int(b)

test1=CSP(["a","b"],{"a":["2","4"],"b":["3","5"]},{"a":"b","b":"a"},t1f)
AC3(test1)
print(test1.infer_assignment())

a must be bigger than b, so b can't be 5, and a must be 4.
when I run this test with the wrong version of AC3 (if Xk != Xi: version), the test says b=5, which is wrong.
but when I run the test with the right version of AC3 (if Xk != Xj: version), the test says a=4, which is true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants