Error in using KNITRO with JuMP

Hi everyone,

I have just updated my packages, then I am unable to use KNITRO.jl with JuMP anymore.

The code I run is:

using KNITRO, JuMP
model = Model(KNITRO.Optimizer)

Then, I get the following error:

The provided `optimizer_constructor` returned an object of type KNITRO.Optimizer. Expected a MathOptInterface.ModelLike.

My package versions are:

  • JuMP v1.6.0
  • KNITRO v0.13.2

I tried passing another optimizer to the JuMP Model, but I don’t get such an error.

Anyone has experience with this? Any suggestions are appreciated. Thanks!!

They latest JuMP release is 1.9.0 so you should probably use that.

They latest JuMP release is 1.9.0 so you should probably use that.

JuMP v1.X is backwards compatible, so it should work with v1.6.0 :smile:

@Rick, unfortunately I cannot reproduce this. Can you show the full output of these commands in your REPL?

julia> import Pkg

julia> Pkg.status()
      Status `/private/tmp/kn/Project.toml`
  [4076af6c] JuMP v1.6.0
  [67920dd8] KNITRO v0.13.2

julia> using JuMP, KNITRO

julia> model = Model(KNITRO.Optimizer)
##### This license is only intended for use by JuMP-dev team. #####
##### License is valid until Aug 31, 2023 #####
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: Knitro

Thanks @odow!

The output of the command is as follows:

ERROR: LoadError: The provided `optimizer_constructor` returned an object of type KNITRO.Optimizer. Expected a MathOptInterface.ModelLike.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] _instantiate_and_check(optimizer_constructor::Type{KNITRO.Optimizer})
   @ MathOptInterface ~/.julia/packages/MathOptInterface/YIcoo/src/instantiate.jl:96
 [3] _instantiate_and_check(optimizer_constructor::MathOptInterface.OptimizerWithAttributes)
   @ MathOptInterface ~/.julia/packages/MathOptInterface/YIcoo/src/instantiate.jl:117
 [4] instantiate(optimizer_constructor::MathOptInterface.OptimizerWithAttributes; with_bridge_type::Type{Float64})
   @ MathOptInterface ~/.julia/packages/MathOptInterface/YIcoo/src/instantiate.jl:149
 [5] set_optimizer(model::Model, optimizer_constructor::MathOptInterface.OptimizerWithAttributes; add_bridges::Bool)
   @ JuMP ~/.julia/packages/JuMP/vuP7I/src/optimizer_interface.jl:110
 [6] Model(optimizer_factory::MathOptInterface.OptimizerWithAttributes; add_bridges::Bool)
   @ JuMP ~/.julia/packages/JuMP/vuP7I/src/JuMP.jl:221
 [7] Model
   @ ~/.julia/packages/JuMP/vuP7I/src/JuMP.jl:220 [inlined]

What about this part?

Here’s my output. Is the warning message for MOI related?

┌ Warning: Replacing module `MathOptInterface`
└ @ Base loading.jl:937
      Status `/Project.toml`
  [6e4b80f9] BenchmarkTools v1.3.2
  [336ed68f] CSV v0.10.9
  [159f3aea] Cairo v1.0.5
  [49dc2e85] Calculus v0.5.1
  [5ae59095] Colors v0.12.10
  [a93c6f00] DataFrames v1.4.4
  [31c24e10] Distributions v0.25.80
  [186bb1d3] Fontconfig v0.4.1
  [f6369f11] ForwardDiff v0.10.34
  [c91e804a] Gadfly v1.3.4
  [2e9cd046] Gurobi v0.11.5
  [7073ff75] IJulia v1.24.0
  [b6b21f68] Ipopt v1.1.0
  [4138dd39] JLD v0.13.3
  [4076af6c] JuMP v1.6.0
  [67920dd8] KNITRO v0.13.2 `https://github.com/jump-dev/KNITRO.jl.git#master`
  [b8f27783] MathOptInterface v1.11.4
  [429524aa] Optim v1.7.4
  [d96e819e] Parameters v0.12.3
  [91a5bcdd] Plots v1.38.2
  [132c30aa] ProfileSVG v0.2.1
  [c46f51b8] ProfileView v1.5.2
  [92933f4c] ProgressMeter v1.7.2
  [d330b81b] PyPlot v2.11.0
  [df47a6cb] RData v1.0.0
  [a8a75453] StatProfilerHTML v1.4.2
  [2913bbd2] StatsBase v0.33.21
  [ade2ca70] Dates
  [37e2e46d] LinearAlgebra
      Status `/Project.toml`
  [6e4b80f9] BenchmarkTools v1.3.2
  [336ed68f] CSV v0.10.9
  [159f3aea] Cairo v1.0.5
  [49dc2e85] Calculus v0.5.1
  [5ae59095] Colors v0.12.10
  [a93c6f00] DataFrames v1.4.4
  [31c24e10] Distributions v0.25.80
  [186bb1d3] Fontconfig v0.4.1
  [f6369f11] ForwardDiff v0.10.34
  [c91e804a] Gadfly v1.3.4
  [2e9cd046] Gurobi v0.11.5
  [7073ff75] IJulia v1.24.0
  [b6b21f68] Ipopt v1.1.0
  [4138dd39] JLD v0.13.3
  [4076af6c] JuMP v1.6.0
  [67920dd8] KNITRO v0.13.2 `https://github.com/jump-dev/KNITRO.jl.git#master`
  [b8f27783] MathOptInterface v1.11.4
  [429524aa] Optim v1.7.4
  [d96e819e] Parameters v0.12.3
  [91a5bcdd] Plots v1.38.2
  [132c30aa] ProfileSVG v0.2.1
  [c46f51b8] ProfileView v1.5.2
  [92933f4c] ProgressMeter v1.7.2
  [d330b81b] PyPlot v2.11.0
  [df47a6cb] RData v1.0.0
  [a8a75453] StatProfilerHTML v1.4.2
  [2913bbd2] StatsBase v0.33.21
  [ade2ca70] Dates
  [37e2e46d] LinearAlgebra

Can you copy the code I wrote above in a new Julia REPL, and provide all output (exactly like I have done). I don’t know why the status has printed twice, or what the “Replacing module” appears.

Also, you shouldn’t need the master branch installed. Run

import Pkg
Pkg.free("KNITRO")

Then restart Julia.

Finally, what do you see if you do:

julia> import KNITRO

julia> KNITRO.Optimizer()
##### This license is only intended for use by JuMP-dev team. #####
##### License is valid until Aug 31, 2023 #####
A MathOptInterface model with backend:
Knitro 13.1.0
-----------------------
Problem Characteristics
-----------------------
Objective goal:  Minimize
Objective type:  -1
Number of variables:                             0
Number of constraints:                           0
Number of nonzeros in Jacobian:                  0
Number of nonzeros in Hessian:                   0