Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/SAGE/SAGE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function PolyJuMP.bridges(
F::Type{<:MOI.AbstractVectorFunction},
::Type{Cone{Signomials{Nothing}}},
)
return [(SAGEBridge, PolyJuMP._coef_type(F))]
return Tuple{Type,Type}[(SAGEBridge, PolyJuMP.coefficient_type_or_float(F))]
end

include("bridges/age.jl")
Expand All @@ -164,7 +164,7 @@ function PolyJuMP.bridges(
F::Type{<:MOI.AbstractVectorFunction},
::Type{Cone{Signomials{Int}}},
)
return [(AGEBridge, PolyJuMP._coef_type(F))]
return Tuple{Type,Type}[(AGEBridge, PolyJuMP.coefficient_type_or_float(F))]
end

include("bridges/signomial.jl")
Expand All @@ -173,7 +173,10 @@ function PolyJuMP.bridges(
F::Type{<:MOI.AbstractVectorFunction},
::Type{Cone{Polynomials{M}}},
) where {M}
return [(SignomialsBridge, PolyJuMP._coef_type(F))]
return Tuple{Type,Type}[(
SignomialsBridge,
PolyJuMP.coefficient_type_or_float(F),
)]
end

end
26 changes: 19 additions & 7 deletions src/constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ end
Return a list of bridges that may be needed to bridge `F`-in-`S` constraints but
not the bridges that may be needed by constraints added by the bridges.
"""
bridges(::Type{<:MOI.AbstractFunction}, ::Type{<:MOI.AbstractSet}) = []
bridges(::Type{<:MOI.AbstractFunction}, ::Type{<:MOI.AbstractSet}) =
Tuple{Type,Type}[]

"""
bridges(S::Type{<:MOI.AbstractSet})
Expand All @@ -79,21 +80,27 @@ function bridges(
F::Type{<:MOI.AbstractVectorFunction},
::Type{<:ZeroPolynomialSet{SS.FullSpace}},
)
return [(Bridges.Constraint.ZeroPolynomialBridge, _coef_type(F))]
return Tuple{Type,Type}[(
Bridges.Constraint.ZeroPolynomialBridge,
coefficient_type_or_float(F),
)]
end

function bridges(
F::Type{<:MOI.AbstractVectorFunction},
::Type{<:ZeroPolynomialSet{<:SS.AbstractAlgebraicSet}},
)
return [(
return Tuple{Type,Type}[(
Bridges.Constraint.ZeroPolynomialInAlgebraicSetBridge,
_coef_type(F),
coefficient_type_or_float(F),
)]
end

function bridges(F::Type{<:MOI.AbstractVectorFunction}, ::Type{<:PlusMinusSet})
return [(Bridges.Constraint.PlusMinusBridge, _coef_type(F))]
return Tuple{Type,Type}[(
Bridges.Constraint.PlusMinusBridge,
coefficient_type_or_float(F),
)]
end

"""
Expand Down Expand Up @@ -143,8 +150,13 @@ function bridgeable(c::JuMP.AbstractConstraint, S::Type{<:MOI.AbstractSet})
return c
end

_coef_type(::Type{<:MOI.AbstractFunction}) = Float64
_coef_type(::Type{<:MOI.Utilities.TypedLike{T}}) where {T} = T
# TODO If `JuMP.value_type` is not `Float64`, we should
# redo `bridgeable`, `bridges` etc... in `JuMP.model_convert`
# the most important is that `MOI.Bridges.concrete_bridge_type`
# works so we should stick to the same coefficient type if there is
# one. If there is none, `Float64` should be fine.
coefficient_type_or_float(::Type{<:MOI.AbstractFunction}) = Float64
coefficient_type_or_float(::Type{<:MOI.Utilities.TypedLike{T}}) where {T} = T

function bridgeable(
c::JuMP.AbstractConstraint,
Expand Down
5 changes: 4 additions & 1 deletion test/testpolymodule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ function PolyJuMP.bridges(
F::Type{<:MOI.AbstractVectorFunction},
::Type{<:NonNeg},
)
return [(DummyNonNegBridge, PolyJuMP._coef_type(F))]
return Tuple{Type,Type}[(
DummyNonNegBridge,
PolyJuMP.coefficient_type_or_float(F),
)]
end
function MOI.Bridges.added_constrained_variable_types(
::Type{<:DummyNonNegBridge},
Expand Down