OSQP.jl
OSQP.jl copied to clipboard
OSQP.Optimizer doesn't handle kwargs correctly
The following gives me an error:
julia> OSQP.Optimizer(max_iter=10)
ERROR: MethodError: Cannot `convert` an object of type Symbol to an object of type String
Closest candidates are:
convert(::Type{String}, ::String) at essentials.jl:218
convert(::Type{T}, ::T) where T<:AbstractString at strings/basic.jl:231
convert(::Type{T}, ::AbstractString) where T<:AbstractString at strings/basic.jl:232
...
Stacktrace:
[1] MathOptInterface.RawOptimizerAttribute(name::Symbol)
@ MathOptInterface ~\.julia\packages\MathOptInterface\src\attributes.jl:868
[2] OSQP.MathOptInterfaceOSQP.Optimizer(; kwargs::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:max_iter,), Tuple{Int64}}})
@ OSQP.MathOptInterfaceOSQP ~\.julia\packages\OSQP\src\MOI_wrapper.jl:81
[3] top-level scope
@ REPL[12]:1
The backtrace points to the following lines in MOI_wrapper.jl:
for (key, value) in kwargs
MOI.set(optimizer, MOI.RawOptimizerAttribute(key), value)
end
I looked up the call signature for RawOptimizerAttribute in MathOptInterface and it's RawOptimizerAttribute(name::String). So I think the keys need to be converted into Strings. Or add support in MathOptInterface for RawOptimizerAttribute(name::Symbol)? If that's preferable, I can open an issue over there instead.
Yes, not that passing these in the constructor is deprecated (which is why this error was overlooked), you should use JuMP.optimizer_with_attributes