timeout for z3 solver in python

人盡茶涼 提交于 2019-12-11 10:37:21

问题


I have problems setting a timeout for my solver:

s = Solver()
encoding = parse_smt2_file("ex.smt2")
s.add(encoding)

s.set("timeout", 600)
solution = s.check()

but I get the following error

Traceback (most recent call last): 
File "/Users/X/Documents/encode.py", line 145, in parse_polyedra("file") 
File "/Users/X/Documents/encode.py", line 108, in parse_polyedra s.set("timeout",1) File "/Users/X/z3/build/z3.py", line 5765, in set Z3_solver_set_params(self.ctx.ref(), self.solver, p.params) 
File "/Users/X/z3/build/z3core.py", line 3969, in Z3_solver_set_params raise Z3Exception(lib().Z3_get_error_msg_ex(a0, err)) 
Z3Exception: unknown parameter 'timeout'

A list of legal parameters appears, but timeout is not part of it. I took a look to this post, but the problem is not the same. As far as I understand, the parameter should be accepted, it is just that in the stable version the timeout may never happens, but there should not be problems to compile.

Anyway I installed the unstable branch and the problem persist.


回答1:


I was able to use the timeout option (and it actually timeouts, and returns the best known solution in the case of optimization) with the following versions:

Python 2.7.9 (default, Mar  1 2015, 12:57:24) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import z3
>>> s = z3.Solver()
>>> s.set("timeout", 600)
>>> z3.get_version_string()
'4.4.2'


来源:https://stackoverflow.com/questions/28338327/timeout-for-z3-solver-in-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!