本文整理匯總了Python中dd.bdd.BDD.compose方法的典型用法代碼示例。如果您正苦於以下問題:Python BDD.compose方法的具體用法?Python BDD.compose怎麽用?Python BDD.compose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dd.bdd.BDD
的用法示例。
在下文中一共展示了BDD.compose方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_compose
# 需要導入模塊: from dd.bdd import BDD [as 別名]
# 或者: from dd.bdd.BDD import compose [as 別名]
def test_compose():
ordering = {'x': 0, 'y': 1, 'z': 2}
g = BDD(ordering)
# x & (x | z)
a = g.add_expr('x && y')
b = g.add_expr('x || z')
c = g.compose(a, 'y', b)
d = g.add_expr('x && (x || z)')
assert c == d, (c, d)
# (y | z) & x
ordering = {'x': 0, 'y': 1, 'z': 2, 'w': 3}
g = BDD(ordering)
a = g.add_expr('(x && y) || z')
b = g.add_expr('(y || z) && x')
c = g.compose(a, 'z', b)
assert c == b, (c, b)
# long expr
ordering = {'x': 0, 'y': 1, 'z': 2, 'w': 3}
g = BDD(ordering)
a = g.add_expr('(x && y) || (!z || (w && y && x))')
b = g.add_expr('(y || z) && x')
c = g.compose(a, 'y', b)
d = g.add_expr(
'(x && ((y || z) && x)) ||'
' (!z || (w && ((y || z) && x) && x))')
assert c == d, (c, d)
# complemented edges
ordering = {'x': 0, 'y': 1}
g = BDD(ordering)
f = g.add_expr('x <-> y')
var = 'y'
new_level = 0
var_node = g.find_or_add(new_level, -1, 1)
u = g.compose(f, var, var_node)
assert u == 1, g.to_expr(u)