Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSQP.Optimizer doesn't handle kwargs correctly #121

Open
qua4tre opened this issue Feb 16, 2023 · 1 comment · May be fixed by #122
Open

OSQP.Optimizer doesn't handle kwargs correctly #121

qua4tre opened this issue Feb 16, 2023 · 1 comment · May be fixed by #122

Comments

@qua4tre
Copy link

qua4tre commented Feb 16, 2023

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.

@qua4tre qua4tre linked a pull request Feb 16, 2023 that will close this issue
@blegat
Copy link
Collaborator

blegat commented Feb 17, 2023

Yes, not that passing these in the constructor is deprecated (which is why this error was overlooked), you should use JuMP.optimizer_with_attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants