在为Haskell运行Data.SBV库中的优化函数示例时:
problem :: Goal
problem = optimize Lexicographic $ do [x1, x2] <- mapM sReal ["x1", "x2"]
constrain $ x1 + x2 .<= 10
constrain $ x1 - x2 .>= 3
constrain $ 5*x1 + 4*x2 .<= 35
constrain $ x1 .>= 0
constrain $ x2 .>= 0
maximize "goal" $ 5 * x1 + 6 * x2
main = optimize Lexicographic problem我得到以下错误:
*** Exception:
*** Data.SBV: Unexpected response from the solver.
*** Context : set-option
*** Sent : (set-option :pp.decimal false)
*** Expected: success
*** Received: unsupported
*** success
CallStack (from HasCallStack):
error, called at ./Data/SBV/Control/Utils.hs:590:9 in sbv-7.3-35rX062AGHeFmuyHxSBaTE:Data.SBV.Control.Utils同样,以下代码:
test = optimize Lexicographic $ do
x <- sInteger "x"
y <- sInteger "y"
maximize "goal" $ x + 2 * y产生错误:
*** Exception:
*** Data.SBV: Unexpected response from the solver.
*** Context : getModel
*** Sent : (get-value (s0))
*** Expected: a value binding for kind: SInteger
*** Received: unsupported
*** ((s0 0))
CallStack (from HasCallStack):
error, called at ./Data/SBV/Control/Utils.hs:590:9 in sbv-7.3-35rX062AGHeFmuyHxSBaTE:Data.SBV.Control.Utils使用minimize组合器作为最后一个表达式也会发生此错误。
我使用GHC版本8.0.2和堆栈版本1.5和SBV版本7.3,我使用Z3作为我的解决程序,它是在MacOS上运行的4.5.1 64位版本。
调用sat和prove按预期工作。有什么想法吗?谢谢!
发布于 2017-09-20 04:09:07
您最有可能使用的是旧版本的Z3。SBV中的优化特性依赖于一些尚未正式发布的Z3特性。你能从这里下载一个吗?
https://github.com/Z3Prover/bin/tree/master/nightly
试一试?
(对于Z3来说,有一张新的发行版就是为了解决这个问题而开的票,但还不清楚他们什么时候才能解决这个问题:https://github.com/Z3Prover/z3/issues/1231)
https://stackoverflow.com/questions/46312808
复制相似问题