Skip to content

[breaking] s/DataType/Type #1501

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

Merged
merged 3 commits into from
Jul 28, 2021
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
4 changes: 2 additions & 2 deletions docs/src/reference/standard_form.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ VectorQuadraticFunction
output_dimension
constant(f::Union{ScalarAffineFunction, ScalarQuadraticFunction})
constant(f::Union{VectorAffineFunction, VectorQuadraticFunction})
constant(f::SingleVariable, ::DataType)
constant(f::VectorOfVariables, T::DataType)
constant(f::SingleVariable, ::Type)
constant(f::VectorOfVariables, T::Type)
```

## Sets
Expand Down
8 changes: 4 additions & 4 deletions docs/src/submodules/Bridges/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ julia> MOI.add_constraint(optimizer, MOI.SingleVariable(x), MOI.Interval(0.0, 1.
MathOptInterface.ConstraintIndex{MathOptInterface.SingleVariable,MathOptInterface.Interval{Float64}}(1)

julia> MOI.get(optimizer, MOI.ListOfConstraintTypesPresent())
1-element Array{Tuple{DataType,DataType},1}:
1-element Array{Tuple{Type,Type},1}:
(MathOptInterface.SingleVariable, MathOptInterface.Interval{Float64})

julia> MOI.get(inner_optimizer, MOI.ListOfConstraintTypesPresent())
2-element Array{Tuple{DataType,DataType},1}:
2-element Array{Tuple{Type,Type},1}:
(MathOptInterface.SingleVariable, MathOptInterface.GreaterThan{Float64})
(MathOptInterface.SingleVariable, MathOptInterface.LessThan{Float64})
```
Expand Down Expand Up @@ -180,10 +180,10 @@ julia> MOI.add_constraint(optimizer, MOI.SingleVariable(x), MOI.Interval(0.0, 1.
MathOptInterface.ConstraintIndex{MathOptInterface.SingleVariable,MathOptInterface.Interval{Float64}}(1)

julia> MOI.get(optimizer, MOI.ListOfConstraintTypesPresent())
1-element Array{Tuple{DataType,DataType},1}:
1-element Array{Tuple{Type,Type},1}:
(MathOptInterface.SingleVariable, MathOptInterface.Interval{Float64})

julia> MOI.get(inner_optimizer, MOI.ListOfConstraintTypesPresent())
1-element Array{Tuple{DataType,DataType},1}:
1-element Array{Tuple{Type,Type},1}:
(MathOptInterface.SingleVariable, MathOptInterface.Interval{Float64})
```
4 changes: 2 additions & 2 deletions src/Bridges/Constraint/bridge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ end
BT::Type{<:AbstractBridge},
F::Type{<:MOI.AbstractFunction},
S::Type{<:MOI.AbstractSet}
)::DataType
)::Type

Return the concrete type of the bridge supporting `F`-in-`S` constraints. This
function can only be called if `MOI.supports_constraint(BT, F, S)` is `true`.
Expand All @@ -126,7 +126,7 @@ MathOptInterface.Bridges.Constraint.SplitIntervalBridge{Float64,MathOptInterface
```
"""
function concrete_bridge_type(
bridge_type::DataType,
bridge_type::Type,
::Type{<:MOI.AbstractFunction},
::Type{<:MOI.AbstractSet},
)
Expand Down
8 changes: 4 additions & 4 deletions src/Bridges/Constraint/det.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ function MOI.supports_constraint(
end

function MOIB.added_constrained_variable_types(::Type{<:LogDetBridge})
return Tuple{DataType}[]
return Tuple{Type}[]
end

function MOIB.added_constraint_types(::Type{LogDetBridge{T}}) where {T}
return [
return Tuple{Type,Type}[
(MOI.VectorAffineFunction{T}, MOI.PositiveSemidefiniteConeTriangle),
(MOI.VectorAffineFunction{T}, MOI.ExponentialCone),
(MOI.ScalarAffineFunction{T}, MOI.LessThan{T}),
Expand Down Expand Up @@ -396,11 +396,11 @@ function MOI.supports_constraint(
end

function MOIB.added_constrained_variable_types(::Type{<:RootDetBridge})
return Tuple{DataType}[]
return Tuple{Type}[]
end

function MOIB.added_constraint_types(::Type{RootDetBridge{T}}) where {T}
return [
return Tuple{Type,Type}[
(MOI.VectorAffineFunction{T}, MOI.PositiveSemidefiniteConeTriangle),
(MOI.VectorAffineFunction{T}, MOI.GeometricMeanCone),
]
Expand Down
8 changes: 4 additions & 4 deletions src/Bridges/Constraint/functionize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ end
function MOIB.added_constrained_variable_types(
::Type{<:ScalarFunctionizeBridge},
)
return Tuple{DataType}[]
return Tuple{Type}[]
end

function MOIB.added_constraint_types(
::Type{ScalarFunctionizeBridge{T,S}},
) where {T,S}
return [(MOI.ScalarAffineFunction{T}, S)]
return Tuple{Type,Type}[(MOI.ScalarAffineFunction{T}, S)]
end

function concrete_bridge_type(
Expand Down Expand Up @@ -130,13 +130,13 @@ end
function MOIB.added_constrained_variable_types(
::Type{<:VectorFunctionizeBridge},
)
return Tuple{DataType}[]
return Tuple{Type}[]
end

function MOIB.added_constraint_types(
::Type{VectorFunctionizeBridge{T,S}},
) where {T,S}
return [(MOI.VectorAffineFunction{T}, S)]
return Tuple{Type,Type}[(MOI.VectorAffineFunction{T}, S)]
end

function concrete_bridge_type(
Expand Down
4 changes: 2 additions & 2 deletions src/Bridges/Constraint/geomean.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ function MOI.supports_constraint(
end

function MOIB.added_constrained_variable_types(::Type{<:GeoMeanBridge})
return Tuple{DataType}[]
return Tuple{Type}[]
end

function MOIB.added_constraint_types(
::Type{<:GeoMeanBridge{T,F,G}},
) where {T,F,G}
return [
return Tuple{Type,Type}[
(F, MOI.LessThan{T}),
(G, MOI.RotatedSecondOrderCone),
(G, MOI.Nonnegatives),
Expand Down
4 changes: 2 additions & 2 deletions src/Bridges/Constraint/geomean_to_relentr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ function MOI.supports_constraint(
end

function MOIB.added_constrained_variable_types(::Type{<:GeoMeantoRelEntrBridge})
return [(MOI.Nonnegatives,)]
return Tuple{Type}[(MOI.Nonnegatives,)]
end

function MOIB.added_constraint_types(
::Type{<:GeoMeantoRelEntrBridge{T,F,G}},
) where {T,F,G}
return [(G, MOI.RelativeEntropyCone)]
return Tuple{Type,Type}[(G, MOI.RelativeEntropyCone)]
end

function concrete_bridge_type(
Expand Down
4 changes: 2 additions & 2 deletions src/Bridges/Constraint/indicator_activate_on_zero.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ end
function MOIB.added_constrained_variable_types(
::Type{<:IndicatorActiveOnFalseBridge},
)
return [(MOI.ZeroOne,)]
return Tuple{Type}[(MOI.ZeroOne,)]
end

function MOIB.added_constraint_types(
::Type{IndicatorActiveOnFalseBridge{T,F,S}},
) where {T,F,S}
return [
return Tuple{Type,Type}[
(MOI.ScalarAffineFunction{T}, MOI.EqualTo{T}),
(F, MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,S}),
]
Expand Down
8 changes: 4 additions & 4 deletions src/Bridges/Constraint/indicator_sos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,19 @@ end
function MOIB.added_constrained_variable_types(
::Type{<:IndicatorSOS1Bridge{T,BC}},
) where {T,BC<:Union{MOI.LessThan{T},MOI.GreaterThan{T}}}
return [(BC,)]
return Tuple{Type}[(BC,)]
end

function MOIB.added_constrained_variable_types(
::Type{<:IndicatorSOS1Bridge{T,BC}},
) where {T,BC}
return []
return Tuple{Type}[]
end

function MOIB.added_constraint_types(
::Type{<:IndicatorSOS1Bridge{T,BC}},
) where {T,BC<:Union{MOI.LessThan{T},MOI.GreaterThan{T}}}
return [
return Tuple{Type,Type}[
(MOI.VectorOfVariables, MOI.SOS1{T}),
(MOI.ScalarAffineFunction{T}, BC),
]
Expand All @@ -130,7 +130,7 @@ end
function MOIB.added_constraint_types(
::Type{<:IndicatorSOS1Bridge{T,S}},
) where {T,S<:MOI.AbstractScalarSet}
return [
return Tuple{Type,Type}[
(MOI.VectorOfVariables, MOI.SOS1{T}),
(MOI.ScalarAffineFunction{T}, S),
]
Expand Down
4 changes: 2 additions & 2 deletions src/Bridges/Constraint/interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ function MOI.supports_constraint(
end

function MOIB.added_constrained_variable_types(::Type{<:SplitIntervalBridge})
return Tuple{DataType}[]
return Tuple{Type}[]
end

function MOIB.added_constraint_types(
::Type{SplitIntervalBridge{T,F,S,LS,US}},
) where {T,F,S,LS,US}
return [(F, LS), (F, US)]
return Tuple{Type,Type}[(F, LS), (F, US)]
end

function concrete_bridge_type(
Expand Down
13 changes: 5 additions & 8 deletions src/Bridges/Constraint/map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@ struct Map <: AbstractDict{MOI.ConstraintIndex,AbstractBridge}
# It is set to `nothing` when the constraint is deleted.
bridges::Vector{Union{Nothing,AbstractBridge}}
# Constraint Index of bridged constraint -> Constraint type.
constraint_types::Vector{Tuple{DataType,DataType}}
constraint_types::Vector{Tuple{Type,Type}}
# The order of the keys is used in `keys_of_type` which is used by
# `ListOfConstraintIndices`. Therefore they need to be in the order
# of creation so we need `OrderedDict` and not `Dict`.
# For `SingleVariable` constraints: (variable, set type) -> bridge
single_variable_constraints::OrderedDict{
Tuple{Int64,DataType},
AbstractBridge,
}
single_variable_constraints::OrderedDict{Tuple{Int64,Type},AbstractBridge}
end

function Map()
return Map(
Union{Nothing,AbstractBridge}[],
Tuple{DataType,DataType}[],
OrderedDict{Tuple{Int64,DataType},AbstractBridge}(),
Tuple{Type,Type}[],
OrderedDict{Tuple{Int64,Type},AbstractBridge}(),
)
end

Expand Down Expand Up @@ -194,7 +191,7 @@ end
Return a list of all the different concrete type of keys in `map`.
"""
function list_of_key_types(map::Map)
list = Set{Tuple{DataType,DataType}}()
list = Set{Tuple{Type,Type}}()
for i in eachindex(map.bridges)
if map.bridges[i] !== nothing
push!(list, map.constraint_types[i])
Expand Down
11 changes: 7 additions & 4 deletions src/Bridges/Constraint/norm_spec_nuc_to_psd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ function MOI.supports_constraint(
end

function MOIB.added_constrained_variable_types(::Type{<:NormSpectralBridge})
return Tuple{DataType}[]
return Tuple{Type}[]
end

function MOIB.added_constraint_types(
::Type{NormSpectralBridge{T,F,G}},
) where {T,F,G}
return [(F, MOI.PositiveSemidefiniteConeTriangle)]
return Tuple{Type,Type}[(F, MOI.PositiveSemidefiniteConeTriangle)]
end

function concrete_bridge_type(
Expand Down Expand Up @@ -253,13 +253,16 @@ function MOI.supports_constraint(
end

function MOIB.added_constrained_variable_types(::Type{<:NormNuclearBridge})
return Tuple{DataType}[]
return Tuple{Type}[]
end

function MOIB.added_constraint_types(
::Type{NormNuclearBridge{T,F,G,H}},
) where {T,F,G,H}
return [(F, MOI.GreaterThan{T}), (G, MOI.PositiveSemidefiniteConeTriangle)]
return Tuple{Type,Type}[
(F, MOI.GreaterThan{T}),
(G, MOI.PositiveSemidefiniteConeTriangle),
]
end

function concrete_bridge_type(
Expand Down
4 changes: 2 additions & 2 deletions src/Bridges/Constraint/norm_to_lp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ function MOI.supports_constraint(
end

function MOIB.added_constrained_variable_types(::Type{<:NormOneBridge})
return Tuple{DataType}[]
return Tuple{Type}[]
end

function MOIB.added_constraint_types(::Type{<:NormOneBridge{T,F}}) where {T,F}
return [(F, MOI.Nonnegatives)]
return Tuple{Type,Type}[(F, MOI.Nonnegatives)]
end

function concrete_bridge_type(
Expand Down
7 changes: 5 additions & 2 deletions src/Bridges/Constraint/quad_to_soc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,14 @@ function MOI.supports_constraint(
end

function MOIB.added_constrained_variable_types(::Type{<:QuadtoSOCBridge})
return Tuple{DataType}[]
return Tuple{Type}[]
end

function MOIB.added_constraint_types(::Type{QuadtoSOCBridge{T}}) where {T}
return [(MOI.VectorAffineFunction{T}, MOI.RotatedSecondOrderCone)]
return Tuple{Type,Type}[(
MOI.VectorAffineFunction{T},
MOI.RotatedSecondOrderCone,
),]
end

function concrete_bridge_type(
Expand Down
4 changes: 2 additions & 2 deletions src/Bridges/Constraint/relentr_to_exp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ function MOI.supports_constraint(
end

function MOIB.added_constrained_variable_types(::Type{<:RelativeEntropyBridge})
return Tuple{DataType}[]
return Tuple{Type}[]
end

function MOIB.added_constraint_types(
::Type{RelativeEntropyBridge{T,F,G,H}},
) where {T,F,G,H}
return [(F, MOI.GreaterThan{T}), (G, MOI.ExponentialCone)]
return Tuple{Type,Type}[(F, MOI.GreaterThan{T}), (G, MOI.ExponentialCone)]
end

function concrete_bridge_type(
Expand Down
4 changes: 2 additions & 2 deletions src/Bridges/Constraint/scalarize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ function MOI.supports_constraint(
end

function MOIB.added_constrained_variable_types(::Type{<:ScalarizeBridge})
return Tuple{DataType}[]
return Tuple{Type}[]
end

function MOIB.added_constraint_types(
::Type{ScalarizeBridge{T,F,S}},
) where {T,F,S}
return [(F, S)]
return Tuple{Type,Type}[(F, S)]
end

function concrete_bridge_type(
Expand Down
6 changes: 3 additions & 3 deletions src/Bridges/Constraint/semi_to_binary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ end
function MOIB.added_constrained_variable_types(
::Type{<:SemiToBinaryBridge{T,S}},
) where {T,S}
return [(MOI.ZeroOne,)]
return Tuple{Type}[(MOI.ZeroOne,)]
end

function MOIB.added_constraint_types(
::Type{<:SemiToBinaryBridge{T,S}},
) where {T,S<:MOI.Semicontinuous{T}}
return [
return Tuple{Type,Type}[
(MOI.ScalarAffineFunction{T}, MOI.LessThan{T}),
(MOI.ScalarAffineFunction{T}, MOI.GreaterThan{T}),
]
Expand All @@ -90,7 +90,7 @@ end
function MOIB.added_constraint_types(
::Type{<:SemiToBinaryBridge{T,S}},
) where {T,S<:MOI.Semiinteger{T}}
return [
return Tuple{Type,Type}[
(MOI.ScalarAffineFunction{T}, MOI.LessThan{T}),
(MOI.ScalarAffineFunction{T}, MOI.GreaterThan{T}),
(MOI.SingleVariable, MOI.Integer),
Expand Down
4 changes: 2 additions & 2 deletions src/Bridges/Constraint/set_map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ function MOI.supports_constraint(
end

function MOIB.added_constrained_variable_types(::Type{<:SetMapBridge})
return Tuple{DataType}[]
return Tuple{Type}[]
end

function MOIB.added_constraint_types(
::Type{<:SetMapBridge{T,S2,S1,F}},
) where {T,S2,S1,F}
return [(F, S2)]
return Tuple{Type,Type}[(F, S2)]
end

# Attributes, Bridge acting as a model
Expand Down
Loading