JuMP CPLEX attribute error for getting CPX_PARAM_INTSOLLIM

I am trying to get a CPLEX attribute of a model. I am using JuMP v0.21.10 and CPLEX v0.7.8.

using JuMP, CPLEX

m = Model()
set_optimizer(m, optimizer_with_attributes(CPLEX.Optimizer, "CPX_PARAM_INTSOLLIM" => 1))
get_optimizer_attribute(m, "CPX_PARAM_INTSOLLIM")

However, this gives me

ERROR: MethodError: Cannot `convert` an object of type Base.RefValue{Int64} to an object of type Int64
Closest candidates are:
  convert(::Type{T}, ::T) where T<:Number at number.jl:6
  convert(::Type{T}, ::Number) where T<:Number at number.jl:7
  convert(::Type{T}, ::Ptr) where T<:Integer at pointer.jl:23
  ...
Stacktrace:
 [1] cconvert(::Type{T} where T, ::Base.RefValue{Int64}) at ./essentials.jl:388
 [2] CPXsetlongparam(::CPLEX.Env, ::Int32, ::Base.RefValue{Int64}) at /home/username/.julia/packages/CPLEX/rmvSt/src/gen1210/libcpx_api.jl:1122
 [3] get(::CPLEX.Optimizer, ::MathOptInterface.RawParameter) at /home/username/.julia/packages/CPLEX/rmvSt/src/MOI/MOI_wrapper.jl:456
 [4] get(::MathOptInterface.Bridges.LazyBridgeOptimizer{CPLEX.Optimizer}, ::MathOptInterface.RawParameter) at /home/username/.julia/packages/MathOptInterface/YDdD3/src/Bridges/bridge_optimizer.jl:804
 [5] get(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64,MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}}, ::MathOptInterface.RawParameter) at /home/username/.julia/packages/MathOptInterface/YDdD3/src/Utilities/cachingoptimizer.jl:847
 [6] get(::Model, ::MathOptInterface.RawParameter) at /home/username/.julia/packages/JuMP/klrjG/src/JuMP.jl:1223
 [7] get_optimizer_attribute at /home/username/.julia/packages/JuMP/klrjG/src/JuMP.jl:948 [inlined]
 [8] get_optimizer_attribute(::Model, ::String) at /home/username/.julia/packages/JuMP/klrjG/src/JuMP.jl:926

It seems to be returning a pointer, but how can I get the integer value?

That looks like a bug in which we’re calling setlongparam instead of getlongparam. I’ve opened a PR to fix: https://github.com/jump-dev/CPLEX.jl/pull/389

This is now fixed in the latest version of CPLEX.jl. Please update your packages. You’ll need CPLEX.jl v0.9.1.

2 Likes