Skip to content
Closed
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
30 changes: 15 additions & 15 deletions docs/src/manual/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ DocTestFilters = [r"MathOptInterface|MOI"]
Use [`add_constraint`](@ref) to add a single constraint.

```jldoctest constraints; setup=:(model = MOI.Utilities.Model{Float64}(); x = MOI.add_variables(model, 2))
julia> c = MOI.add_constraint(model, MOI.VectorOfVariables(x), MOI.Nonnegatives(2))
MathOptInterface.ConstraintIndex{MathOptInterface.VectorOfVariables,MathOptInterface.Nonnegatives}(1)
julia> c = MOI.add_constraint(model, MOI.VectorOfVariables(x), MOI.NonnegativeCone(2))
MathOptInterface.ConstraintIndex{MathOptInterface.VectorOfVariables,MathOptInterface.NonnegativeCone}(1)
```

[`add_constraint`](@ref) returns a [`ConstraintIndex`](@ref) type, which should
Expand Down Expand Up @@ -98,19 +98,19 @@ nonpositive) real numbers.

### Linear constraints

| Mathematical Constraint | MOI Function | MOI Set |
|-------------------------------|------------------------------|----------------|
| ``a^Tx \le \beta`` | `ScalarAffineFunction` | `LessThan` |
| ``a^Tx \ge \alpha`` | `ScalarAffineFunction` | `GreaterThan` |
| ``a^Tx = \beta`` | `ScalarAffineFunction` | `EqualTo` |
| ``\alpha \le a^Tx \le \beta`` | `ScalarAffineFunction` | `Interval` |
| ``x_i \le \beta`` | `SingleVariable` | `LessThan` |
| ``x_i \ge \alpha`` | `SingleVariable` | `GreaterThan` |
| ``x_i = \beta`` | `SingleVariable` | `EqualTo` |
| ``\alpha \le x_i \le \beta`` | `SingleVariable` | `Interval` |
| ``Ax + b \in \mathbb{R}_+^n`` | `VectorAffineFunction` | `Nonnegatives` |
| ``Ax + b \in \mathbb{R}_-^n`` | `VectorAffineFunction` | `Nonpositives` |
| ``Ax + b = 0`` | `VectorAffineFunction` | `Zeros` |
| Mathematical Constraint | MOI Function | MOI Set |
|-------------------------------|------------------------------|-------------------|
| ``a^Tx \le \beta`` | `ScalarAffineFunction` | `LessThan` |
| ``a^Tx \ge \alpha`` | `ScalarAffineFunction` | `GreaterThan` |
| ``a^Tx = \beta`` | `ScalarAffineFunction` | `EqualTo` |
| ``\alpha \le a^Tx \le \beta`` | `ScalarAffineFunction` | `Interval` |
| ``x_i \le \beta`` | `SingleVariable` | `LessThan` |
| ``x_i \ge \alpha`` | `SingleVariable` | `GreaterThan` |
| ``x_i = \beta`` | `SingleVariable` | `EqualTo` |
| ``\alpha \le x_i \le \beta`` | `SingleVariable` | `Interval` |
| ``Ax + b \in \mathbb{R}_+^n`` | `VectorAffineFunction` | `NonnegativeCone` |
| ``Ax + b \in \mathbb{R}_-^n`` | `VectorAffineFunction` | `NonpositiveCone` |
| ``Ax + b = 0`` | `VectorAffineFunction` | `ZeroCone` |

By convention, solvers are not expected to support nonzero constant terms in the
[`ScalarAffineFunction`](@ref)s the first four rows above, because they are
Expand Down
8 changes: 4 additions & 4 deletions docs/src/manual/modification.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ julia> c = MOI.add_constraint(
],
[0.0, 0.0],
),
MOI.Nonnegatives(2),
MOI.NonnegativeCone(2),
)
MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64},MathOptInterface.Nonnegatives}(1)
MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64},MathOptInterface.NonnegativeCone}(1)

julia> MOI.modify(model, c, MOI.VectorConstantChange([3.0, 4.0]));

Expand Down Expand Up @@ -227,9 +227,9 @@ julia> c = MOI.add_constraint(
],
[0.0, 0.0],
),
MOI.Nonnegatives(2),
MOI.NonnegativeCone(2),
)
MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64},MathOptInterface.Nonnegatives}(1)
MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64},MathOptInterface.NonnegativeCone}(1)

julia> MOI.modify(model, c, MOI.MultirowChange(x, [(1, 3.0), (2, 4.0)]));

Expand Down
8 changes: 4 additions & 4 deletions docs/src/manual/standard_form.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ The one-dimensional set types implemented in MathOptInterface.jl are:

The vector-valued set types implemented in MathOptInterface.jl are:

* [`Reals(dimension)`](@ref MathOptInterface.Reals):
* [`RealCone(dimension)`](@ref MathOptInterface.RealCone):
``\mathbb{R}^\mbox{dimension}``
* [`Zeros(dimension)`](@ref MathOptInterface.Zeros): ``0^\mbox{dimension}``
* [`Nonnegatives(dimension)`](@ref MathOptInterface.Nonnegatives):
* [`ZeroCone(dimension)`](@ref MathOptInterface.ZeroCone): ``0^\mbox{dimension}``
* [`NonnegativeCone(dimension)`](@ref MathOptInterface.NonnegativeCone):
``\{ x \in \mathbb{R}^\mbox{dimension} : x \ge 0 \}``
* [`Nonpositives(dimension)`](@ref MathOptInterface.Nonpositives):
* [`NonpositiveCone(dimension)`](@ref MathOptInterface.NonpositiveCone):
``\{ x \in \mathbb{R}^\mbox{dimension} : x \le 0 \}``
* [`SecondOrderCone(dimension)`](@ref MathOptInterface.SecondOrderCone):
``\{ (t,x) \in \mathbb{R}^\mbox{dimension} : t \ge \lVert x \rVert_2 \}``
Expand Down
6 changes: 3 additions & 3 deletions docs/src/reference/standard_form.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ Semiinteger

