Skip to content

Fix SetMapBridge with complex type#2733

Merged
odow merged 8 commits intomasterfrom
bl/set_map_complex
Apr 30, 2025
Merged

Fix SetMapBridge with complex type#2733
odow merged 8 commits intomasterfrom
bl/set_map_complex

Conversation

@blegat
Copy link
Copy Markdown
Member

@blegat blegat commented Apr 22, 2025

The bridges don't support dealing with a function that is not of coefficient type T. So with ComplexF64, we had these errors but actually we get the same with Int for instance. So we might as well check it with MOI.is_coefficient_type

Before the PR

julia> model = MOI.instantiate(MOI.Utilities.Model{Float64}, with_bridge_type=Float64)

julia> MOI.supports_constraint(model, MOI.VectorAffineFunction{Int}, MOI.Nonnegatives)
ERROR: MethodError: no method matching promote_operation(::typeof(-), ::Type{Float64}, ::Type{MathOptInterface.VectorAffineFunction{Int64}})
The function `promote_operation` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  promote_operation(::typeof(-), ::Type{T}, ::Type{MathOptInterface.VectorNonlinearFunction}) where T<:Number
   @ MathOptInterface ~/.julia/dev/MathOptInterface/src/Utilities/promote_operation.jl:177
  promote_operation(::typeof(-), ::Type{T}, ::Type{MathOptInterface.VectorOfVariables}) where T<:Number
   @ MathOptInterface ~/.julia/dev/MathOptInterface/src/Utilities/promote_operation.jl:169
  promote_operation(::typeof(-), ::Type{T}, ::Type{F}) where {T, F<:Union{AbstractVector{T}, MathOptInterface.ScalarAffineFunction{T}, MathOptInterface.ScalarNonlinearFunction, MathOptInterface.ScalarQuadraticFunction{T}, MathOptInterface.VectorAffineFunction{T}, MathOptInterface.VectorQuadraticFunction{T}, T}}
   @ MathOptInterface ~/.julia/dev/MathOptInterface/src/Utilities/promote_operation.jl:142
  ...

Stacktrace:
 [1] concrete_bridge_type(::Type{…}, G::Type{…}, ::Type{…})
   @ MathOptInterface.Bridges.Constraint ~/.julia/dev/MathOptInterface/src/Bridges/Constraint/bridges/FlipSignBridge.jl:238
 [2] node(b::MathOptInterface.Bridges.LazyBridgeOptimizer{…}, F::Type{…}, S::Type{…})
   @ MathOptInterface.Bridges ~/.julia/dev/MathOptInterface/src/Bridges/lazy_bridge_optimizer.jl:327
 [3] bridge_index
   @ ~/.julia/dev/MathOptInterface/src/Bridges/lazy_bridge_optimizer.jl:464 [inlined]
 [4] supports_bridging_constraint
   @ ~/.julia/dev/MathOptInterface/src/Bridges/lazy_bridge_optimizer.jl:491 [inlined]
 [5] supports_constraint(b::MathOptInterface.Bridges.LazyBridgeOptimizer{…}, F::Type{…}, S::Type{…})
   @ MathOptInterface.Bridges ~/.julia/dev/MathOptInterface/src/Bridges/bridge_optimizer.jl:1837
 [6] top-level scope
   @ REPL[22]:1
Some type information was truncated. Use `show(err)` to see complete types.

After the PR:

julia> MOI.supports_constraint(model, MOI.VectorAffineFunction{Int}, MOI.Nonnegatives)
false

Needed for jump-dev/SeDuMi.jl#28

@odow
Copy link
Copy Markdown
Member

odow commented Apr 23, 2025

Can we test this somehow?

Comment thread src/Bridges/Constraint/bridges/InequalityToComplementsBridge.jl Outdated
Comment thread src/Bridges/Constraint/bridges/InequalityToComplementsBridge.jl Outdated
Comment thread src/Bridges/Constraint/bridges/NormOneBridge.jl Outdated
@odow
Copy link
Copy Markdown
Member

odow commented Apr 27, 2025

Comment thread src/Bridges/Constraint/bridges/NormOneBridge.jl Outdated
@odow odow mentioned this pull request Apr 30, 2025
9 tasks
@odow odow merged commit e0d6bb3 into master Apr 30, 2025
30 of 31 checks passed
@odow odow deleted the bl/set_map_complex branch April 30, 2025 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants