Ejemplo n.º 1
0
 def testSimple(self):
     self.assertEqual(bdd.variable('x'),
                      bdd.Node('x', bdd.Node.T, bdd.Node.F))
     self.assertEqual(bdd.notVariable('x'),
                      bdd.Node('x', bdd.Node.F, bdd.Node.T))
     self.assertEqual(bdd.conjunction([]), bdd.Node.T)
     self.assertEqual(bdd.conjunction(['x']), bdd.variable('x'))
     self.assertEqual(bdd.conjunction(['x', 'y']),
                      bdd.Node('x', bdd.variable('y'), bdd.Node.F))
     self.assertEqual(
         bdd.conjunction(['x', 'y', 'z']),
         bdd.Node(
             'x',
             bdd.Node('y', bdd.Node('z', bdd.Node.T, bdd.Node.F),
                      bdd.Node.F), bdd.Node.F))
     self.assertEqual(bdd.disjunction([]), bdd.Node.F)
     self.assertEqual(bdd.disjunction(['x']), bdd.variable('x'))
     self.assertEqual(bdd.disjunction(['x', 'y']),
                      bdd.Node('x', bdd.Node.T, bdd.variable('y')))
     self.assertEqual(
         bdd.disjunction(['x', 'y', 'z']),
         bdd.Node(
             'x', bdd.Node.T,
             bdd.Node('y', bdd.Node.T, bdd.Node('z', bdd.Node.T,
                                                bdd.Node.F))))
Ejemplo n.º 2
0
 def testApply(self):
     v1 = bdd.variable('v1')
     v2 = bdd.variable('v2')
     v1dv2 = bdd.disjunction(['v1', 'v2'])
     v1av2 = bdd.simplify(
         bdd.apply(v1, v2, bdd.orOperation,
                   bdd.enumeratedVariablesOrdering(['v1', 'v2'])))
     self.assertEqual(v1dv2, v1av2)
Ejemplo n.º 3
0
 def testOrderings(self):
     self.__allOrderings(bdd.leftistOrdering)
     self.assertTrue(bdd.leftistOrdering(None,None))
     self.__allOrderings(bdd.rightistOrdering)
     self.assertFalse(bdd.rightistOrdering(None,None))
     v1=bdd.enumeratedVariablesOrdering(['x1','x2','x3','x4'])
     self.__allOrderings(v1)
     self.assertTrue(v1(bdd.variable('x2'),bdd.variable('x4')))
     self.assertFalse(v1(bdd.variable('x3'),bdd.variable('x2')))
Ejemplo n.º 4
0
 def testOrderings(self):
     self.__allOrderings(bdd.leftistOrdering)
     self.assertTrue(bdd.leftistOrdering(None, None))
     self.__allOrderings(bdd.rightistOrdering)
     self.assertFalse(bdd.rightistOrdering(None, None))
     v1 = bdd.enumeratedVariablesOrdering(['x1', 'x2', 'x3', 'x4'])
     self.__allOrderings(v1)
     self.assertTrue(v1(bdd.variable('x2'), bdd.variable('x4')))
     self.assertFalse(v1(bdd.variable('x3'), bdd.variable('x2')))
Ejemplo n.º 5
0
 def testSimple(self):
     self.assertEqual(bdd.variable('x'),bdd.Node('x',bdd.Node.T,bdd.Node.F))
     self.assertEqual(bdd.notVariable('x'),bdd.Node('x',bdd.Node.F,bdd.Node.T))
     self.assertEqual(bdd.conjunction([]),bdd.Node.T)
     self.assertEqual(bdd.conjunction(['x']),bdd.variable('x'))
     self.assertEqual(bdd.conjunction(['x','y']),bdd.Node('x',bdd.variable('y'),bdd.Node.F))
     self.assertEqual(bdd.conjunction(['x','y','z']),bdd.Node('x',bdd.Node('y',bdd.Node('z',bdd.Node.T,bdd.Node.F),bdd.Node.F),bdd.Node.F))
     self.assertEqual(bdd.disjunction([]),bdd.Node.F)
     self.assertEqual(bdd.disjunction(['x']),bdd.variable('x'))
     self.assertEqual(bdd.disjunction(['x','y']),bdd.Node('x',bdd.Node.T,bdd.variable('y')))
     self.assertEqual(bdd.disjunction(['x','y','z']),bdd.Node('x',bdd.Node.T,bdd.Node('y',bdd.Node.T,bdd.Node('z',bdd.Node.T,bdd.Node.F))))
Ejemplo n.º 6
0
 def testApply(self):
     v1=bdd.variable('v1')
     v2=bdd.variable('v2')
     v1dv2=bdd.disjunction(['v1','v2'])
     v1av2=bdd.simplify(bdd.apply(v1,v2,bdd.orOperation,bdd.enumeratedVariablesOrdering(['v1','v2'])))
     self.assertEqual(v1dv2,v1av2)