Permalink
Browse files

Fixed the complex test for ac3

  • Loading branch information...
1 parent b117224 commit 906720dacc170964ea2c0b45718ae6cd6221d86f @fisadev fisadev committed Nov 24, 2013
Showing with 10 additions and 13 deletions.
  1. +10 −13 tests/search/test_arc_concistency.py
@@ -77,20 +77,20 @@ def test_if_variable_has_no_domain_left_returns_false(self):
self.assertFalse(result)
def test_chained_revise_calls_remove_non_obvious_problems(self):
- # if A, B, C must be all different, with domains [1], [2], [2] you
+ # if A, B, C must be all different, with domains [1, 1], [1, 2], [2, 2] you
# can't find a solution, but it requires several chained calls to
# revise:
- # revise(A, B) -> ok! [1] [2] [2]
- # revise(A, C) -> ok! [1] [2] [2]
- # revise(B, C) -> fail, remove 2 from B [1] [] [2]
- # and re-revise A, B ...
- # revise(A, B) -> fail, remove 1 from A [] [] [2]
+ # revise(A, B) -> ok! [1, 1] [1, 2] [2, 2]
+ # revise(A, C) -> ok! [1, 1] [1, 2] [2, 2]
+ # revise(B, C) -> fail, remove 2 from B [1, 1] [1] [2, 2]
+ # and re-revise A, B and C, B
+ # revise(A, B) -> fail, remove 1 from A [] [1] [2, 2]
# and re-revise ...
- # at the end, there are no possible values in any domain [] [] []
+ # here A has no more values, ac3 returns a failure
- domains = {'A': [1,],
- 'B': [2,],
- 'C': [2,]}
+ domains = {'A': [1, 1],
+ 'B': [1, 2],
+ 'C': [2, 2]}
different = lambda variables, values: len(set(values)) == len(variables)
constraints = [(('A', 'B'), different),
(('A', 'C'), different),
@@ -99,6 +99,3 @@ def test_chained_revise_calls_remove_non_obvious_problems(self):
result = arc_consistency_3(domains, constraints)
self.assertFalse(result)
- self.assertEquals(domains['A'], [])
- self.assertEquals(domains['B'], [])
- self.assertEquals(domains['C'], [])

0 comments on commit 906720d

Please sign in to comment.