FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

modify AC3 algorithm by nvinayvarma189 · Pull Request #717 · aimacode/aima-python · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion csp.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def AC3(csp, queue=None, removals=None):
if not csp.curr_domains[Xi]:
return False
for Xk in csp.neighbors[Xi]:
if Xk != Xi:
if Xk != Xj:
queue.append((Xk, Xi))
return True

Expand Down
7 changes: 7 additions & 0 deletions tests/test_csp.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ def test_AC3():
assert AC3(csp, removals=removals) is True
assert (removals == [('A', 1), ('A', 3), ('B', 1), ('B', 3)] or
removals == [('B', 1), ('B', 3), ('A', 1), ('A', 3)])

domains = {'A': [ 2, 4], 'B': [ 3, 5]}
constraints = lambda X, x, Y, y: int(x) > int (y)
removals=[]
csp = CSP(variables=None, domains=domains, neighbors=neighbors, constraints=constraints)

assert AC3(csp, removals=removals)


def test_first_unassigned_variable():
Expand Down

Back | FazBrowse Home | New Git URL