Skip to content

Commit

Permalink
some tests for lists in n
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimosts committed May 27, 2024
1 parent ee25234 commit 9eadddc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_globalconstraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ def test_alldifferent_except_n(self):
bv = cp.boolvar()
self.assertTrue(cp.Model([cp.AllDifferentExceptN([iv[0], bv],4)]).solve())

# test with list of n
iv = cp.intvar(0, 4, shape=7)
self.assertFalse(cp.Model([cp.AllDifferentExceptN([iv], [7,8])]).solve())
self.assertTrue(cp.Model([cp.AllDifferentExceptN([iv], [4, 1])]).solve())

def test_not_alldifferentexcept0(self):
iv = cp.intvar(-8, 8, shape=3)
self.assertTrue(cp.Model([~cp.AllDifferentExcept0(iv)]).solve())
Expand Down Expand Up @@ -959,6 +964,11 @@ def test_allEqualExceptn(self):
self.assertTrue(cp.Model([cp.AllEqualExceptN([a,b,False, a | b], 0)]).solve())
self.assertTrue(cp.Model([cp.AllEqualExceptN([a,b,False, a | b, y], -1)]).solve())

# test with list of n
iv = cp.intvar(0, 4, shape=7)
self.assertFalse(cp.Model([cp.AllEqualExceptN([iv], [7,8]), iv[0] != iv[1]]).solve())
self.assertTrue(cp.Model([cp.AllEqualExceptN([iv], [4, 1]), iv[0] != iv[1]]).solve())

def test_not_allEqualExceptn(self):
x = cp.intvar(lb=0, ub=3, shape=3)
n = 2
Expand Down

0 comments on commit 9eadddc

Please sign in to comment.