本文整理匯總了Python中dd.bdd.BDD.dump方法的典型用法代碼示例。如果您正苦於以下問題:Python BDD.dump方法的具體用法?Python BDD.dump怎麽用?Python BDD.dump使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dd.bdd.BDD
的用法示例。
在下文中一共展示了BDD.dump方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_bdd_to_mdd
# 需要導入模塊: from dd.bdd import BDD [as 別名]
# 或者: from dd.bdd.BDD import dump [as 別名]
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)
示例2: test_dump_load
# 需要導入模塊: from dd.bdd import BDD [as 別名]
# 或者: from dd.bdd.BDD import dump [as 別名]
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()