本文整理汇总了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()