简体   繁体   English

使用 z3py 的全局参数

[英]Using global parameters of z3py

I'm trying to use SMT solver over a scheduling problem and could not find anything helping in the documentation.我正在尝试使用 SMT 求解器解决调度问题,但在文档中找不到任何帮助。

It seems using following ways of setting parameters do not have any effect on the solver.似乎使用以下设置参数的方式对求解器没有任何影响。

from z3 import *

set_param(logic="QF_UFIDL")
s = Optimize() # or even Solver()

or even甚至

from z3 import *

s = Optimize()
s.set("parallel.enable", True)

So how can I set [global] parameters effectively in z3py.那么如何在 z3py 中有效地设置 [global] 参数。 to be most specific I need to set parameters below:最具体地说,我需要在下面设置参数:

  1. parallel.enable=True parallel.enable=真
  2. auto_confic=False auto_confic=假
  3. smtlib2_compliant=True smtlib2_compliant=真
  4. logic="QF_UFIDL"逻辑=“QF_UFIDL”

Use global parameter statements like the following on separate lines before creating Solver or Optimize object:在创建SolverOptimize object 之前,在单独的行中使用如下全局参数语句:

set_param('parallel.enable', True)
set_param('parallel.threads.max', 4)   #  default 10000

To set non-global parameters specific to a Solver or Optimize object, you can use the help() function to show available parameters:要设置特定于SolverOptimize器的非全局参数 object,您可以使用help() function 来显示可用参数:

o = Optimize()
o.help()

s = Solver()
s.help()

The following example shows how to set an Optimize parameter:以下示例显示如何设置Optimize参数:

opt = Optimize()
opt.set(priority='pareto')

Use set_param , as described here: https://z3prover.github.io/api/html/namespacez3py.html#a4ae524d5f91ad1b380d8821de01cd7c3使用set_param ,如下所述: https://z3prover.github.io/api/html/namespacez3py.html#a4ae524d5f91ad1b380d8821de01cd7c3

It isn't clear what's not working for you.目前尚不清楚什么对您不起作用。 Are you getting an error message back?你收到错误信息了吗? From your description, I understand that the setting does indeed take place, but you don't see any change in behavior?根据您的描述,我了解到设置确实发生了,但是您看不到任何行为变化吗? For that, you'll have to provide a concrete example we can look at.为此,您必须提供一个我们可以查看的具体示例。 Note that for most parameters, the effects will only be visible with benchmarks that trigger the option, and even then it'll be hard to tell what (if any) effect it had, unless you dig into verbose log output.请注意,对于大多数参数,效果只会在触发该选项的基准测试中可见,即使那样也很难说出它有什么(如果有的话)效果,除非您深入研究详细的日志 output。

Also, parallel-solving features, which you seem to be interested in, isn't going to gain you much.此外,您似乎感兴趣的并行求解功能不会给您带来太多好处。 See Section 9.2 of https://z3prover.github.io/papers/z3internals.html : Essentially it boils down to attempting to solve the same problem with different seeds to see if one of them goes faster.请参阅https://z3prover.github.io/papers/z3internals.html的第 9.2 节:本质上,它归结为尝试用不同的种子解决相同的问题,看看其中一个是否运行得更快。 If you have many cores lying around it might be worth a try, but don't expect magic out of it.如果你周围有很多核心,它可能值得一试,但不要指望它会产生魔力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM