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

Utilities.Model does not support complex number types #1947

Closed
odow opened this issue Jul 13, 2022 · 2 comments
Closed

Utilities.Model does not support complex number types #1947

odow opened this issue Jul 13, 2022 · 2 comments
Labels
Project: generic number support Issues relating to generic number (e.g., Complex) support Submodule: Utilities About the Utilities submodule

Comments

@odow
Copy link
Member

odow commented Jul 13, 2022

julia> MOI.Utilities.Model{Complex{Float64}}()
ERROR: MethodError: Cannot `convert` an object of type 
  Nothing to an object of type 
  Union{}
Closest candidates are:
  convert(::Type{Union{}}, ::Any) at essentials.jl:203
  convert(::Type{T}, ::Any) where T<:VecElement at baseext.jl:8
  convert(::Type{var"#s814"} where var"#s814"<:LinearAlgebra.Hermitian, ::Union{LinearAlgebra.Hermitian, LinearAlgebra.Symmetric}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/symmetric.jl:194
  ...
Stacktrace:
 [1] convert(#unused#::Type{Union{}}, x::Nothing)
   @ Base ./essentials.jl:203
 [2] MathOptInterface.Utilities.ModelFunctionConstraints{ComplexF64}()
   @ MathOptInterface.Utilities ~/.julia/dev/MathOptInterface/src/Utilities/struct_of_constraints.jl:378
 [3] MathOptInterface.Utilities.Model{ComplexF64}()
   @ MathOptInterface.Utilities ~/.julia/dev/MathOptInterface/src/Utilities/model.jl:736
 [4] top-level scope
   @ REPL[24]:1
@odow odow added Submodule: Utilities About the Utilities submodule Project: generic number support Issues relating to generic number (e.g., Complex) support labels Jul 13, 2022
@odow
Copy link
Member Author

odow commented Jul 13, 2022

Oooof. This is a tricky one.

The issue is that some of the sets have restrictions on type parameters:

julia> MOI.PowerCone{ComplexF64}
ERROR: TypeError: in PowerCone, in T, expected T<:Real, got Type{ComplexF64}
Stacktrace:
 [1] top-level scope
   @ REPL[59]:1

which causes some weird errors, but effectively we can't support ComplexF64 in Model.

@odow
Copy link
Member Author

odow commented Jul 13, 2022

Closing this for now since there's no simple solution and we can work-around it with a UniversalFallback. We can come back to it if it pops up again.

Edit: Actually one solution might be adding ScalarAffineFunction{Complex{T}} and EqualTo{Complex{T}} as functions and sets, but that isn't a general solution.

@odow odow closed this as completed Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Project: generic number support Issues relating to generic number (e.g., Complex) support Submodule: Utilities About the Utilities submodule
Development

No branches or pull requests

1 participant