Z3 JAVA-API for solver timeout

2019-08-02 03:38发布

How to set solver's timeout for Z3 JAVA API?

Back to this question again:

Here is my code:

    Context ctx = getZ3Context();
    solver = ctx.MkSolver();
    Params p = ctx.MkParams();
    p.Add("timeout", 1);
    solver.setParameters(p);

Not work, the solver just running the query forever. Any idea about this?

2条回答
爷、活的狠高调
2楼-- · 2019-08-02 04:05

Okay, finally found a solution myself:

Context ctx = getZ3Context();
solver = ctx.MkSolver();
Params p = ctx.MkParams();
/* Also tried
 * p.Add("timeout", 1),
 * p.Add(":timeout", 1), 
 * neither worked.
 */
p.Add("soft_timeout", 1);
solver.setParameters(p);
查看更多
该账号已被封号
3楼-- · 2019-08-02 04:07

I haven't used the Java API, but from Looking at the official Java example and at this snippet, I'd assume that something along the following lines should work:

Solver s = ctx.MkSolver();
Params p = ctx.MkParams();
p.Add("timeout", valueInMilliseconds); /* "SOFT_TIMEOUT" or ":timeout"? */
s.setParameters(p);
查看更多
登录 后发表回答