[英]Size of constraints in the Z3 Solver()
Is there a way for us to get how many constraints were added into the solver?有没有办法让我们获得在求解器中添加了多少约束? For example, we initialize a z3 solver
s = Solver()
and then adding constraints to it using s.add()
.例如,我们初始化一个 z3 求解器
s = Solver()
,然后使用s.add()
添加约束。 How can we get the number of constraints which were finally added to the solver?我们如何获得最终添加到求解器中的约束数量?
You can use the assertions
method:您可以使用
assertions
方法:
from z3 import *
s = Solver()
i = Int('i')
s.add (i > 1)
s.add (i < 12)
print s.assertions()
print len(s.assertions())
This prints:这打印:
[i > 1, i < 12]
2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.