Starter example in JuMP

I tested JuMP some times ago an everything went perfect. Now when I retry the small model at:

https://jump.dev/JuMP.jl/stable/tutorials/getting_started/getting_started_with_JuMP/
I get an error

model = Model(GLPK.Optimizer)
ERROR: MethodError: no method matching Model(::Type{GLPK.Optimizer})

I have Julia 1.5.3 and of course added the lib JuMP and GLPK to the model.
I do not understand why this does not work anymore…
Thanks for help
Tony

I can’t tell you what’s going wrong, but I can tell you that example works in my Julia 1.7.0

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

some other basic tests

julia> using JuMP

julia> Model()
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.

julia> using GLPK

julia> GLPK.Optimizer
GLPK.Optimizer

Beyond that, a bit more of your REPL and the error message might help

So then me question is, how to update Julia WITHOUT reinstalling all packages again (I updated them with Pkg.update()).
I did not find a easy updating way in the Internet.
Tony

I don’t actually know if it is a version problem

Although 1.5.3 is no longer maintained.

Anyway, upgrading a whole Julia instance is not so simple as “upgrade”

There are quote a few discussions here on Discourse about it

e.g.

tbh. I use Projects so I am used to regularly installing a bunch of packages for each project as I use it, it’s not so bad

1 Like

You must have an old version installed.

Check:

import Pkg
Pkg.status()

Then run import Pkg; Pkg.update(). The latest version of JuMP is v0.22.2.