为Haskell运行example for the optimize function in the Data.SBV library时:
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
组合子作为最后一个表达式也会出现此错误。
我使用的是带有堆栈版本1.5和SBV版本7.3的GHC版本8.0.2 我使用Z3作为我的解算器,它是在MacOS上运行的64.1版本。
调用sat
和prove
按预期工作。有任何想法吗?谢谢!
答案 0 :(得分:2)
您最有可能使用旧版Z3。 SBV中的优化功能依赖于Z3的一些尚未正式发布的功能。你能从这里下载一个:
https://github.com/Z3Prover/bin/tree/master/nightly
并尝试一下?
(Z3有一个开放的机票,可以准确地为这个问题准备一个新的版本,但是当它们能够解决这个问题时它是不清楚的:https://github.com/Z3Prover/z3/issues/1231)< / p>