julia:使用Model(GLPK.Optimizer)和optimize!(model)时出错

大家好,今天我在尝试写官方提供的代码

using JuMP
using GLPK
model=Model(GLPK.Optimizer)
@variable(model,x>=0)
@variable(model,0<=y<=3)
@objective(model,Min,12x+20y)
@constraint(model,c1,6x+8y>=100)
@constraint(model,c2,7x+12y>=120)
print(model)
optimize!(model)
@show termination_status(model)
@show primal_status(model)
@show dual_status(model)
@show objective_value(model)
@show value(x)
@show value(y)
@show shadow_price(c1)
@show shadow_price(c2)

发现julia会在Model(GLPK.Optimizer)报错:cannot 'convert 'an object of type Type{GLPK.Optimizer} to an object of type JuMP.Model

optimize!(model)和下面的代码报错:undefvarerror:optimize! not defined

这是为啥呢,我是第一次在Atom里敲julia的代码,不是很明白,能请各位讲一下吗?感激不尽!

使用
JuMP.optimize!

但是在我电脑上都是可以运行的,
_ _ ()_ | Documentation: https://docs.julialang.org
() | () () |
_ _ | | __ _ | Type “?” for help, “]?” for Pkg help.
| | | | | | |/ ` | |
| | |
| | | | (
| | | Version 1.7.3 (2022-05-06)
/ |_|||_’_| | Official https://julialang.org/ release
|__/ |

julia> using JuMP

julia> using GLPK

julia> model=Model(GLPK.Optimizer)
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: GLPK

julia> @variable(model,x>=0)
x

julia> @variable(model,0<=y<=3)
y

julia> @objective(model,Min,12x+20y)
12 x + 20 y

julia> @constraint(model,c1,6x+8y>=100)
c1 : 6 x + 8 y >= 100.0

julia> @constraint(model,c2,7x+12y>=120)
c2 : 7 x + 12 y >= 120.0

julia> print(model)
Min 12 x + 20 y
Subject to
c1 : 6 x + 8 y >= 100.0
c2 : 7 x + 12 y >= 120.0
x >= 0.0
y >= 0.0
y <= 3.0

julia> optimize!(model)

julia> @show termination_status(model)
termination_status(model) = MathOptInterface.OPTIMAL
OPTIMAL::TerminationStatusCode = 1

julia> @show primal_status(model)
primal_status(model) = MathOptInterface.FEASIBLE_POINT
FEASIBLE_POINT::ResultStatusCode = 1

julia> @show dual_status(model)
dual_status(model) = MathOptInterface.FEASIBLE_POINT
FEASIBLE_POINT::ResultStatusCode = 1

julia> @show objective_value(model)
objective_value(model) = 204.99999999999997
204.99999999999997

julia> @show value(x)
value(x) = 15.000000000000005
15.000000000000005

julia> @show value(y)
value(y) = 1.249999999999996
1.249999999999996

julia> @show shadow_price(c1)
shadow_price(c1) = -0.24999999999999922
-0.24999999999999922

julia> @show shadow_price(c2)
shadow_price(c2) = -1.5000000000000007
-1.5000000000000007