Пример #1
0
 def test_not_equals_higher(self):
     equals = expr.exprvar("equals")
     cardinality = cardnet.equals(self.function.support,
                                  len(self.pos) + 1,
                                  ~equals)
     sat = expr.And(self.function, equals, *cardinality).to_cnf().satisfy_one()
     self.assertIsNotNone(sat)
     self.assertEqual(sat.get(equals), 1)
Пример #2
0
    def test_equals_is(self):
        cardinality = cardnet.equals(self.function.support,
                                     len(self.pos))
        sat = expr.And(self.function, *cardinality).to_cnf().satisfy_one()
        self.assertIsNotNone(sat)

        solution = {x: sat.get(x) for x in self.pos}
        self.assertEqual(solution, {x: 1 for x in self.pos})
Пример #3
0
    def test_equals_one_small(self):
        (a, _b, _c) = self.pos
        self.function = a

        cardinality = cardnet.equals(self.function.support, 1)
        sat = expr.And(self.function, *cardinality).to_cnf().satisfy_one()

        self.assertIsNotNone(sat)
        self.assertEqual(sat.get(a), 1)
Пример #4
0
 def test_equals_higher(self):
     cardinality = cardnet.equals(self.function.support,
                                  len(self.pos) + 1)
     sat = expr.And(self.function, *cardinality).to_cnf().satisfy_one()
     self.assertIsNone(sat)
Пример #5
0
 def test_equals_zero(self):
     cardinality = cardnet.equals(self.function.support, 0)
     sat = expr.And(self.function, *cardinality).to_cnf().satisfy_one()
     self.assertIsNone(sat)
Пример #6
0
def equals(inputs, p, equivalent=None):
    if p == 1: yield from equals_one(inputs, equivalent)
    else: yield from cardnet.equals(inputs, p, equivalent)