Problem with optimisation code

What is the issue with the following code? I upgraded the packages today and facing the error. It used to work before upgrading.

using JuMP, Cbc,Ipopt,Optim
m = Model(with_optimizer(Cbc.Optimizer))

@variable(m, 0 <= x <= 2 )
@variable(m, 0 <= y <= 30 )

@objective(m, Max, 5x + 3*y )

@constraint(m, 1x + 5y <= 3.0 )


status = optimize!(m)

println("Objective value: ", objective_value(m))
println("x = ", value(x))
println("y = ", value(y))

UndefVarError: with_optimizer not defined

 [1] top-level scope at In[8]:2

for easy reference here is the package details.

1.1) pkg> st
    Status `C:\Users\Himanshi\.julia\environments\v1.1\Project.toml`
  [c52e3926] Atom v0.9.1
  [6e4b80f9] BenchmarkTools v0.4.2
  [a076750e] CPLEX v0.5.0
  [336ed68f] CSV v0.5.11
  [49dc2e85] Calculus v0.5.0
  [9961bab8] Cbc v0.6.0
  [e2554f3b] Clp v0.6.2
  [a93c6f00] DataFrames v0.19.2
  [1313f7d8] DataFramesMeta v0.5.0
  [7806a523] DecisionTree v0.8.3
  [39dd38d3] Dierckx v0.4.1
  [31c24e10] Distributions v0.21.1
  [f6369f11] ForwardDiff v0.10.3
  [38e38edf] GLM v1.3.1
  [60bf3e95] GLPK v0.11.0
  [28b8d3ca] GR v0.41.0
  [c91e804a] Gadfly v1.0.1
  [09f84164] HypothesisTests v0.8.0
  [7073ff75] IJulia v1.19.0
  [b6b21f68] Ipopt v0.6.0
  [8c755ed3] JuML v0.0.0 [`C:\Users\Himanshi\.julia\dev\JuML`]
  [4076af6c] JuMP v0.18.6
  [e5e0dc1b] Juno v0.7.2
  [5ab0869b] KernelDensity v0.5.1
  [093fc24a] LightGraphs v1.3.0
  [2fda8390] LsqFit v0.8.1
  [33e6dc65] MKL v0.0.0 #master (
  [cc2ba9b6] MLDataUtils v0.5.0
  [1914dd2f] MacroTools v0.5.1
  [b8f27783] MathOptInterface v0.9.1
  [2774e3e8] NLsolve v4.1.0
  [429524aa] Optim v0.19.2
  [9b87118b] PackageCompiler v0.6.4 #sd-notomls (
  [295af30f] Revise v2.1.8
  [3646fa90] ScikitLearn v0.5.1
  [90137ffa] StaticArrays v0.11.0
  [2913bbd2] StatsBase v0.32.0
  [f3b207a7] StatsPlots v0.11.0
  [70df011a] TableReader v0.4.0
  [c17dfb99] WinRPM v0.4.2
  [c2297ded] ZMQ v1.0.0
  [8ba89e20] Distributed
  [de0858da] Printf
  [9a3f8284] Random
  [2f01184e] SparseArrays
  [10745b16] Statistics

Please see JuMP v0.19.2 ⇒ v0.18.6.

This is an unfortunate result of Pkg choosing to downgrade JuMP in order to update GLPK. Run

up JuMP@0.19
add GLPK@0.10

It will be fixed by an upcoming release of JuMP.

1 Like

Thanks @odow and @jling

I removed GLPK but I was not able to upgrade JuMP to v0.19.2 using the ‘up’ command. I try a couple of time to add or upgrade JuMP v0.19, but it was still picking v0.18.6 somehow. So I removed JuMP and then cloned the JuMP package but then GLPK v0.10 was giving a getconstant error when running the same example. Afterwards I upgraded GLPK to v0.11 and it now it works.

Maybe another solver package (besides GLPK) was forcing the downgrade of JuMP, for similar reasons?