计算表示为 ROBDD 数组的函数的集合图像
我有一组整数,表示为 降序二元决策图 (ROBDD )(当且仅当输入在集合中时,被解释为一个计算结果为 true 的函数),我将其称为 Domain,以及一个整数函数(我将其称为 F),表示为 ROBDD 数组(ROBDD 的每一位都有一个条目) 结果)。
现在我想计算 F 的域图像。这绝对是可能的,因为它可以通过枚举域中的所有项目、应用 F 并将结果插入图像中来简单地完成。但这是一个可怕的算法,具有指数复杂性(与域的大小呈线性关系),而且我的直觉告诉我它可以更快。我一直在研究以下方向:
- 将 Restrict(Domain) 应用于 F 的所有位,
- 发挥魔法
但第二步被证明很困难。第一步的结果包含我需要的信息(至少我有 90% 的把握),但形式不正确。是否有一种有效的算法将其变成“编码为 ROBDD 的集合”?我需要其他方法吗?
I have a set of integers, represented as a Reduced Ordered Binary Decision Diagram (ROBDD) (interpreted as a function which evaluates to true iff the input is in the set) which I shall call Domain, and an integer function (which I shall call F) represented as an array of ROBDD's (one entry per bit of the result).
Now I want to calculate the image of the domain for F. It's definitely possible, because it could trivially be done by enumerating all items from the domain, apply F, and insert the result in the image. But that's a horrible algorithm with exponential complexity (linear in the size of the domain), and my gut tells me it can be faster. I've been looking into the direction of:
- apply Restrict(Domain) to all bits of F
- do magic
But the second step proved difficult. The result of the first step contains the information I need (at least, I'm 90% sure of it), but not in the right form. Is there an efficient algorithm to turn it into a "set encoded as ROBDD"? Do I need an other approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
定义两个集值函数:
然后,当序列为空时,我们就有了完整的问题:
从完整的域中,我们可以定义两个子集:
可以递归地应用此过程来为每个序列生成 D。
然后我们可以确定完整序列的 N(x):
可以从两个子节点生成父节点,直到生成 N()。
如果在任何时候我们确定 D(d1...dm) 为空,那么我们就知道
N(d1...dm) 也是空的,我们可以避免处理该分支。
这是主要的优化。
以下代码(Python)概述了该过程:
Define two set-valued functions:
Then when the sequences are empty, we have our full problem:
From the full domain we can define two subsets:
This process can be applied recursively to generate D for every sequence.
We can then determine N(x) for the full sequences:
The parent nodes can be produced from the two children, until we've produced N().
If at any point we determine that D(d1...dm) is empty, then we know
that N(d1...dm) is also empty, and we can avoid processing that branch.
This is the main optimization.
The following code (in Python) outlines the process:
令 S(x1, x2, x3...xn) 为集合 S 的指示函数,因此如果 (x1, x2,...xn) 是一个元素,则 S(x1, x2...xn) = true设 F1(x1, x2, x3...xn), F2(),... Fn() 是定义 F 的各个函数。然后我可以询问带有通配符的特定位模式是否是在 F 的图像中,通过形成方程,例如S() & F1() & ~F2() 用于位模式 10,然后求解这个方程,我认为我可以这样做,因为它是一个 ROBDD。
当然,您需要一个通用指示函数,它告诉我 abc 是否在图像中。扩展上述内容,我想你会得到 S() & (a&F1() | ~a&~F1()) & (b&F2() | ~b&~F2()) &... 如果您随后对变量重新排序,使得原始 x1, x2, ... xn 出现在 ROBDD 顺序的最后,那么您应该能够修剪树以在 x1、x2、...xn 的任何设置导致值 true 的情况下返回 true,否则返回 false。
(当然,您可能会因为空间不足或耐心等待重新排序而起作用)。
Let S(x1, x2, x3...xn) be the indicator function for the set S, so that S(x1, x2...xn) = true if (x1, x2,...xn) is an element of S. Let F1(x1, x2, x3... xn), F2(),... Fn() be the individual functions that define F. Then I could ask if a particular bit pattern, with wild cards, is in the image of F by forming the equation e.g. S() & F1() & ~F2() for bit-pattern 10 and then solving this equation, which I presume that I can do since it is an ROBDD.
Of course you want a general indicator function, which tells me if abc is in the image. Extending the above, I think you get S() & (a&F1() | ~a&~F1()) & (b&F2() | ~b&~F2()) &... If you then re-order the variables so that the original x1, x2, ... xn occur last in the ROBDD order, then you should be able to prune the tree to return true for the case where any setting of the x1, x2, ... xn leads to the value true, and to return false otherwise.
(of course you could run of space, or patience, waiting for the re-ordering to work).