def test_dump_load(): prefix = 'test_dump_load' g = BDD({'x': 0, 'y': 1}) e = 'x & !y' u = g.add_expr(e) g.incref(u) fname = prefix + '.p' g.dump(fname) h = BDD.load(fname) assert h.assert_consistent() u_ = h.add_expr(e) assert u == u_, (u, u_) h.dump(prefix + '.pdf')
def test_bdd_to_mdd(): from dd.bdd import BDD ordering = {'x': 0, 'y': 1} bdd = BDD(ordering) u = bdd.add_expr('x & ! y') bdd.incref(u) # BDD -> MDD dvars = dict(x=dict(level=1, len=2, bitnames=['x']), y=dict(level=0, len=2, bitnames=['y'])) mdd, umap = dd.mdd.bdd_to_mdd(bdd, dvars) pd = dd.mdd.to_pydot(mdd) pd.write_pdf('mdd.pdf') bdd.dump('bdd.pdf') v = umap[abs(u)] if u < 0: v = -v print(v)
def test_bdd_to_mdd(): from dd.bdd import BDD ordering = {'x': 0, 'y': 1} bdd = BDD(ordering) u = bdd.add_expr('x & ! y') bdd.incref(u) # BDD -> MDD dvars = dict( x=dict(level=1, len=2, bitnames=['x']), y=dict(level=0, len=2, bitnames=['y'])) mdd, umap = dd.mdd.bdd_to_mdd(bdd, dvars) pd = dd.mdd.to_pydot(mdd) pd.write_pdf('mdd.pdf') bdd.dump('bdd.pdf') v = umap[abs(u)] if u < 0: v = -v print(v)
def test_dump_load(): prefix = 'test_dump_load' fname = prefix + '.p' dvars = dict(x=0, y=1) # dump b = BDD(dvars) e = 'x & !y' u_dumped = b.add_expr(e) b.dump(fname, [u_dumped]) b.dump(fname) # no roots # load b = BDD(dvars) b.add_expr('x | y') u_new = b.add_expr(e) umap = b.load(fname) u_loaded = umap[abs(u_dumped)] if u_dumped < 0: u_loaded = -u_loaded assert u_loaded == u_new, (u_dumped, u_loaded, u_new, umap) assert b.assert_consistent()
def test_dump_load(): prefix = 'test_dump_load' fname = prefix + '.p' dvars = dict(x=0, y=1) # dump b = BDD(dvars) e = 'x & !y' u_dumped = b.add_expr(e) b.dump(fname, [u_dumped]) b.dump(fname) # no roots # load b = BDD(dvars) b.add_expr('x | y') u_new = b.add_expr(e) umap = b.load(fname) u_loaded = umap[abs(u_dumped)] if u_dumped < 0: u_loaded = -u_loaded assert u_loaded == u_new, ( u_dumped, u_loaded, u_new, umap) assert b.assert_consistent()