Z3 JAVA-API for solver timeout

馋奶兔 提交于 2019-12-11 08:58:59

问题


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?


回答1:


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);



回答2:


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);


来源:https://stackoverflow.com/questions/15513944/z3-java-api-for-solver-timeout

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