Hernan Ponce de Leon
Hernan Ponce de Leon

Reputation: 91

timeout for z3 solver in python

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.

Upvotes: 1

Views: 4186

Answers (1)

Emilien
Emilien

Reputation: 2455

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'

Upvotes: 2

Related Questions