Hi guys programming newbie here
I am trying to solve a linear programming problem using Julia and GLPK, with emphasis on trying because so far I have been getting errors no matter what I try. This is the code:
using JuMP, GLPK
m = Model(GLPK.Optimizer)
@variable(m, x1 >= 0 )
@variable(m, x2 >= 0 )
@variable(m, x3 >= 0 )
@objective(m, Max, 200x1 +200x2 + 700x3 )
@constraint(m, 2x1 + x2 + 3x3 <= 22 )
@constraint(m, x1 + 2x2 + 4x3 <= 20 )
@constraint(m, x1 + x2 + x3 <= 10 )
optimize!(m)
println("Objective value: ", JuMP.objective_value(m))
println("x1 = ", JuMP.value(x1))
println("x2 = ", JuMP.value(x2))
println("x2 = ", JuMP.value(x3))
From what I can tell the error is in the second line, calling GLPK (or maybe the first one because it doesen't "import" GLPK) The above code is the exact code my lecturer uploaded as a solution to the problem yet it wont run on my Windows PC, I suspected it had something to do with Windows Defender, so tried without, I have uninstalled and reinstalled Julia and Atom (and the packages), I've tried including the code directly in the Julia terminal, as well as doing all of these on my laptop but to no avail. Julia ver.: 1.5.2 and I have also tested 1.0.5
I'm having a hard time figuring out what to do, and I haven't been able to find anything on Google either. I hope my question isn't too dumb, and I will greatly appreciate a solution or info!
Error message:
LoadError: MethodError: no method matching Model(::Type{GLPK.Optimizer})
Closest candidates are:
Model(::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any) at C:\Users\Peter\.julia\packages\JuMP\iGamg\src\JuMP.jl:126
Model(; caching_mode, solver) at C:\Users\Peter\.julia\packages\JuMP\iGamg\src\JuMP.jl:161
Model(!Matched::MathOptInterface.AbstractOptimizer, !Matched::Dict{MathOptInterface.ConstraintIndex,AbstractShape}, !Matched::Set{Any}, !Matched::Any, !Matched::Any, !Matched::Dict{Symbol,Any}, !Matched::Int64, !Matched::Dict{Symbol,Any}) at C:\Users\Peter\.julia\packages\JuMP\iGamg\src\JuMP.jl:126
...
in expression starting at C:\Users\Peter\iCloudDrive\BSc\Introduktion til operationsanalyse\Opgaver\Week1Ex1.jl:2
top-level scope at Week1Ex1.jl:2
include_string(::Function, ::Module, ::String, ::String) at loading.jl:1088
Pkg.status():
julia> Pkg.status()
Status `C:\Users\Peter\.julia\environments\v1.5\Project.toml`
[c52e3926] Atom v0.12.21
[60bf3e95] GLPK v0.13.0
[3c7084bd] GLPKMathProgInterface v0.5.0
[4076af6c] JuMP v0.20.0
[e5e0dc1b] Juno v0.8.3