Julia "no method matching supports_default_copy_to(::GLPK.Optimizer, ::Bool)" 声明模型
Julia "no method matching supports_default_copy_to(::GLPK.Optimizer, ::Bool)" declaring Model
我是 Julia 的新手并尝试 运行 Second Edition of Julia Programming for Operations Research 中的第一个示例脚本,但前两行:
using JuMP, GLPK
m = Model(with_optimizer(GLPK.Optimizer))
抛出以下错误:
julia> m = Model(with_optimizer(GLPK.Optimizer))
ERROR: MethodError: no method matching supports_default_copy_to(::GLPK.Optimizer, ::Bool)
Closest candidates are:
supports_default_copy_to(::MathOptInterface.Utilities.AbstractModel, ::Bool) at /home/mepstein/.julia/packages/MathOptInterface/C1XBe/src/Utilities/model.jl:693
supports_default_copy_to(::MathOptInterface.Utilities.MockOptimizer, ::Bool) at /home/mepstein/.julia/packages/MathOptInterface/C1XBe/src/Utilities/mockoptimizer.jl:521
supports_default_copy_to(::MathOptInterface.Utilities.CachingOptimizer, ::Bool) at /home/mepstein/.julia/packages/MathOptInterface/C1XBe/src/Utilities/cachingoptimizer.jl:165
如果相关,using JuMP, GLPK
抛出以下 warning
:
┌ Warning: Replacing module MathOptInterface
└ @ Base loading.jl:942
我的版本是:
Julia: 1.3.1 (latest stable)
"GLPK" => v"0.12.0"
"JuMP" => v"0.20.1"
本书作者在 https://github.com/chkwon/jpor_codes/issues/4
解决了这个问题
来自 julia
解释器的 运行 ] up
将 GLPK 从 12.0 升级到 12.1。很有趣,因为几个小时前我刚刚安装了 GLPK。事实上,我什至不确定我 'upgraded' 安装的版本;从日志看来 ] up
使某些配置文件与已安装的版本一致?
julia>
(v1.3) pkg> up
Updating registry at `~/.julia/registries/General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Resolving package versions...
Installed GLPK ─ v0.12.1
Updating `~/.julia/environments/v1.3/Project.toml`
[60bf3e95] ↑ GLPK v0.12.0 ⇒ v0.12.1
Updating `~/.julia/environments/v1.3/Manifest.toml`
[60bf3e95] ↑ GLPK v0.12.0 ⇒ v0.12.1
Building GLPK → `~/.julia/packages/GLPK/HjJiX/deps/build.log`
无论如何,上面问题中的代码现在可以运行并给出以下输出:
julia> using JuMP, GLPK
julia> m = Model(with_optimizer(GLPK.Optimizer))
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: GLPK```
我是 Julia 的新手并尝试 运行 Second Edition of Julia Programming for Operations Research 中的第一个示例脚本,但前两行:
using JuMP, GLPK
m = Model(with_optimizer(GLPK.Optimizer))
抛出以下错误:
julia> m = Model(with_optimizer(GLPK.Optimizer))
ERROR: MethodError: no method matching supports_default_copy_to(::GLPK.Optimizer, ::Bool)
Closest candidates are:
supports_default_copy_to(::MathOptInterface.Utilities.AbstractModel, ::Bool) at /home/mepstein/.julia/packages/MathOptInterface/C1XBe/src/Utilities/model.jl:693
supports_default_copy_to(::MathOptInterface.Utilities.MockOptimizer, ::Bool) at /home/mepstein/.julia/packages/MathOptInterface/C1XBe/src/Utilities/mockoptimizer.jl:521
supports_default_copy_to(::MathOptInterface.Utilities.CachingOptimizer, ::Bool) at /home/mepstein/.julia/packages/MathOptInterface/C1XBe/src/Utilities/cachingoptimizer.jl:165
如果相关,using JuMP, GLPK
抛出以下 warning
:
┌ Warning: Replacing module MathOptInterface
└ @ Base loading.jl:942
我的版本是:
Julia: 1.3.1 (latest stable)
"GLPK" => v"0.12.0"
"JuMP" => v"0.20.1"
本书作者在 https://github.com/chkwon/jpor_codes/issues/4
解决了这个问题 来自julia
解释器的 运行 ] up
将 GLPK 从 12.0 升级到 12.1。很有趣,因为几个小时前我刚刚安装了 GLPK。事实上,我什至不确定我 'upgraded' 安装的版本;从日志看来 ] up
使某些配置文件与已安装的版本一致?
julia>
(v1.3) pkg> up
Updating registry at `~/.julia/registries/General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Resolving package versions...
Installed GLPK ─ v0.12.1
Updating `~/.julia/environments/v1.3/Project.toml`
[60bf3e95] ↑ GLPK v0.12.0 ⇒ v0.12.1
Updating `~/.julia/environments/v1.3/Manifest.toml`
[60bf3e95] ↑ GLPK v0.12.0 ⇒ v0.12.1
Building GLPK → `~/.julia/packages/GLPK/HjJiX/deps/build.log`
无论如何,上面问题中的代码现在可以运行并给出以下输出:
julia> using JuMP, GLPK
julia> m = Model(with_optimizer(GLPK.Optimizer))
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: GLPK```