List of recognized vector sets.
```@docs
Reals
RealCone
Zeros
Nonnegatives
Nonpositives
NonnegativeCone
NonpositiveCone
NormInfinityCone
NormOneCone
SecondOrderCone
Expand Down
4 changes: 2 additions & 2 deletions docs/src/submodules/Utilities/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ eight tuples specifying the types of constraints that are supported, and then a
The eight tuples are in the following order:
1. Un-typed scalar sets, e.g., [`Integer`](@ref)
2. Typed scalar sets, e.g., [`LessThan`](@ref)
3. Un-typed vector sets, e.g., [`Nonnegatives`](@ref)
3. Un-typed vector sets, e.g., [`NonnegativeCone`](@ref)
4. Typed vector sets, e.g., [`PowerCone`](@ref)
5. Un-typed scalar functions, e.g., [`SingleVariable`](@ref)
6. Typed scalar functions, e.g., [`ScalarAffineFunction`](@ref)
Expand All @@ -75,7 +75,7 @@ julia> MOI.Utilities.@model(
MyNewModel,
(MOI.Integer,), # Un-typed scalar sets
(MOI.GreaterThan,), # Typed scalar sets
(MOI.Nonnegatives,), # Un-typed vector sets
(MOI.NonnegativeCone,), # Un-typed vector sets
(MOI.PowerCone,), # Typed vector sets
(MOI.SingleVariable,), # Un-typed scalar functions
(MOI.ScalarAffineFunction,), # Typed scalar functions
Expand Down
2 changes: 1 addition & 1 deletion docs/src/tutorials/implementing.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ If this is the case, implement:
By default, MathOptInterface assumes solvers support free variables. If your
solver does not support free variables, define:
```julia
MOI.supports_add_constrained_variables(::Optimizer, ::Type{Reals}) = false
MOI.supports_add_constrained_variables(::Optimizer, ::Type{RealCone}) = false
```

### Incremental and `copy_to`
Expand Down
4 changes: 2 additions & 2 deletions perf/bellman_ford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ const MOIB = MOI.Bridges
# Model similar to SDPA format, it gives a good example because it does not
# support a lot hence need a lot of bridges
MOIU.@model(SDPAModel,
(), (MOI.EqualTo,), (MOI.Nonnegatives, MOI.PositiveSemidefiniteConeTriangle), (),
(), (MOI.EqualTo,), (MOI.NonnegativeCone, MOI.PositiveSemidefiniteConeTriangle), (),
(), (MOI.ScalarAffineFunction,), (MOI.VectorOfVariables,), ())
MOI.supports_constraint(::SDPAModel{T}, ::Type{MOI.SingleVariable}, ::Type{MOI.GreaterThan{T}}) where {T} = false
MOI.supports_constraint(::SDPAModel{T}, ::Type{MOI.SingleVariable}, ::Type{MOI.LessThan{T}}) where {T} = false
MOI.supports_constraint(::SDPAModel{T}, ::Type{MOI.SingleVariable}, ::Type{MOI.EqualTo{T}}) where {T} = false
MOI.supports_constraint(::SDPAModel{T}, ::Type{MOI.SingleVariable}, ::Type{MOI.Interval{T}}) where {T} = false
MOI.supports_constraint(::SDPAModel, ::Type{MOI.VectorOfVariables}, ::Type{MOI.Reals}) = false
MOI.supports_constraint(::SDPAModel, ::Type{MOI.VectorOfVariables}, ::Type{MOI.RealCone}) = false
MOI.supports(::SDPAModel{T}, ::MOI.ObjectiveFunction{MOI.ScalarQuadraticFunction{T}}) where {T} = false
MOI.supports(::SDPAModel, ::MOI.ObjectiveFunction{MOI.SingleVariable}) = false

Expand Down
28 changes: 14 additions & 14 deletions src/Bridges/Constraint/flip_sign.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,23 @@ end
T,
F<:MOI.AbstractVectorFunction,
G<:MOI.AbstractVectorFunction
} <: FlipSignBridge{T, MOI.Nonnegatives, MOI.Nonpositives, F, G}
} <: FlipSignBridge{T, MOI.NonnegativeCone, MOI.NonpositiveCone, F, G}

Transforms a `G`-in-`Nonnegatives` constraint into a `F`-in-`Nonpositives`
Transforms a `G`-in-`NonnegativeCone` constraint into a `F`-in-`NonpositiveCone`
constraint.
"""
mutable struct NonnegToNonposBridge{
T,
F<:MOI.AbstractVectorFunction,
G<:MOI.AbstractVectorFunction,
} <: FlipSignBridge{T,MOI.Nonnegatives,MOI.Nonpositives,F,G}
constraint::CI{F,MOI.Nonpositives}
} <: FlipSignBridge{T,MOI.NonnegativeCone,MOI.NonpositiveCone,F,G}
constraint::CI{F,MOI.NonpositiveCone}
end

function concrete_bridge_type(
::Type{<:NonnegToNonposBridge{T}},
G::Type{<:MOI.AbstractVectorFunction},
::Type{MOI.Nonnegatives},
::Type{MOI.NonnegativeCone},
) where {T}
F = MOIU.promote_operation(-, T, G)
return NonnegToNonposBridge{T,F,G}
Expand All @@ -163,34 +163,34 @@ end
T,
F<:MOI.AbstractVectorFunction,
G<:MOI.AbstractVectorFunction,
} <: FlipSignBridge{T, MOI.Nonpositives, MOI.Nonnegatives, F, G}
} <: FlipSignBridge{T, MOI.NonpositiveCone, MOI.NonnegativeCone, F, G}

Transforms a `G`-in-`Nonpositives` constraint into a `F`-in-`Nonnegatives`
Transforms a `G`-in-`NonpositiveCone` constraint into a `F`-in-`NonnegativeCone`
constraint.
"""
mutable struct NonposToNonnegBridge{
T,
F<:MOI.AbstractVectorFunction,
G<:MOI.AbstractVectorFunction,
} <: FlipSignBridge{T,MOI.Nonpositives,MOI.Nonnegatives,F,G}
constraint::CI{F,MOI.Nonnegatives}
} <: FlipSignBridge{T,MOI.NonpositiveCone,MOI.NonnegativeCone,F,G}
constraint::CI{F,MOI.NonnegativeCone}
end

function MOIB.map_set(::Type{<:NonposToNonnegBridge}, set::MOI.Nonpositives)
return MOI.Nonnegatives(set.dimension)
function MOIB.map_set(::Type{<:NonposToNonnegBridge}, set::MOI.NonpositiveCone)
return MOI.NonnegativeCone(set.dimension)
end

function MOIB.inverse_map_set(
::Type{<:NonposToNonnegBridge},
set::MOI.Nonnegatives,
set::MOI.NonnegativeCone,
)
return MOI.Nonpositives(set.dimension)
return MOI.NonpositiveCone(set.dimension)
end

function concrete_bridge_type(
::Type{<:NonposToNonnegBridge{T}},
G::Type{<:MOI.AbstractVectorFunction},
::Type{MOI.Nonpositives},
::Type{MOI.NonpositiveCone},
) where {T}
F = MOIU.promote_operation(-, T, G)
return NonposToNonnegBridge{T,F,G}
Expand Down
12 changes: 6 additions & 6 deletions src/Bridges/Constraint/geomean.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct GeoMeanBridge{T,F,G,H} <: AbstractBridge
xij::Vector{MOI.VariableIndex}
tubc::CI{F,MOI.LessThan{T}}
socrc::Vector{CI{G,MOI.RotatedSecondOrderCone}}
nonneg::Union{Nothing,CI{H,MOI.Nonnegatives}}
nonneg::Union{Nothing,CI{H,MOI.NonnegativeCone}}
end

function bridge_constraint(
Expand All @@ -81,7 +81,7 @@ function bridge_constraint(
allow_modify_function = true,
)
nonneg =
MOI.add_constraint(model, f_scalars[2:end], MOI.Nonnegatives(1))
MOI.add_constraint(model, f_scalars[2:end], MOI.NonnegativeCone(1))
return GeoMeanBridge{T,F,G,H}(d, xij, tubc, socrc, nonneg)
end

Expand Down Expand Up @@ -147,7 +147,7 @@ function MOIB.added_constraint_types(
return [
(F, MOI.LessThan{T}),
(G, MOI.RotatedSecondOrderCone),
(G, MOI.Nonnegatives),
(G, MOI.NonnegativeCone),
]
end

Expand Down Expand Up @@ -184,7 +184,7 @@ end

function MOI.get(
b::GeoMeanBridge{T,F,G},
::MOI.NumberOfConstraints{G,MOI.Nonnegatives},
::MOI.NumberOfConstraints{G,MOI.NonnegativeCone},
) where {T,F,G}
return (b.d > 2 ? 0 : 1)
end
Expand All @@ -205,9 +205,9 @@ end

function MOI.get(
b::GeoMeanBridge{T,F,G,H},
::MOI.ListOfConstraintIndices{H,MOI.Nonnegatives},
::MOI.ListOfConstraintIndices{H,MOI.NonnegativeCone},
) where {T,F,G,H}
return (b.d > 2 ? MOI.ConstraintIndex{H,MOI.Nonnegatives}[] : [b.nonneg])
return (b.d > 2 ? MOI.ConstraintIndex{H,MOI.NonnegativeCone}[] : [b.nonneg])
end

# References
Expand Down
10 changes: 5 additions & 5 deletions src/Bridges/Constraint/geomean_to_relentr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ of ones.
"""
struct GeoMeantoRelEntrBridge{T,F,G,H} <: AbstractBridge
y::MOI.VariableIndex
nn_index::CI{F,MOI.Nonnegatives} # for y >= 0
nn_index::CI{F,MOI.NonnegativeCone} # for y >= 0
relentr_index::CI{G,MOI.RelativeEntropyCone}
end

Expand All @@ -28,7 +28,7 @@ function bridge_constraint(
s::MOI.GeometricMeanCone,
) where {T,F,G,H}
f_scalars = MOIU.eachscalar(f)
(y, nn_index) = MOI.add_constrained_variables(model, MOI.Nonnegatives(1))
(y, nn_index) = MOI.add_constrained_variables(model, MOI.NonnegativeCone(1))
w_func = MOIU.vectorize(
fill(
MOIU.operate(+, T, f_scalars[1], MOI.SingleVariable(y[1])),
Expand Down Expand Up @@ -59,7 +59,7 @@ function MOI.supports_constraint(
end

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

function MOIB.added_constraint_types(
Expand Down Expand Up @@ -94,7 +94,7 @@ end

function MOI.get(
::GeoMeantoRelEntrBridge{T,F},
::MOI.NumberOfConstraints{F,MOI.Nonnegatives},
::MOI.NumberOfConstraints{F,MOI.NonnegativeCone},
) where {T,F}
return 1
end
Expand All @@ -108,7 +108,7 @@ end

function MOI.get(
bridge::GeoMeantoRelEntrBridge{T,F},
::MOI.ListOfConstraintIndices{F,MOI.Nonnegatives},
::MOI.ListOfConstraintIndices{F,MOI.NonnegativeCone},
) where {T,F}
return [bridge.nn_index]
end
Expand Down
22 changes: 14 additions & 8 deletions src/Bridges/Constraint/interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ _lower_set(set::MOI.Interval) = MOI.GreaterThan(set.lower)
_upper_set(set::MOI.Interval) = MOI.LessThan(set.upper)
_lower_set(set::MOI.EqualTo) = MOI.GreaterThan(set.value)
_upper_set(set::MOI.EqualTo) = MOI.LessThan(set.value)
_lower_set(set::MOI.Zeros) = MOI.Nonnegatives(set.dimension)
_upper_set(set::MOI.Zeros) = MOI.Nonpositives(set.dimension)
_lower_set(set::MOI.ZeroCone) = MOI.NonnegativeCone(set.dimension)
_upper_set(set::MOI.ZeroCone) = MOI.NonpositiveCone(set.dimension)

"""
SplitIntervalBridge{T, F, S, LS, US}
Expand All @@ -12,7 +12,7 @@ The `SplitIntervalBridge` splits a `F`-in-`S` constraint into a `F`-in-`LS` and
a `F`-in-`US` constraint where we have either:
* `S = MOI.Interval{T}`, `LS = MOI.GreaterThan{T}` and `US = MOI.LessThan{T}`,
* `S = MOI.EqualTo{T}`, `LS = MOI.GreaterThan{T}` and `US = MOI.LessThan{T}`, or
* `S = MOI.Zeros`, `LS = MOI.Nonnegatives` and `US = MOI.Nonpositives`.
* `S = MOI.ZeroCone`, `LS = MOI.NonnegativeCone` and `US = MOI.NonpositiveCone`.

For instance, if `F` is `MOI.ScalarAffineFunction` and `S` is `MOI.Interval`,
it transforms the constraint ``l ≤ ⟨a, x⟩ + α ≤ u`` into the constraints
Expand Down Expand Up @@ -51,7 +51,7 @@ end
function MOI.supports_constraint(
::Type{SplitIntervalBridge{T}},
F::Type{<:MOI.AbstractVectorFunction},
::Type{MOI.Zeros},
::Type{MOI.ZeroCone},
) where {T}
return MOIU.is_coefficient_type(F, T)
end
Expand All @@ -77,9 +77,15 @@ end
function concrete_bridge_type(
::Type{<:SplitIntervalBridge{T}},
F::Type{<:MOI.AbstractVectorFunction},
::Type{MOI.Zeros},
::Type{MOI.ZeroCone},
) where {T}
return SplitIntervalBridge{T,F,MOI.Zeros,MOI.Nonnegatives,MOI.Nonpositives}
return SplitIntervalBridge{
T,
F,
MOI.ZeroCone,
MOI.NonnegativeCone,
MOI.NonpositiveCone,
}
end

# Attributes, Bridge acting as a model
Expand Down Expand Up @@ -286,7 +292,7 @@ end
function MOI.get(
model::MOI.ModelLike,
attr::MOI.ConstraintSet,
bridge::SplitIntervalBridge{T,F,MOI.Zeros},
bridge::SplitIntervalBridge{T,F,MOI.ZeroCone},
) where {T,F}
return MOI.Zeros(MOI.get(model, attr, bridge.lower).dimension)
return MOI.ZeroCone(MOI.get(model, attr, bridge.lower).dimension)
end
Loading