From cc6134fae1e24f46f4a5c9236661863035e74465 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 18 Jul 2021 05:29:56 +0200 Subject: [PATCH 1/5] Rename Nonnegatives to NonnegativeCone. --- docs/src/manual/constraints.md | 30 ++--- docs/src/manual/modification.md | 8 +- docs/src/manual/standard_form.md | 2 +- docs/src/reference/standard_form.md | 2 +- docs/src/submodules/Utilities/overview.md | 4 +- perf/bellman_ford.jl | 2 +- src/Bridges/Constraint/flip_sign.jl | 20 +-- src/Bridges/Constraint/geomean.jl | 12 +- src/Bridges/Constraint/geomean_to_relentr.jl | 10 +- src/Bridges/Constraint/interval.jl | 6 +- src/Bridges/Constraint/norm_to_lp.jl | 20 +-- src/Bridges/Variable/bridge.jl | 8 +- src/Bridges/Variable/flip_sign.jl | 8 +- src/Bridges/Variable/free.jl | 12 +- src/Bridges/Variable/rsoc_to_psd.jl | 14 +- src/Bridges/Variable/vectorize.jl | 4 +- src/Bridges/flip_sign.jl | 4 +- src/Bridges/lazy_bridge_optimizer.jl | 2 +- .../UnitTests/basic_constraint_tests.jl | 12 +- src/DeprecatedTest/UnitTests/modifications.jl | 4 +- src/DeprecatedTest/UnitTests/variables.jl | 8 +- src/DeprecatedTest/contconic.jl | 94 ++++++------- src/DeprecatedTest/contlinear.jl | 10 +- src/DeprecatedTest/contquadratic.jl | 6 +- src/DeprecatedTest/modellike.jl | 26 ++-- src/FileFormats/CBF/CBF.jl | 2 +- src/FileFormats/CBF/read.jl | 2 +- src/FileFormats/CBF/write.jl | 4 +- src/FileFormats/MOF/MOF.jl | 2 +- src/FileFormats/MOF/mof.0.6.schema.json | 4 +- src/FileFormats/MOF/read.jl | 6 +- src/FileFormats/MOF/write.jl | 2 +- src/FileFormats/SDPA/SDPA.jl | 6 +- src/Test/test_basic_constraint.jl | 4 +- src/Test/test_conic.jl | 124 +++++++++--------- src/Test/test_constraint.jl | 12 +- src/Test/test_linear.jl | 6 +- src/Test/test_model.jl | 2 +- src/Test/test_modification.jl | 4 +- src/Test/test_quadratic.jl | 8 +- src/Test/test_variable.jl | 10 +- src/Utilities/model.jl | 8 +- src/Utilities/parser.jl | 2 +- src/Utilities/precompile.jl | 2 +- src/Utilities/product_of_sets.jl | 2 +- src/Utilities/sets.jl | 6 +- src/sets.jl | 22 ++-- test/Bridges/Constraint/det.jl | 4 +- test/Bridges/Constraint/flip_sign.jl | 10 +- test/Bridges/Constraint/functionize.jl | 12 +- test/Bridges/Constraint/geomean.jl | 12 +- test/Bridges/Constraint/geomean_to_relentr.jl | 24 ++-- test/Bridges/Constraint/interval.jl | 4 +- test/Bridges/Constraint/norm_to_lp.jl | 50 +++---- test/Bridges/Constraint/quad_to_soc.jl | 2 +- test/Bridges/Constraint/scalarize.jl | 16 +-- test/Bridges/Constraint/slack.jl | 12 +- test/Bridges/Constraint/vectorize.jl | 6 +- test/Bridges/Variable/flip_sign.jl | 12 +- test/Bridges/Variable/free.jl | 18 +-- test/Bridges/Variable/rsoc_to_psd.jl | 8 +- test/Bridges/Variable/vectorize.jl | 4 +- test/Bridges/bridge_optimizer.jl | 18 +-- test/Bridges/lazy_bridge_optimizer.jl | 38 +++--- test/DeprecatedTest/contconic.jl | 30 ++--- test/DeprecatedTest/contquadratic.jl | 2 +- test/FileFormats/CBF/CBF.jl | 14 +- test/FileFormats/MOF/MOF.jl | 4 +- test/FileFormats/SDPA/SDPA.jl | 10 +- test/Utilities/cachingoptimizer.jl | 8 +- test/Utilities/copy.jl | 44 +++---- test/Utilities/matrix_of_constraints.jl | 20 +-- test/Utilities/mockoptimizer.jl | 4 +- test/Utilities/product_of_sets.jl | 12 +- test/errors.jl | 4 +- test/hygiene.jl | 2 +- test/sets.jl | 6 +- 77 files changed, 489 insertions(+), 489 deletions(-) diff --git a/docs/src/manual/constraints.md b/docs/src/manual/constraints.md index b7a3df04e2..2d6c58056f 100644 --- a/docs/src/manual/constraints.md +++ b/docs/src/manual/constraints.md @@ -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 @@ -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` | `Nonpositives` | +| ``Ax + b = 0`` | `VectorAffineFunction` | `Zeros` | By convention, solvers are not expected to support nonzero constant terms in the [`ScalarAffineFunction`](@ref)s the first four rows above, because they are diff --git a/docs/src/manual/modification.md b/docs/src/manual/modification.md index b28999c3dc..b5eeb5e484 100644 --- a/docs/src/manual/modification.md +++ b/docs/src/manual/modification.md @@ -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])); @@ -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)])); diff --git a/docs/src/manual/standard_form.md b/docs/src/manual/standard_form.md index e4600da18f..efb36fa69e 100644 --- a/docs/src/manual/standard_form.md +++ b/docs/src/manual/standard_form.md @@ -74,7 +74,7 @@ The vector-valued set types implemented in MathOptInterface.jl are: * [`Reals(dimension)`](@ref MathOptInterface.Reals): ``\mathbb{R}^\mbox{dimension}`` * [`Zeros(dimension)`](@ref MathOptInterface.Zeros): ``0^\mbox{dimension}`` -* [`Nonnegatives(dimension)`](@ref MathOptInterface.Nonnegatives): +* [`NonnegativeCone(dimension)`](@ref MathOptInterface.NonnegativeCone): ``\{ x \in \mathbb{R}^\mbox{dimension} : x \ge 0 \}`` * [`Nonpositives(dimension)`](@ref MathOptInterface.Nonpositives): ``\{ x \in \mathbb{R}^\mbox{dimension} : x \le 0 \}`` diff --git a/docs/src/reference/standard_form.md b/docs/src/reference/standard_form.md index d3ad803b4f..c53d9f09b3 100644 --- a/docs/src/reference/standard_form.md +++ b/docs/src/reference/standard_form.md @@ -75,7 +75,7 @@ List of recognized vector sets. ```@docs Reals Zeros -Nonnegatives +NonnegativeCone Nonpositives NormInfinityCone NormOneCone diff --git a/docs/src/submodules/Utilities/overview.md b/docs/src/submodules/Utilities/overview.md index fbeb038084..3af27e293b 100644 --- a/docs/src/submodules/Utilities/overview.md +++ b/docs/src/submodules/Utilities/overview.md @@ -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) @@ -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 diff --git a/perf/bellman_ford.jl b/perf/bellman_ford.jl index e8d4773303..33dbca162b 100644 --- a/perf/bellman_ford.jl +++ b/perf/bellman_ford.jl @@ -7,7 +7,7 @@ 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 diff --git a/src/Bridges/Constraint/flip_sign.jl b/src/Bridges/Constraint/flip_sign.jl index 4dce503b9a..5f22b8214e 100644 --- a/src/Bridges/Constraint/flip_sign.jl +++ b/src/Bridges/Constraint/flip_sign.jl @@ -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.Nonpositives, F, G} -Transforms a `G`-in-`Nonnegatives` constraint into a `F`-in-`Nonpositives` +Transforms a `G`-in-`NonnegativeCone` constraint into a `F`-in-`Nonpositives` constraint. """ mutable struct NonnegToNonposBridge{ T, F<:MOI.AbstractVectorFunction, G<:MOI.AbstractVectorFunction, -} <: FlipSignBridge{T,MOI.Nonnegatives,MOI.Nonpositives,F,G} +} <: FlipSignBridge{T,MOI.NonnegativeCone,MOI.Nonpositives,F,G} constraint::CI{F,MOI.Nonpositives} 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} @@ -163,26 +163,26 @@ end T, F<:MOI.AbstractVectorFunction, G<:MOI.AbstractVectorFunction, - } <: FlipSignBridge{T, MOI.Nonpositives, MOI.Nonnegatives, F, G} + } <: FlipSignBridge{T, MOI.Nonpositives, MOI.NonnegativeCone, F, G} -Transforms a `G`-in-`Nonpositives` constraint into a `F`-in-`Nonnegatives` +Transforms a `G`-in-`Nonpositives` 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.Nonpositives,MOI.NonnegativeCone,F,G} + constraint::CI{F,MOI.NonnegativeCone} end function MOIB.map_set(::Type{<:NonposToNonnegBridge}, set::MOI.Nonpositives) - return MOI.Nonnegatives(set.dimension) + return MOI.NonnegativeCone(set.dimension) end function MOIB.inverse_map_set( ::Type{<:NonposToNonnegBridge}, - set::MOI.Nonnegatives, + set::MOI.NonnegativeCone, ) return MOI.Nonpositives(set.dimension) end diff --git a/src/Bridges/Constraint/geomean.jl b/src/Bridges/Constraint/geomean.jl index 5616c078ff..c390f23754 100644 --- a/src/Bridges/Constraint/geomean.jl +++ b/src/Bridges/Constraint/geomean.jl @@ -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( @@ -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 @@ -147,7 +147,7 @@ function MOIB.added_constraint_types( return [ (F, MOI.LessThan{T}), (G, MOI.RotatedSecondOrderCone), - (G, MOI.Nonnegatives), + (G, MOI.NonnegativeCone), ] end @@ -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 @@ -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 diff --git a/src/Bridges/Constraint/geomean_to_relentr.jl b/src/Bridges/Constraint/geomean_to_relentr.jl index 3ed6b5a72a..05d8628f80 100644 --- a/src/Bridges/Constraint/geomean_to_relentr.jl +++ b/src/Bridges/Constraint/geomean_to_relentr.jl @@ -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 @@ -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])), @@ -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( @@ -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 @@ -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 diff --git a/src/Bridges/Constraint/interval.jl b/src/Bridges/Constraint/interval.jl index 402be7ad43..2603a5b574 100644 --- a/src/Bridges/Constraint/interval.jl +++ b/src/Bridges/Constraint/interval.jl @@ -2,7 +2,7 @@ _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) +_lower_set(set::MOI.Zeros) = MOI.NonnegativeCone(set.dimension) _upper_set(set::MOI.Zeros) = MOI.Nonpositives(set.dimension) """ @@ -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.Zeros`, `LS = MOI.NonnegativeCone` and `US = MOI.Nonpositives`. For instance, if `F` is `MOI.ScalarAffineFunction` and `S` is `MOI.Interval`, it transforms the constraint ``l ≤ ⟨a, x⟩ + α ≤ u`` into the constraints @@ -79,7 +79,7 @@ function concrete_bridge_type( F::Type{<:MOI.AbstractVectorFunction}, ::Type{MOI.Zeros}, ) where {T} - return SplitIntervalBridge{T,F,MOI.Zeros,MOI.Nonnegatives,MOI.Nonpositives} + return SplitIntervalBridge{T,F,MOI.Zeros,MOI.NonnegativeCone,MOI.Nonpositives} end # Attributes, Bridge acting as a model diff --git a/src/Bridges/Constraint/norm_to_lp.jl b/src/Bridges/Constraint/norm_to_lp.jl index fd4cf76527..66a3591444 100644 --- a/src/Bridges/Constraint/norm_to_lp.jl +++ b/src/Bridges/Constraint/norm_to_lp.jl @@ -6,8 +6,8 @@ The `NormInfinityCone` is representable with LP constraints, since ``t \\ge x_i`` and ``t \\ge -x_i`` for all ``i``. """ struct NormInfinityBridge{T,F,G} <: - SetMapBridge{T,MOI.Nonnegatives,MOI.NormInfinityCone,F,G} - constraint::CI{F,MOI.Nonnegatives} + SetMapBridge{T,MOI.NonnegativeCone,MOI.NormInfinityCone,F,G} + constraint::CI{F,MOI.NonnegativeCone} end function concrete_bridge_type( @@ -20,12 +20,12 @@ function concrete_bridge_type( end function MOIB.map_set(::Type{<:NormInfinityBridge}, set::MOI.NormInfinityCone) - return MOI.Nonnegatives(2 * (MOI.dimension(set) - 1)) + return MOI.NonnegativeCone(2 * (MOI.dimension(set) - 1)) end function MOIB.inverse_map_set( ::Type{<:NormInfinityBridge}, - set::MOI.Nonnegatives, + set::MOI.NonnegativeCone, ) return MOI.NormInfinityCone(div(MOI.dimension(set), 2) + 1) end @@ -73,7 +73,7 @@ function MOIB.inverse_adjoint_map_function( func::AbstractVector{T}, ) where {T} # This is used by `MOI.ConstraintDualStart`. - # The result should belong to `MOI.Nonnegatives` and the sum of the elements should + # The result should belong to `MOI.NonnegativeCone` and the sum of the elements should # be `t`. # Only one of dual of the upper and lower bound should be active so one of the two # duals is zero. We know which one since they should be nonnegative. @@ -95,7 +95,7 @@ The `NormOneCone` is representable with LP constraints, since """ struct NormOneBridge{T,F,G} <: AbstractBridge y::Vector{MOI.VariableIndex} - nn_index::CI{F,MOI.Nonnegatives} + nn_index::CI{F,MOI.NonnegativeCone} end function bridge_constraint( @@ -114,7 +114,7 @@ function bridge_constraint( lb = MOIU.operate!(+, T, lb, MOI.VectorOfVariables(y)) ub = MOIU.operate!(+, T, ub, MOI.VectorOfVariables(y)) f_new = MOIU.operate(vcat, T, ge, ub, lb) - nn_index = MOI.add_constraint(model, f_new, MOI.Nonnegatives(2d - 1)) + nn_index = MOI.add_constraint(model, f_new, MOI.NonnegativeCone(2d - 1)) return NormOneBridge{T,F,G}(y, nn_index) end @@ -131,7 +131,7 @@ function MOIB.added_constrained_variable_types(::Type{<:NormOneBridge}) end function MOIB.added_constraint_types(::Type{<:NormOneBridge{T,F}}) where {T,F} - return [(F, MOI.Nonnegatives)] + return [(F, MOI.NonnegativeCone)] end function concrete_bridge_type( @@ -154,14 +154,14 @@ MOI.get(b::NormOneBridge, ::MOI.NumberOfVariables) = length(b.y) MOI.get(b::NormOneBridge, ::MOI.ListOfVariableIndices) = copy(b.y) function MOI.get( b::NormOneBridge{T,F}, - ::MOI.NumberOfConstraints{F,MOI.Nonnegatives}, + ::MOI.NumberOfConstraints{F,MOI.NonnegativeCone}, ) where {T,F} return 1 end function MOI.get( b::NormOneBridge{T,F}, - ::MOI.ListOfConstraintIndices{F,MOI.Nonnegatives}, + ::MOI.ListOfConstraintIndices{F,MOI.NonnegativeCone}, ) where {T,F} return [b.nn_index] end diff --git a/src/Bridges/Variable/bridge.jl b/src/Bridges/Variable/bridge.jl index f99d3e75cf..2226ffdfc6 100644 --- a/src/Bridges/Variable/bridge.jl +++ b/src/Bridges/Variable/bridge.jl @@ -139,7 +139,7 @@ so bridges should not implement this. ## Examples As a variable in [`MathOptInterface.GreaterThan`](@ref) is bridged into -variables in [`MathOptInterface.Nonnegatives`](@ref) by the +variables in [`MathOptInterface.NonnegativeCone`](@ref) by the [`VectorizeBridge`](@ref): ```jldoctest; setup=:(using MathOptInterface; const MOI = MathOptInterface) @@ -151,7 +151,7 @@ MOI.Bridges.added_constrained_variable_types( # output 1-element Array{Tuple{DataType},1}: - (MathOptInterface.Nonnegatives,) + (MathOptInterface.NonnegativeCone,) ``` """ function MOIB.added_constrained_variable_types( @@ -214,7 +214,7 @@ is `true`. ## Examples As a variable in [`MathOptInterface.GreaterThan`](@ref) is bridged into -variables in [`MathOptInterface.Nonnegatives`](@ref) by the +variables in [`MathOptInterface.NonnegativeCone`](@ref) by the [`VectorizeBridge`](@ref): ```jldoctest; setup=:(using MathOptInterface; const MOI = MathOptInterface) @@ -225,7 +225,7 @@ MOI.Bridges.Variable.concrete_bridge_type( # output -MathOptInterface.Bridges.Variable.VectorizeBridge{Float64,MathOptInterface.Nonnegatives} +MathOptInterface.Bridges.Variable.VectorizeBridge{Float64,MathOptInterface.NonnegativeCone} ``` """ function concrete_bridge_type(bridge_type::DataType, ::Type{<:MOI.AbstractSet}) diff --git a/src/Bridges/Variable/flip_sign.jl b/src/Bridges/Variable/flip_sign.jl index 8a31a3a002..553060038a 100644 --- a/src/Bridges/Variable/flip_sign.jl +++ b/src/Bridges/Variable/flip_sign.jl @@ -11,15 +11,15 @@ abstract type FlipSignBridge{T,S1<:MOI.AbstractSet,S2<:MOI.AbstractSet} <: """ NonposToNonnegBridge{T} <: - FlipSignBridge{T, MOI.Nonpositives, MOI.Nonnegatives} + FlipSignBridge{T, MOI.Nonpositives, MOI.NonnegativeCone} Transforms constrained variables in `Nonpositives` into constrained variables in -`Nonnegatives`. +`NonnegativeCone`. """ struct NonposToNonnegBridge{T} <: - FlipSignBridge{T,MOI.Nonpositives,MOI.Nonnegatives} + FlipSignBridge{T,MOI.Nonpositives,MOI.NonnegativeCone} variables::Vector{MOI.VariableIndex} - constraint::MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.Nonnegatives} + constraint::MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.NonnegativeCone} end function MOI.delete( diff --git a/src/Bridges/Variable/free.jl b/src/Bridges/Variable/free.jl index 60720e79d9..f9b1e24e9b 100644 --- a/src/Bridges/Variable/free.jl +++ b/src/Bridges/Variable/free.jl @@ -2,11 +2,11 @@ FreeBridge{T} <: Bridges.Variable.AbstractBridge Transforms constrained variables in [`MOI.Reals`](@ref) to the difference of -constrained variables in [`MOI.Nonnegatives`](@ref). +constrained variables in [`MOI.NonnegativeCone`](@ref). """ struct FreeBridge{T} <: AbstractBridge variables::Vector{MOI.VariableIndex} - constraint::MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.Nonnegatives} + constraint::MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.NonnegativeCone} end function bridge_constrained_variable( @@ -16,7 +16,7 @@ function bridge_constrained_variable( ) where {T} variables, constraint = MOI.add_constrained_variables( model, - MOI.Nonnegatives(2MOI.dimension(set)), + MOI.NonnegativeCone(2MOI.dimension(set)), ) return FreeBridge{T}(variables, constraint) end @@ -26,7 +26,7 @@ function supports_constrained_variable(::Type{<:FreeBridge}, ::Type{MOI.Reals}) end function MOIB.added_constrained_variable_types(::Type{<:FreeBridge}) - return [(MOI.Nonnegatives,)] + return [(MOI.NonnegativeCone,)] end function MOIB.added_constraint_types(::Type{FreeBridge{T}}) where {T} @@ -44,14 +44,14 @@ end function MOI.get( ::FreeBridge, - ::MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.Nonnegatives}, + ::MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.NonnegativeCone}, ) return 1 end function MOI.get( bridge::FreeBridge, - ::MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.Nonnegatives}, + ::MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.NonnegativeCone}, ) return [bridge.constraint] end diff --git a/src/Bridges/Variable/rsoc_to_psd.jl b/src/Bridges/Variable/rsoc_to_psd.jl index 6963bcf4da..f1da3dbfe8 100644 --- a/src/Bridges/Variable/rsoc_to_psd.jl +++ b/src/Bridges/Variable/rsoc_to_psd.jl @@ -16,7 +16,7 @@ struct RSOCtoPSDBridge{T} <: AbstractBridge MOI.VectorOfVariables, MOI.PositiveSemidefiniteConeTriangle, }, - MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.Nonnegatives}, + MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.NonnegativeCone}, } off_diag::Vector{MOI.ConstraintIndex{MOI.SingleVariable,MOI.EqualTo{T}}} diag::Vector{ @@ -34,7 +34,7 @@ function bridge_constrained_variable( if set.dimension <= 2 variables, psd = MOI.add_constrained_variables( model, - MOI.Nonnegatives(set.dimension), + MOI.NonnegativeCone(set.dimension), ) else dim = set.dimension - 1 @@ -75,7 +75,7 @@ function supports_constrained_variable( end function MOIB.added_constrained_variable_types(::Type{<:RSOCtoPSDBridge}) - return [(MOI.PositiveSemidefiniteConeTriangle,), (MOI.Nonnegatives,)] + return [(MOI.PositiveSemidefiniteConeTriangle,), (MOI.NonnegativeCone,)] end function MOIB.added_constraint_types(::Type{RSOCtoPSDBridge{T}}) where {T} @@ -97,14 +97,14 @@ end function MOI.get( bridge::RSOCtoPSDBridge, ::MOI.NumberOfConstraints{MOI.VectorOfVariables,S}, -) where {S<:Union{MOI.PositiveSemidefiniteConeTriangle,MOI.Nonnegatives}} +) where {S<:Union{MOI.PositiveSemidefiniteConeTriangle,MOI.NonnegativeCone}} return bridge.psd isa MOI.ConstraintIndex{MOI.VectorOfVariables,S} ? 1 : 0 end function MOI.get( bridge::RSOCtoPSDBridge, ::MOI.ListOfConstraintIndices{MOI.VectorOfVariables,S}, -) where {S<:Union{MOI.PositiveSemidefiniteConeTriangle,MOI.Nonnegatives}} +) where {S<:Union{MOI.PositiveSemidefiniteConeTriangle,MOI.NonnegativeCone}} if bridge.psd isa MOI.ConstraintIndex{MOI.VectorOfVariables,S} return [bridge.psd] else @@ -153,7 +153,7 @@ end function MOI.get(::MOI.ModelLike, ::MOI.ConstraintSet, bridge::RSOCtoPSDBridge) if bridge.psd isa - MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.Nonnegatives} + MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.NonnegativeCone} dim = length(bridge.variables) else dim = length(bridge.diag) + 3 @@ -171,7 +171,7 @@ end function _variable_map(bridge::RSOCtoPSDBridge, i::MOIB.IndexInVector) if bridge.psd isa - MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.Nonnegatives} + MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.NonnegativeCone} return i.value elseif i.value == 1 return 1 diff --git a/src/Bridges/Variable/vectorize.jl b/src/Bridges/Variable/vectorize.jl index adf5cd5bc6..8c1f55cbc7 100644 --- a/src/Bridges/Variable/vectorize.jl +++ b/src/Bridges/Variable/vectorize.jl @@ -3,9 +3,9 @@ Transforms a constrained variable in `scalar_set_type(S, T)` where `S <: VectorLinearSet` into a constrained vector of one variable in `S`. For -instance, `VectorizeBridge{Float64, MOI.Nonnegatives}` transforms a constrained +instance, `VectorizeBridge{Float64, MOI.NonnegativeCone}` transforms a constrained variable in `MOI.GreaterThan{Float64}` into a constrained vector of one -variable in `MOI.Nonnegatives`. +variable in `MOI.NonnegativeCone`. """ mutable struct VectorizeBridge{T,S} <: AbstractBridge variable::MOI.VariableIndex diff --git a/src/Bridges/flip_sign.jl b/src/Bridges/flip_sign.jl index 89040a4152..c1cae6477b 100644 --- a/src/Bridges/flip_sign.jl +++ b/src/Bridges/flip_sign.jl @@ -1,12 +1,12 @@ const _NonnegToNonposMap{T} = Union{Variable.NonposToNonnegBridge{T},Constraint.NonnegToNonposBridge{T}} -function map_set(::Type{<:_NonnegToNonposMap}, set::MOI.Nonnegatives) +function map_set(::Type{<:_NonnegToNonposMap}, set::MOI.NonnegativeCone) return MOI.Nonpositives(set.dimension) end function inverse_map_set(::Type{<:_NonnegToNonposMap}, set::MOI.Nonpositives) - return MOI.Nonnegatives(set.dimension) + return MOI.NonnegativeCone(set.dimension) end const _FlipSignMap{T} = diff --git a/src/Bridges/lazy_bridge_optimizer.jl b/src/Bridges/lazy_bridge_optimizer.jl index a026a6aa99..20b6e14821 100644 --- a/src/Bridges/lazy_bridge_optimizer.jl +++ b/src/Bridges/lazy_bridge_optimizer.jl @@ -194,7 +194,7 @@ function node(b::LazyBridgeOptimizer, S::Type{<:MOI.AbstractSet}) if FF !== nothing # We assume the distance of the variable node `MOI.Reals` is `1`, # i.e. it is bridged by `Variable.FreeBridge` and then - # the distance of `MOI.Nonnegatives` is zero. + # the distance of `MOI.NonnegativeCone` is zero. # We also use the functionize bridge which has cost 1. # And we add `+1` as we treat constrained variables as constraints. set_variable_constraint_node( diff --git a/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl b/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl index eebe5d891a..1205666917 100644 --- a/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl +++ b/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl @@ -59,8 +59,8 @@ const BasicConstraintTests = Dict( (dummy_vectorofvariables, 2, MOI.Zeros(2)), (MOI.VectorOfVariables, MOI.Nonpositives) => (dummy_vectorofvariables, 2, MOI.Nonpositives(2)), - (MOI.VectorOfVariables, MOI.Nonnegatives) => - (dummy_vectorofvariables, 2, MOI.Nonnegatives(2)), + (MOI.VectorOfVariables, MOI.NonnegativeCone) => + (dummy_vectorofvariables, 2, MOI.NonnegativeCone(2)), (MOI.VectorOfVariables, MOI.NormInfinityCone) => (dummy_vectorofvariables, 3, MOI.NormInfinityCone(3)), (MOI.VectorOfVariables, MOI.NormOneCone) => @@ -120,8 +120,8 @@ const BasicConstraintTests = Dict( (dummy_vector_affine, 2, MOI.Zeros(2)), (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => (dummy_vector_affine, 2, MOI.Nonpositives(2)), - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => - (dummy_vector_affine, 2, MOI.Nonnegatives(2)), + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => + (dummy_vector_affine, 2, MOI.NonnegativeCone(2)), (MOI.VectorAffineFunction{Float64}, MOI.Complements) => (dummy_vector_affine, 2, MOI.Complements(2)), (MOI.VectorAffineFunction{Float64}, MOI.NormInfinityCone) => @@ -161,8 +161,8 @@ const BasicConstraintTests = Dict( (dummy_vector_quadratic, 2, MOI.Zeros(2)), (MOI.VectorQuadraticFunction{Float64}, MOI.Nonpositives) => (dummy_vector_quadratic, 2, MOI.Nonpositives(2)), - (MOI.VectorQuadraticFunction{Float64}, MOI.Nonnegatives) => - (dummy_vector_quadratic, 2, MOI.Nonnegatives(2)), + (MOI.VectorQuadraticFunction{Float64}, MOI.NonnegativeCone) => + (dummy_vector_quadratic, 2, MOI.NonnegativeCone(2)), (MOI.VectorQuadraticFunction{Float64}, MOI.NormInfinityCone) => (dummy_vector_quadratic, 3, MOI.NormInfinityCone(3)), (MOI.VectorQuadraticFunction{Float64}, MOI.NormOneCone) => diff --git a/src/DeprecatedTest/UnitTests/modifications.jl b/src/DeprecatedTest/UnitTests/modifications.jl index 7a12f2dd29..53ece3c254 100644 --- a/src/DeprecatedTest/UnitTests/modifications.jl +++ b/src/DeprecatedTest/UnitTests/modifications.jl @@ -248,7 +248,7 @@ modificationtests["solve_func_scalaraffine_lessthan"] = """ solve_func_vectoraffine_nonneg(model::MOI.ModelLike, config::Config) -Test setting the function in a VectorAffineFunction-in-Nonnegatives +Test setting the function in a VectorAffineFunction-in-NonnegativeCone constraint. If `config.solve=true` confirm that it solves correctly, and if `config.duals=true`, check that the duals are computed correctly. """ @@ -259,7 +259,7 @@ function solve_func_vectoraffine_nonneg(model::MOI.ModelLike, config::Config) """ variables: x, y minobjective: 1.0x + 2.0y - c: [1.0x, 2.0y] in Nonnegatives(2) + c: [1.0x, 2.0y] in NonnegativeCone(2) """, ) x = MOI.get(model, MOI.VariableIndex, "x") diff --git a/src/DeprecatedTest/UnitTests/variables.jl b/src/DeprecatedTest/UnitTests/variables.jl index 54c042504d..ffb3591622 100644 --- a/src/DeprecatedTest/UnitTests/variables.jl +++ b/src/DeprecatedTest/UnitTests/variables.jl @@ -97,7 +97,7 @@ function delete_nonnegative_variables(model::MOI.ModelLike, config::Config) MOI.empty!(model) @test MOI.is_empty(model) @test MOI.get(model, MOI.NumberOfVariables()) == 0 - v, cv = MOI.add_constrained_variables(model, MOI.Nonnegatives(2)) + v, cv = MOI.add_constrained_variables(model, MOI.NonnegativeCone(2)) @test MOI.get(model, MOI.NumberOfVariables()) == 2 MOI.delete(model, v) @test MOI.get(model, MOI.NumberOfVariables()) == 0 @@ -106,7 +106,7 @@ function delete_nonnegative_variables(model::MOI.ModelLike, config::Config) @test !MOI.is_valid(model, v[2]) @test_throws MOI.InvalidIndex(v[2]) MOI.delete(model, v[2]) @test !MOI.is_valid(model, cv) - v, cv = MOI.add_constrained_variables(model, MOI.Nonnegatives(1)) + v, cv = MOI.add_constrained_variables(model, MOI.NonnegativeCone(1)) @test MOI.get(model, MOI.NumberOfVariables()) == 1 MOI.delete(model, v[1]) @test !MOI.is_valid(model, v[1]) @@ -128,7 +128,7 @@ function update_dimension_nonnegative_variables( MOI.empty!(model) @test MOI.is_empty(model) @test MOI.get(model, MOI.NumberOfVariables()) == 0 - v, cv = MOI.add_constrained_variables(model, MOI.Nonnegatives(2)) + v, cv = MOI.add_constrained_variables(model, MOI.NonnegativeCone(2)) @test MOI.get(model, MOI.NumberOfVariables()) == 2 MOI.delete(model, v[1]) @test !MOI.is_valid(model, v[1]) @@ -137,7 +137,7 @@ function update_dimension_nonnegative_variables( @test MOI.is_valid(model, v[2]) @test MOI.get(model, MOI.ConstraintFunction(), cv) == MOI.VectorOfVariables([v[2]]) - @test MOI.get(model, MOI.ConstraintSet(), cv) == MOI.Nonnegatives(1) + @test MOI.get(model, MOI.ConstraintSet(), cv) == MOI.NonnegativeCone(1) MOI.delete(model, v[2]) @test MOI.get(model, MOI.NumberOfVariables()) == 0 @test !MOI.is_valid(model, v[1]) diff --git a/src/DeprecatedTest/contconic.jl b/src/DeprecatedTest/contconic.jl index 0f395532a4..ec50c643c4 100644 --- a/src/DeprecatedTest/contconic.jl +++ b/src/DeprecatedTest/contconic.jl @@ -20,13 +20,13 @@ function _lin1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) @test MOI.supports_constraint( model, MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) else @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) end @test MOI.supports_constraint( @@ -40,12 +40,12 @@ function _lin1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) @test MOI.get(model, MOI.NumberOfVariables()) == 3 vov = MOI.VectorOfVariables(v) if vecofvars - vc = MOI.add_constraint(model, vov, MOI.Nonnegatives(3)) + vc = MOI.add_constraint(model, vov, MOI.NonnegativeCone(3)) else vc = MOI.add_constraint( model, MOI.VectorAffineFunction{Float64}(vov), - MOI.Nonnegatives(3), + MOI.NonnegativeCone(3), ) end c = MOI.add_constraint( @@ -65,7 +65,7 @@ function _lin1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) MOI.NumberOfConstraints{ vecofvars ? MOI.VectorOfVariables : MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 @test MOI.get( @@ -80,7 +80,7 @@ function _lin1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) @test length(loc) == 2 @test ( vecofvars ? MOI.VectorOfVariables : MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) in loc @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc MOI.set( @@ -133,7 +133,7 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) #@test MOI.supportsproblem(model, MOI.ScalarAffineFunction{Float64}, #[ # (MOI.VectorAffineFunction{Float64},MOI.Zeros), - # (MOI.VectorOfVariables,MOI.Nonnegatives), + # (MOI.VectorOfVariables,MOI.NonnegativeCone), # (MOI.VectorOfVariables,MOI.Nonpositives) #]) # mixed cones @@ -157,7 +157,7 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) @test MOI.supports_constraint( model, MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @test MOI.supports_add_constrained_variables(model, MOI.Nonpositives) @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.Zeros) @@ -165,7 +165,7 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @test MOI.supports_constraint( model, @@ -218,7 +218,7 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) ) if vecofvars # test fallback - vz = MOI.add_constraint(model, [z], MOI.Nonnegatives(1)) + vz = MOI.add_constraint(model, [z], MOI.NonnegativeCone(1)) else vz = MOI.add_constraint( model, @@ -226,7 +226,7 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, z))], [0.0], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) end vov = MOI.VectorOfVariables([s]) @@ -260,7 +260,7 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) MOI.NumberOfConstraints{ vecofvars ? MOI.VectorOfVariables : MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 end @@ -338,7 +338,7 @@ function lin3test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) MOI.empty!(model) @test MOI.is_empty(model) @@ -349,7 +349,7 @@ function lin3test(model::MOI.ModelLike, config::Config) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) MOI.add_constraint( model, @@ -364,7 +364,7 @@ function lin3test(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 @test MOI.get( @@ -417,7 +417,7 @@ function lin4test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @test MOI.supports_add_constrained_variables(model, MOI.Nonpositives) MOI.empty!(model) @@ -430,14 +430,14 @@ function lin4test(model::MOI.ModelLike, config::Config) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) if config.query_number_of_constraints @test MOI.get( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 @test MOI.get( @@ -633,7 +633,7 @@ function norminf2test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @test MOI.supports_constraint( model, @@ -654,7 +654,7 @@ function norminf2test(model::MOI.ModelLike, config::Config) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, y))], [-2.0], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) MOI.add_constraint( model, @@ -677,7 +677,7 @@ function norminf2test(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 @test MOI.get( @@ -715,7 +715,7 @@ function norminf3test(model::MOI.ModelLike, config::Config) # Problem NormInf3 # min x # st (-1 + x, 2 .+ y) in NormInf(1 + n) - # (1 .+ y) in Nonnegatives(n) + # (1 .+ y) in NonnegativeCone(n) # let n = 3. optimal solution: y .= -1, x = 2 @test MOI.supports_incremental_interface(model, false) #=copy_names=# @test MOI.supports(model, MOI.ObjectiveFunction{MOI.SingleVariable}()) @@ -744,7 +744,7 @@ function norminf3test(model::MOI.ModelLike, config::Config) MOI.VectorAffineTerm.(1:3, MOI.ScalarAffineTerm.(1.0, y)), ones(3), ) - nonneg = MOI.add_constraint(model, nonneg_vaf, MOI.Nonnegatives(3)) + nonneg = MOI.add_constraint(model, nonneg_vaf, MOI.NonnegativeCone(3)) if config.query_number_of_constraints @test MOI.get( model, @@ -757,14 +757,14 @@ function norminf3test(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 end loc = MOI.get(model, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 2 @test (MOI.VectorAffineFunction{Float64}, MOI.NormInfinityCone) in loc - @test (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) in loc if config.solve @test MOI.get(model, MOI.TerminationStatus()) == MOI.OPTIMIZE_NOT_CALLED MOI.optimize!(model) @@ -956,7 +956,7 @@ function normone2test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @test MOI.supports_constraint( model, @@ -977,7 +977,7 @@ function normone2test(model::MOI.ModelLike, config::Config) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, y))], [-2.0], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) MOI.add_constraint( model, @@ -1000,7 +1000,7 @@ function normone2test(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 @test MOI.get( @@ -1038,7 +1038,7 @@ function normone3test(model::MOI.ModelLike, config::Config) # Problem NormOne3 # min x # st (-1 + x, 2 .+ y) in NormOne(1 + n) - # (1 .+ y) in Nonnegatives(n) + # (1 .+ y) in NonnegativeCone(n) # let n = 3. optimal solution: y .= -1, x = 4 @test MOI.supports_incremental_interface(model, false) #=copy_names=# @test MOI.supports(model, MOI.ObjectiveFunction{MOI.SingleVariable}()) @@ -1067,7 +1067,7 @@ function normone3test(model::MOI.ModelLike, config::Config) MOI.VectorAffineTerm.(1:3, MOI.ScalarAffineTerm.(1.0, y)), ones(3), ) - nonneg = MOI.add_constraint(model, nonneg_vaf, MOI.Nonnegatives(3)) + nonneg = MOI.add_constraint(model, nonneg_vaf, MOI.NonnegativeCone(3)) if config.query_number_of_constraints @test MOI.get( model, @@ -1080,14 +1080,14 @@ function normone3test(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 end loc = MOI.get(model, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 2 @test (MOI.VectorAffineFunction{Float64}, MOI.NormOneCone) in loc - @test (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) in loc if config.solve @test MOI.get(model, MOI.TerminationStatus()) == MOI.OPTIMIZE_NOT_CALLED MOI.optimize!(model) @@ -1271,7 +1271,7 @@ function _soc2test(model::MOI.ModelLike, config::Config, nonneg::Bool) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) else @test MOI.supports_constraint( @@ -1301,7 +1301,7 @@ function _soc2test(model::MOI.ModelLike, config::Config, nonneg::Bool) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, y))], [-1 / √2], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) else cnon = MOI.add_constraint( @@ -1337,7 +1337,7 @@ function _soc2test(model::MOI.ModelLike, config::Config, nonneg::Bool) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - nonneg ? MOI.Nonnegatives : MOI.Nonpositives, + nonneg ? MOI.NonnegativeCone : MOI.Nonpositives, }(), ) == 1 @test MOI.get( @@ -1421,7 +1421,7 @@ function soc3test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @test MOI.supports_constraint( model, @@ -1442,7 +1442,7 @@ function soc3test(model::MOI.ModelLike, config::Config) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, y))], [-2.0], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) MOI.add_constraint( model, @@ -1465,7 +1465,7 @@ function soc3test(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 @test MOI.get( @@ -1882,7 +1882,7 @@ function rotatedsoc3test(model::MOI.ModelLike, config::Config; n = 2, ub = 3.0) MOI.SingleVariable, MOI.EqualTo{Float64}, ) - @test MOI.supports_add_constrained_variables(model, MOI.Nonnegatives) + @test MOI.supports_add_constrained_variables(model, MOI.NonnegativeCone) @test MOI.supports_constraint( model, MOI.SingleVariable, @@ -1900,7 +1900,7 @@ function rotatedsoc3test(model::MOI.ModelLike, config::Config; n = 2, ub = 3.0) ) MOI.empty!(model) @test MOI.is_empty(model) - x, cx = MOI.add_constrained_variables(model, MOI.Nonnegatives(n)) + x, cx = MOI.add_constrained_variables(model, MOI.NonnegativeCone(n)) u = MOI.add_variable(model) v = MOI.add_variable(model) t = MOI.add_variables(model, 2) @@ -1941,7 +1941,7 @@ function rotatedsoc3test(model::MOI.ModelLike, config::Config; n = 2, ub = 3.0) ) == 2 @test MOI.get( model, - MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.Nonnegatives}(), + MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.NonnegativeCone}(), ) == 1 @test MOI.get( model, @@ -2594,7 +2594,7 @@ function exp2test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) MOI.empty!(model) @test MOI.is_empty(model) @@ -2642,7 +2642,7 @@ function exp2test(model::MOI.ModelLike, config::Config) ), zeros(3), ), - MOI.Nonnegatives(3), + MOI.NonnegativeCone(3), ) c3 = MOI.add_constraint( model, @@ -2656,7 +2656,7 @@ function exp2test(model::MOI.ModelLike, config::Config) ), zeros(3), ), - MOI.Nonnegatives(3), + MOI.NonnegativeCone(3), ) c4 = MOI.add_constraint( model, @@ -4221,7 +4221,7 @@ function _det1test( @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) MOI.empty!(model) @test MOI.is_empty(model) @@ -4255,7 +4255,7 @@ function _det1test( ), ones(2), ), - MOI.Nonnegatives(2), + MOI.NonnegativeCone(2), ) if config.query_number_of_constraints @test MOI.get( @@ -4270,7 +4270,7 @@ function _det1test( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 end diff --git a/src/DeprecatedTest/contlinear.jl b/src/DeprecatedTest/contlinear.jl index e524740993..cf255e18d3 100644 --- a/src/DeprecatedTest/contlinear.jl +++ b/src/DeprecatedTest/contlinear.jl @@ -7,7 +7,7 @@ function linear1test(model::MOI.ModelLike, config::Config{T}) where {T} # simple 2 variable, 1 constraint problem # min -x # st x + y <= 1 (x + y - 1 ∈ Nonpositives) - # x, y >= 0 (x, y ∈ Nonnegatives) + # x, y >= 0 (x, y ∈ NonnegativeCone) @test MOI.supports_incremental_interface(model, false) #=copy_names=# @test MOI.supports( model, @@ -1052,7 +1052,7 @@ function linear6test(model::MOI.ModelLike, config::Config{T}) where {T} end end -# Modify constants in Nonnegatives and Nonpositives +# Modify constants in NonnegativeCone and Nonpositives function linear7test(model::MOI.ModelLike, config::Config{T}) where {T} atol = config.atol rtol = config.rtol @@ -1081,7 +1081,7 @@ function linear7test(model::MOI.ModelLike, config::Config{T}) where {T} @test MOI.supports_constraint( model, MOI.VectorAffineFunction{T}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @test MOI.supports_constraint( model, @@ -1110,7 +1110,7 @@ function linear7test(model::MOI.ModelLike, config::Config{T}) where {T} [MOI.VectorAffineTerm{T}(1, MOI.ScalarAffineTerm{T}(one(T), x))], [zero(T)], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) c2 = MOI.add_constraint( model, @@ -1150,7 +1150,7 @@ function linear7test(model::MOI.ModelLike, config::Config{T}) where {T} ], [-T(100)], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) end if config.solve diff --git a/src/DeprecatedTest/contquadratic.jl b/src/DeprecatedTest/contquadratic.jl index 1c019497a3..35fb1cd7f3 100644 --- a/src/DeprecatedTest/contquadratic.jl +++ b/src/DeprecatedTest/contquadratic.jl @@ -371,7 +371,7 @@ function qcp1test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @test MOI.supports_constraint( model, @@ -392,14 +392,14 @@ function qcp1test(model::MOI.ModelLike, config::Config) ), [0.0, 0.0], ), - MOI.Nonnegatives(2), + MOI.NonnegativeCone(2), ) if config.query_number_of_constraints @test MOI.get( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 end diff --git a/src/DeprecatedTest/modellike.jl b/src/DeprecatedTest/modellike.jl index f617171bcb..7ab6b3c5d5 100644 --- a/src/DeprecatedTest/modellike.jl +++ b/src/DeprecatedTest/modellike.jl @@ -350,10 +350,10 @@ function emptytest(model::MOI.ModelLike) @test MOI.supports_constraint( model, MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) vc = - MOI.add_constraint(model, MOI.VectorOfVariables(v), MOI.Nonnegatives(3)) + MOI.add_constraint(model, MOI.VectorOfVariables(v), MOI.NonnegativeCone(3)) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, @@ -385,7 +385,7 @@ function emptytest(model::MOI.ModelLike) @test MOI.get(model, MOI.NumberOfVariables()) == 0 @test MOI.get( model, - MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.Nonnegatives}(), + MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.NonnegativeCone}(), ) == 0 @test MOI.get( model, @@ -536,10 +536,10 @@ function start_values_unset_test(model::MOI.ModelLike, config) c = MOI.add_constraint( model, MOIU.operate(vcat, Float64, 2.0fz + 1.0), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) F2 = MOI.VectorAffineFunction{Float64} - S2 = MOI.Nonnegatives + S2 = MOI.NonnegativeCone vpattr = MOI.VariablePrimalStart() cpattr = MOI.ConstraintPrimalStart() cdattr = MOI.ConstraintDualStart() @@ -633,10 +633,10 @@ function start_values_test(dest::MOI.ModelLike, src::MOI.ModelLike) c = MOI.add_constraint( src, MOIU.operate(vcat, Float64, 2.0fz + 1.0), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) F2 = MOI.VectorAffineFunction{Float64} - S2 = MOI.Nonnegatives + S2 = MOI.NonnegativeCone vpattr = MOI.VariablePrimalStart() cpattr = MOI.ConstraintPrimalStart() cdattr = MOI.ConstraintDualStart() @@ -711,7 +711,7 @@ function copytest(dest::MOI.ModelLike, src::MOI.ModelLike; copy_names = false) # We test this after the creation of every `SingleVariable` constraint # to ensure a good coverage of corner cases. @test csv.value == w.value - cvv = MOI.add_constraint(src, MOI.VectorOfVariables(v), MOI.Nonnegatives(3)) + cvv = MOI.add_constraint(src, MOI.VectorOfVariables(v), MOI.NonnegativeCone(3)) MOI.set(src, MOI.ConstraintName(), cvv, "cvv") csa = MOI.add_constraint( src, @@ -752,7 +752,7 @@ function copytest(dest::MOI.ModelLike, src::MOI.ModelLike; copy_names = false) MOI.SingleVariable, MOI.EqualTo{Float64}, ) - @test MOI.supports_constraint(dest, MOI.VectorOfVariables, MOI.Nonnegatives) + @test MOI.supports_constraint(dest, MOI.VectorOfVariables, MOI.NonnegativeCone) @test MOI.supports_constraint( dest, MOI.ScalarAffineFunction{Float64}, @@ -783,11 +783,11 @@ function copytest(dest::MOI.ModelLike, src::MOI.ModelLike; copy_names = false) ) == [dict[csv]] @test MOI.get( dest, - MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.Nonnegatives}(), + MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.NonnegativeCone}(), ) == 1 @test MOI.get( dest, - MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.Nonnegatives}(), + MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.NonnegativeCone}(), ) == [dict[cvv]] @test MOI.get( dest, @@ -817,7 +817,7 @@ function copytest(dest::MOI.ModelLike, src::MOI.ModelLike; copy_names = false) loc = MOI.get(dest, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 4 @test (MOI.SingleVariable, MOI.EqualTo{Float64}) in loc - @test (MOI.VectorOfVariables, MOI.Nonnegatives) in loc + @test (MOI.VectorOfVariables, MOI.NonnegativeCone) in loc @test (MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64}) in loc @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc @test MOI.get(dest, MOI.ConstraintFunction(), dict[csv]) == @@ -827,7 +827,7 @@ function copytest(dest::MOI.ModelLike, src::MOI.ModelLike; copy_names = false) MOI.get(dest, MOI.ConstraintName(), dict[cvv]) == dest_name("cvv") @test MOI.get(dest, MOI.ConstraintFunction(), dict[cvv]) == MOI.VectorOfVariables(getindex.(Ref(dict), v)) - @test MOI.get(dest, MOI.ConstraintSet(), dict[cvv]) == MOI.Nonnegatives(3) + @test MOI.get(dest, MOI.ConstraintSet(), dict[cvv]) == MOI.NonnegativeCone(3) @test !MOI.supports(dest, MOI.ConstraintName(), typeof(csa)) || MOI.get(dest, MOI.ConstraintName(), dict[csa]) == dest_name("csa") @test MOI.get(dest, MOI.ConstraintFunction(), dict[csa]) ≈ diff --git a/src/FileFormats/CBF/CBF.jl b/src/FileFormats/CBF/CBF.jl index abe06e34a1..8687359ffa 100644 --- a/src/FileFormats/CBF/CBF.jl +++ b/src/FileFormats/CBF/CBF.jl @@ -12,7 +12,7 @@ MOI.Utilities.@model( ( MOI.Reals, MOI.Zeros, - MOI.Nonnegatives, + MOI.NonnegativeCone, MOI.Nonpositives, MOI.SecondOrderCone, MOI.RotatedSecondOrderCone, diff --git a/src/FileFormats/CBF/read.jl b/src/FileFormats/CBF/read.jl index 854606330b..c0401e202c 100644 --- a/src/FileFormats/CBF/read.jl +++ b/src/FileFormats/CBF/read.jl @@ -65,7 +65,7 @@ function _cbf_to_moi_cone( elseif cone_str == "L-" return MOI.Nonpositives(cone_dim) elseif cone_str == "L+" - return MOI.Nonnegatives(cone_dim) + return MOI.NonnegativeCone(cone_dim) elseif cone_str == "Q" @assert cone_dim >= 2 return MOI.SecondOrderCone(cone_dim) diff --git a/src/FileFormats/CBF/write.jl b/src/FileFormats/CBF/write.jl index ae6dd50e26..2fd59d8d09 100644 --- a/src/FileFormats/CBF/write.jl +++ b/src/FileFormats/CBF/write.jl @@ -30,7 +30,7 @@ end _cone_string(::Any, ::Type{MOI.Zeros}) = "L=" _cone_string(::Any, ::Type{MOI.Reals}) = "F" -_cone_string(::Any, ::Type{MOI.Nonnegatives}) = "L+" +_cone_string(::Any, ::Type{MOI.NonnegativeCone}) = "L+" _cone_string(::Any, ::Type{MOI.Nonpositives}) = "L-" _cone_string(::Any, ::Type{MOI.SecondOrderCone}) = "Q" _cone_string(::Any, ::Type{MOI.RotatedSecondOrderCone}) = "QR" @@ -182,7 +182,7 @@ function _CBFDataStructure(model::Model) for S in ( MOI.Zeros, MOI.Reals, - MOI.Nonnegatives, + MOI.NonnegativeCone, MOI.Nonpositives, MOI.SecondOrderCone, MOI.RotatedSecondOrderCone, diff --git a/src/FileFormats/MOF/MOF.jl b/src/FileFormats/MOF/MOF.jl index 6aa24518ac..9de16d2f23 100644 --- a/src/FileFormats/MOF/MOF.jl +++ b/src/FileFormats/MOF/MOF.jl @@ -38,7 +38,7 @@ MOI.Utilities.@model( ( MOI.Reals, MOI.Zeros, - MOI.Nonnegatives, + MOI.NonnegativeCone, MOI.Nonpositives, MOI.SecondOrderCone, MOI.RotatedSecondOrderCone, diff --git a/src/FileFormats/MOF/mof.0.6.schema.json b/src/FileFormats/MOF/mof.0.6.schema.json index 031e10ab37..a9a7809f8c 100644 --- a/src/FileFormats/MOF/mof.0.6.schema.json +++ b/src/FileFormats/MOF/mof.0.6.schema.json @@ -654,11 +654,11 @@ } }, { "description": "R₊^{dimension}", - "examples": ["{\"type\": \"Nonnegatives\", \"dimension\": 3}"], + "examples": ["{\"type\": \"NonnegativeCone\", \"dimension\": 3}"], "required": ["dimension"], "properties": { "type": { - "const": "Nonnegatives" + "const": "NonnegativeCone" }, "dimension": { "type": "integer", diff --git a/src/FileFormats/MOF/read.jl b/src/FileFormats/MOF/read.jl index 15f9bbafb9..4d86dc63fb 100644 --- a/src/FileFormats/MOF/read.jl +++ b/src/FileFormats/MOF/read.jl @@ -289,7 +289,7 @@ end Semicontinuous, Zeros, Reals, - Nonnegatives, + NonnegativeCone, Nonpositives, SecondOrderCone, RotatedSecondOrderCone, @@ -375,8 +375,8 @@ function set_to_moi(::Val{:Reals}, object::Object) return MOI.Reals(object["dimension"]) end -function set_to_moi(::Val{:Nonnegatives}, object::Object) - return MOI.Nonnegatives(object["dimension"]) +function set_to_moi(::Val{:NonnegativeCone}, object::Object) + return MOI.NonnegativeCone(object["dimension"]) end function set_to_moi(::Val{:Nonpositives}, object::Object) diff --git a/src/FileFormats/MOF/write.jl b/src/FileFormats/MOF/write.jl index 675eb3f3c8..30b4bcf445 100644 --- a/src/FileFormats/MOF/write.jl +++ b/src/FileFormats/MOF/write.jl @@ -264,7 +264,7 @@ head_name(::Type{<:MOI.Semicontinuous}) = "Semicontinuous" # ========== Non-typed vector sets ========== head_name(::Type{MOI.Zeros}) = "Zeros" head_name(::Type{MOI.Reals}) = "Reals" -head_name(::Type{MOI.Nonnegatives}) = "Nonnegatives" +head_name(::Type{MOI.NonnegativeCone}) = "NonnegativeCone" head_name(::Type{MOI.Nonpositives}) = "Nonpositives" head_name(::Type{MOI.SecondOrderCone}) = "SecondOrderCone" head_name(::Type{MOI.RotatedSecondOrderCone}) = "RotatedSecondOrderCone" diff --git a/src/FileFormats/SDPA/SDPA.jl b/src/FileFormats/SDPA/SDPA.jl index a85e75cfb6..bcc7a819bf 100644 --- a/src/FileFormats/SDPA/SDPA.jl +++ b/src/FileFormats/SDPA/SDPA.jl @@ -11,7 +11,7 @@ MOI.Utilities.@model( Model, (), (), - (MOI.Nonnegatives, MOI.PositiveSemidefiniteConeTriangle), + (MOI.NonnegativeCone, MOI.PositiveSemidefiniteConeTriangle), (), (), (), @@ -110,7 +110,7 @@ function Base.write(io::IO, model::Model{T}) where {T} end end - nonneg = model_cons(MOI.VectorAffineFunction{T}, MOI.Nonnegatives) + nonneg = model_cons(MOI.VectorAffineFunction{T}, MOI.NonnegativeCone) psd = model_cons( MOI.VectorAffineFunction{T}, MOI.PositiveSemidefiniteConeTriangle, @@ -252,7 +252,7 @@ function Base.read!(io::IO, model::Model{T}) where {T} if block_dim > 0 return MOI.PositiveSemidefiniteConeTriangle(block_dim) else - return MOI.Nonnegatives(-block_dim) + return MOI.NonnegativeCone(-block_dim) end end objective_read = false diff --git a/src/Test/test_basic_constraint.jl b/src/Test/test_basic_constraint.jl index 842c6da500..a8ae4ed86c 100644 --- a/src/Test/test_basic_constraint.jl +++ b/src/Test/test_basic_constraint.jl @@ -79,7 +79,7 @@ _set(::Type{T}, ::Type{MOI.SOS1}) where {T} = MOI.SOS1(convert.(T, 1:2)) _set(::Type{T}, ::Type{MOI.SOS2}) where {T} = MOI.SOS2(convert.(T, 1:2)) _set(::Type{MOI.Zeros}) = MOI.Zeros(2) _set(::Type{MOI.Nonpositives}) = MOI.Nonpositives(2) -_set(::Type{MOI.Nonnegatives}) = MOI.Nonnegatives(2) +_set(::Type{MOI.NonnegativeCone}) = MOI.NonnegativeCone(2) _set(::Type{MOI.NormInfinityCone}) = MOI.NormInfinityCone(3) _set(::Type{MOI.NormOneCone}) = MOI.NormOneCone(3) _set(::Type{MOI.SecondOrderCone}) = MOI.SecondOrderCone(3) @@ -225,7 +225,7 @@ for s in [ :SOS2, :Zeros, :Nonpositives, - :Nonnegatives, + :NonnegativeCone, :NormInfinityCone, :NormOneCone, :SecondOrderCone, diff --git a/src/Test/test_conic.jl b/src/Test/test_conic.jl index c8176d3222..b14cef73f4 100644 --- a/src/Test/test_conic.jl +++ b/src/Test/test_conic.jl @@ -33,13 +33,13 @@ function _test_conic_linear_helper( @requires MOI.supports_constraint( model, MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) else @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) end @requires MOI.supports_constraint( @@ -51,12 +51,12 @@ function _test_conic_linear_helper( @test MOI.get(model, MOI.NumberOfVariables()) == 3 vov = MOI.VectorOfVariables(v) if use_VectorOfVariables - vc = MOI.add_constraint(model, vov, MOI.Nonnegatives(3)) + vc = MOI.add_constraint(model, vov, MOI.NonnegativeCone(3)) else vc = MOI.add_constraint( model, MOI.VectorAffineFunction{Float64}(vov), - MOI.Nonnegatives(3), + MOI.NonnegativeCone(3), ) end c = MOI.add_constraint( @@ -76,7 +76,7 @@ function _test_conic_linear_helper( MOI.NumberOfConstraints{ use_VectorOfVariables ? MOI.VectorOfVariables : MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 @test MOI.get( @@ -92,7 +92,7 @@ function _test_conic_linear_helper( @test ( use_VectorOfVariables ? MOI.VectorOfVariables : MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) in loc @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc MOI.set( @@ -185,7 +185,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1.0, 0.0, 2.0], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0, 2, 0]], (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-3, -1]], ), @@ -233,7 +233,7 @@ function _test_conic_linear_helper_2( @requires MOI.supports_constraint( model, MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @requires MOI.supports_add_constrained_variables( model, @@ -248,7 +248,7 @@ function _test_conic_linear_helper_2( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @requires MOI.supports_constraint( model, @@ -299,7 +299,7 @@ function _test_conic_linear_helper_2( ) if use_VectorOfVariables # test fallback - vz = MOI.add_constraint(model, [z], MOI.Nonnegatives(1)) + vz = MOI.add_constraint(model, [z], MOI.NonnegativeCone(1)) else vz = MOI.add_constraint( model, @@ -307,7 +307,7 @@ function _test_conic_linear_helper_2( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, z))], [0.0], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) end vov = MOI.VectorOfVariables([s]) @@ -341,7 +341,7 @@ function _test_conic_linear_helper_2( MOI.NumberOfConstraints{ use_VectorOfVariables ? MOI.VectorOfVariables : MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 end @@ -446,7 +446,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [-4, -3, 16, 0], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => [[0]], + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0]], (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => [[0]], (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[7, 2, -4], [7]], @@ -482,7 +482,7 @@ function test_conic_linear_INFEASIBLE(model::MOI.ModelLike, config::Config) @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) x = MOI.add_variable(model) MOI.add_constraint( @@ -491,7 +491,7 @@ function test_conic_linear_INFEASIBLE(model::MOI.ModelLike, config::Config) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) MOI.add_constraint( model, @@ -506,7 +506,7 @@ function test_conic_linear_INFEASIBLE(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 @test MOI.get( @@ -566,7 +566,7 @@ function test_conic_linear_INFEASIBLE_2(model::MOI.ModelLike, config::Config) @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @requires MOI.supports_add_constrained_variables(model, MOI.Nonpositives) @@ -578,14 +578,14 @@ function test_conic_linear_INFEASIBLE_2(model::MOI.ModelLike, config::Config) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) if _supports(config, MOI.NumberOfConstraints) @test MOI.get( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 @test MOI.get( @@ -864,7 +864,7 @@ function test_conic_NormInfinityCone_INFEASIBLE( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @requires MOI.supports_constraint( model, @@ -884,7 +884,7 @@ function test_conic_NormInfinityCone_INFEASIBLE( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, y))], [-2.0], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) MOI.add_constraint( model, @@ -907,7 +907,7 @@ function test_conic_NormInfinityCone_INFEASIBLE( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 @test MOI.get( @@ -960,7 +960,7 @@ Test the problem: ``` min x st (-1 + x, 2 .+ y) in NormInf(1 + n) - (1 .+ y) in Nonnegatives(n) + (1 .+ y) in NonnegativeCone(n) let n = 3. optimal solution: y .= -1, x = 2 ``` """ @@ -993,7 +993,7 @@ function test_conic_NormInfinityCone_3(model::MOI.ModelLike, config::Config) MOI.VectorAffineTerm.(1:3, MOI.ScalarAffineTerm.(1.0, y)), ones(3), ) - nonneg = MOI.add_constraint(model, nonneg_vaf, MOI.Nonnegatives(3)) + nonneg = MOI.add_constraint(model, nonneg_vaf, MOI.NonnegativeCone(3)) if _supports(config, MOI.NumberOfConstraints) @test MOI.get( model, @@ -1006,14 +1006,14 @@ function test_conic_NormInfinityCone_3(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 end loc = MOI.get(model, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 2 @test (MOI.VectorAffineFunction{Float64}, MOI.NormInfinityCone) in loc - @test (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) in loc if _supports(config, MOI.optimize!) @test MOI.get(model, MOI.TerminationStatus()) == MOI.OPTIMIZE_NOT_CALLED MOI.optimize!(model) @@ -1058,7 +1058,7 @@ function setup_test( [2, -1, -1, -1], (MOI.VectorAffineFunction{Float64}, MOI.NormInfinityCone) => [vcat(1, fill(-inv(3), 3))], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [fill(inv(3), 3)], ), ) @@ -1291,7 +1291,7 @@ function test_conic_NormOneCone_INFEASIBLE(model::MOI.ModelLike, config::Config) @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @requires MOI.supports_constraint( model, @@ -1311,7 +1311,7 @@ function test_conic_NormOneCone_INFEASIBLE(model::MOI.ModelLike, config::Config) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, y))], [-2.0], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) MOI.add_constraint( model, @@ -1334,7 +1334,7 @@ function test_conic_NormOneCone_INFEASIBLE(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 @test MOI.get( @@ -1387,7 +1387,7 @@ Test the following problem: ``` min x st (-1 + x, 2 .+ y) in NormOne(1 + n) - (1 .+ y) in Nonnegatives(n) + (1 .+ y) in NonnegativeCone(n) let n = 3. optimal solution: y .= -1, x = 4 ``` """ @@ -1425,7 +1425,7 @@ function test_conic_NormOneCone(model::MOI.ModelLike, config::Config) MOI.VectorAffineTerm.(1:3, MOI.ScalarAffineTerm.(1.0, y)), ones(3), ) - nonneg = MOI.add_constraint(model, nonneg_vaf, MOI.Nonnegatives(3)) + nonneg = MOI.add_constraint(model, nonneg_vaf, MOI.NonnegativeCone(3)) if _supports(config, MOI.NumberOfConstraints) @test MOI.get( model, @@ -1438,14 +1438,14 @@ function test_conic_NormOneCone(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 end loc = MOI.get(model, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 2 @test (MOI.VectorAffineFunction{Float64}, MOI.NormOneCone) in loc - @test (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) in loc if _supports(config, MOI.optimize!) @test MOI.get(model, MOI.TerminationStatus()) == MOI.OPTIMIZE_NOT_CALLED MOI.optimize!(model) @@ -1489,7 +1489,7 @@ function setup_test( [4, -1, -1, -1], (MOI.VectorAffineFunction{Float64}, MOI.NormOneCone) => [vcat(1, fill(-1, 3))], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [ones(3)], ), ) @@ -1722,7 +1722,7 @@ function _test_conic_SecondOrderCone_helper_2( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) else @requires MOI.supports_constraint( @@ -1751,7 +1751,7 @@ function _test_conic_SecondOrderCone_helper_2( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, y))], [-1 / √2], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) else cnon = MOI.add_constraint( @@ -1787,7 +1787,7 @@ function _test_conic_SecondOrderCone_helper_2( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - nonneg ? MOI.Nonnegatives : MOI.Nonpositives, + nonneg ? MOI.NonnegativeCone : MOI.Nonpositives, }(), ) == 1 @test MOI.get( @@ -1849,7 +1849,7 @@ end config::Config, ) -Test a SecondOrderCone with Nonnegatives constraints. +Test a SecondOrderCone with NonnegativeCone constraints. """ function test_conic_SecondOrderCone_Nonnegatives( model::MOI.ModelLike, @@ -1872,7 +1872,7 @@ function setup_test( (MOI.VectorAffineFunction{Float64}, MOI.SecondOrderCone) => [[√2, 1, -1]], (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[√2]], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1.0]], ), ) @@ -1949,7 +1949,7 @@ function test_conic_SecondOrderCone_INFEASIBLE( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @requires MOI.supports_constraint( model, @@ -1969,7 +1969,7 @@ function test_conic_SecondOrderCone_INFEASIBLE( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, y))], [-2.0], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) MOI.add_constraint( model, @@ -1992,7 +1992,7 @@ function test_conic_SecondOrderCone_INFEASIBLE( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 @test MOI.get( @@ -2531,7 +2531,7 @@ function test_conic_RotatedSecondOrderCone_INFEASIBLE_2( MOI.SingleVariable, MOI.EqualTo{Float64}, ) - @requires MOI.supports_add_constrained_variables(model, MOI.Nonnegatives) + @requires MOI.supports_add_constrained_variables(model, MOI.NonnegativeCone) @requires MOI.supports_constraint( model, MOI.SingleVariable, @@ -2548,7 +2548,7 @@ function test_conic_RotatedSecondOrderCone_INFEASIBLE_2( MOI.RotatedSecondOrderCone, ) - x, cx = MOI.add_constrained_variables(model, MOI.Nonnegatives(n)) + x, cx = MOI.add_constrained_variables(model, MOI.NonnegativeCone(n)) u = MOI.add_variable(model) v = MOI.add_variable(model) t = MOI.add_variables(model, 2) @@ -2589,7 +2589,7 @@ function test_conic_RotatedSecondOrderCone_INFEASIBLE_2( ) == 2 @test MOI.get( model, - MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.Nonnegatives}(), + MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.NonnegativeCone}(), ) == 1 @test MOI.get( model, @@ -2693,7 +2693,7 @@ function setup_test( [1.0; zeros(n - 1); ub; √ub; ones(2)], (MOI.SingleVariable, MOI.EqualTo{Float64}) => [-√ub / 4, -√ub / 4], - (MOI.VectorOfVariables, MOI.Nonnegatives) => [zeros(n)], + (MOI.VectorOfVariables, MOI.NonnegativeCone) => [zeros(n)], (MOI.SingleVariable, MOI.GreaterThan{Float64}) => [0.0], (MOI.SingleVariable, MOI.LessThan{Float64}) => [-1 / (2 * √ub)], (MOI.VectorAffineFunction{Float64}, MOI.RotatedSecondOrderCone) => [ @@ -3510,7 +3510,7 @@ function test_conic_Exponential_hard_2(model::MOI.ModelLike, config::Config) @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) v = MOI.add_variables(model, 9) @@ -3557,7 +3557,7 @@ function test_conic_Exponential_hard_2(model::MOI.ModelLike, config::Config) ), zeros(3), ), - MOI.Nonnegatives(3), + MOI.NonnegativeCone(3), ) c3 = MOI.add_constraint( model, @@ -3571,7 +3571,7 @@ function test_conic_Exponential_hard_2(model::MOI.ModelLike, config::Config) ), zeros(3), ), - MOI.Nonnegatives(3), + MOI.NonnegativeCone(3), ) c4 = MOI.add_constraint( model, @@ -3664,7 +3664,7 @@ function setup_test( [-1.0, exp(-0.3) * 0.3], (MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64}) => [-exp(-0.3) * 0.3], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => [ + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [ [0.0, exp(-0.3), exp(-0.3) / 2], [0.0, 0.0, exp(-0.3) / 2], ], @@ -5928,7 +5928,7 @@ function _test_det_cone_helper_ellipsoid( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) t = MOI.add_variable(model) @@ -5961,7 +5961,7 @@ function _test_det_cone_helper_ellipsoid( ), ones(2), ), - MOI.Nonnegatives(2), + MOI.NonnegativeCone(2), ) if _supports(config, MOI.NumberOfConstraints) @test MOI.get( @@ -5976,7 +5976,7 @@ function _test_det_cone_helper_ellipsoid( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 end @@ -6150,7 +6150,7 @@ function setup_test( mock, [0, 1, 0, 1, 1], (MOI.SingleVariable, MOI.EqualTo{Float64}) => [2], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1, 1]], (MOI.VectorOfVariables, MOI.LogDetConeTriangle) => [[-1, -2, 1, 0, 1]], @@ -6193,7 +6193,7 @@ function setup_test( mock, [0, 1, 0, 1, 1], (MOI.SingleVariable, MOI.EqualTo{Float64}) => [2], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1, 1]], (MOI.VectorAffineFunction{Float64}, MOI.LogDetConeTriangle) => [[-1, -2, 1, 0, 1]], @@ -6229,7 +6229,7 @@ function setup_test( mock, [0, 1, 0, 0, 1, 1], (MOI.SingleVariable, MOI.EqualTo{Float64}) => [2], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1, 1]], (MOI.VectorOfVariables, MOI.LogDetConeSquare) => [[-1, -2, 1, 0, 0, 1]], @@ -6267,7 +6267,7 @@ function setup_test( mock, [0, 1, 0, 0, 1, 1], (MOI.SingleVariable, MOI.EqualTo{Float64}) => [2], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1, 1]], (MOI.VectorAffineFunction{Float64}, MOI.LogDetConeSquare) => [[-1, -2, 1, 0, 0, 1]], @@ -6307,7 +6307,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 1, 0, 1], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0.5, 0.5]], (MOI.VectorOfVariables, MOI.RootDetConeTriangle) => [[-1.0, 0.5, 0.0, 0.5]], @@ -6347,7 +6347,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 1, 0, 1], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0.5, 0.5]], (MOI.VectorAffineFunction{Float64}, MOI.RootDetConeTriangle) => [[-1.0, 0.5, 0.0, 0.5]], @@ -6382,7 +6382,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 1, 0, 0, 1], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0.5, 0.5]], (MOI.VectorOfVariables, MOI.RootDetConeSquare) => [[-1.0, 0.5, 0.0, 0.0, 0.5]], @@ -6417,7 +6417,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 1, 0, 0, 1], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0.5, 0.5]], (MOI.VectorAffineFunction{Float64}, MOI.RootDetConeSquare) => [[-1.0, 0.5, 0.0, 0.0, 0.5]], diff --git a/src/Test/test_constraint.jl b/src/Test/test_constraint.jl index 4ab7b8802f..a0be6a9b02 100644 --- a/src/Test/test_constraint.jl +++ b/src/Test/test_constraint.jl @@ -726,19 +726,19 @@ function test_constraint_ConstraintPrimalStart( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{T}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @requires MOI.supports( model, MOI.ConstraintPrimalStart(), - MOI.ConstraintIndex{MOI.VectorAffineFunction{T},MOI.Nonnegatives}, + MOI.ConstraintIndex{MOI.VectorAffineFunction{T},MOI.NonnegativeCone}, ) x = MOI.add_variable(model) f = MOI.VectorAffineFunction( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(one(T), x))], [0.0], ) - c = MOI.add_constraint(model, f, MOI.Nonnegatives(1)) + c = MOI.add_constraint(model, f, MOI.NonnegativeCone(1)) @test MOI.get(model, MOI.ConstraintPrimalStart(), c) === nothing MOI.set(model, MOI.ConstraintPrimalStart(), c, [-one(T)]) @test MOI.get(model, MOI.ConstraintPrimalStart(), c) == [-one(T)] @@ -762,19 +762,19 @@ function test_constraint_ConstraintDualStart( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{T}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @requires MOI.supports( model, MOI.ConstraintDualStart(), - MOI.ConstraintIndex{MOI.VectorAffineFunction{T},MOI.Nonnegatives}, + MOI.ConstraintIndex{MOI.VectorAffineFunction{T},MOI.NonnegativeCone}, ) x = MOI.add_variable(model) f = MOI.VectorAffineFunction( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(one(T), x))], [0.0], ) - c = MOI.add_constraint(model, f, MOI.Nonnegatives(1)) + c = MOI.add_constraint(model, f, MOI.NonnegativeCone(1)) @test MOI.get(model, MOI.ConstraintDualStart(), c) === nothing MOI.set(model, MOI.ConstraintDualStart(), c, [-one(T)]) @test MOI.get(model, MOI.ConstraintDualStart(), c) == [-one(T)] diff --git a/src/Test/test_linear.jl b/src/Test/test_linear.jl index 604ee3ab5f..7578b7e7d1 100644 --- a/src/Test/test_linear.jl +++ b/src/Test/test_linear.jl @@ -1283,7 +1283,7 @@ function test_linear_VectorAffineFunction( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{T}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @requires MOI.supports_constraint( model, @@ -1310,7 +1310,7 @@ function test_linear_VectorAffineFunction( [MOI.VectorAffineTerm{T}(1, MOI.ScalarAffineTerm{T}(one(T), x))], [zero(T)], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) c2 = MOI.add_constraint( model, @@ -1350,7 +1350,7 @@ function test_linear_VectorAffineFunction( ], [-T(100)], ), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) end if _supports(config, MOI.optimize!) diff --git a/src/Test/test_model.jl b/src/Test/test_model.jl index 62d8cea500..3a39a99966 100644 --- a/src/Test/test_model.jl +++ b/src/Test/test_model.jl @@ -678,7 +678,7 @@ function test_model_supports_constraint_VectorOfVariables_Nonnegatives( @requires MOI.supports_constraint( model, MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) # Pick a "bad" coefficient type that should fail tests. @test !MOI.supports_constraint( diff --git a/src/Test/test_modification.jl b/src/Test/test_modification.jl index 670e815d89..c21e03584c 100644 --- a/src/Test/test_modification.jl +++ b/src/Test/test_modification.jl @@ -398,7 +398,7 @@ end config::Config, ) -Test setting the function in a VectorAffineFunction-in-Nonnegatives +Test setting the function in a VectorAffineFunction-in-NonnegativeCone constraint. If `config.solve=true` confirm that it solves correctly, and if `config.duals=true`, check that the duals are computed correctly. """ @@ -411,7 +411,7 @@ function test_modification_func_vectoraffine_nonneg( """ variables: x, y minobjective: 1.0x + 2.0y - c: [1.0x, 2.0y] in Nonnegatives(2) + c: [1.0x, 2.0y] in NonnegativeCone(2) """, ) x = MOI.get(model, MOI.VariableIndex, "x") diff --git a/src/Test/test_quadratic.jl b/src/Test/test_quadratic.jl index 2a688e45d3..d4074a885c 100644 --- a/src/Test/test_quadratic.jl +++ b/src/Test/test_quadratic.jl @@ -480,7 +480,7 @@ function test_quadratic_constraint_integration( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @requires MOI.supports_constraint( model, @@ -499,14 +499,14 @@ function test_quadratic_constraint_integration( ), [0.0, 0.0], ), - MOI.Nonnegatives(2), + MOI.NonnegativeCone(2), ) if _supports(config, MOI.NumberOfConstraints) @test MOI.get( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) == 1 end @@ -598,7 +598,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1 / 2, 7 / 4], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [zeros(2)], (MOI.ScalarQuadraticFunction{Float64}, MOI.LessThan{Float64}) => [-1.0], diff --git a/src/Test/test_variable.jl b/src/Test/test_variable.jl index 8907d65322..030ea387d6 100644 --- a/src/Test/test_variable.jl +++ b/src/Test/test_variable.jl @@ -68,9 +68,9 @@ end Test adding, and then deleting, nonnegative variables. """ function test_variable_delete_Nonnegatives(model::MOI.ModelLike, ::Config) - @requires MOI.supports_add_constrained_variables(model, MOI.Nonnegatives) + @requires MOI.supports_add_constrained_variables(model, MOI.NonnegativeCone) @test MOI.get(model, MOI.NumberOfVariables()) == 0 - v, cv = MOI.add_constrained_variables(model, MOI.Nonnegatives(2)) + v, cv = MOI.add_constrained_variables(model, MOI.NonnegativeCone(2)) @test MOI.get(model, MOI.NumberOfVariables()) == 2 MOI.delete(model, v) @test MOI.get(model, MOI.NumberOfVariables()) == 0 @@ -79,7 +79,7 @@ function test_variable_delete_Nonnegatives(model::MOI.ModelLike, ::Config) @test !MOI.is_valid(model, v[2]) @test_throws MOI.InvalidIndex(v[2]) MOI.delete(model, v[2]) @test !MOI.is_valid(model, cv) - v, cv = MOI.add_constrained_variables(model, MOI.Nonnegatives(1)) + v, cv = MOI.add_constrained_variables(model, MOI.NonnegativeCone(1)) @test MOI.get(model, MOI.NumberOfVariables()) == 1 MOI.delete(model, v[1]) @test !MOI.is_valid(model, v[1]) @@ -95,9 +95,9 @@ end Test adding, and then deleting one by one, nonnegative variables. """ function test_variable_delete_Nonnegatives_row(model::MOI.ModelLike, ::Config) - @requires MOI.supports_add_constrained_variables(model, MOI.Nonnegatives) + @requires MOI.supports_add_constrained_variables(model, MOI.NonnegativeCone) @test MOI.get(model, MOI.NumberOfVariables()) == 0 - v, cv = MOI.add_constrained_variables(model, MOI.Nonnegatives(2)) + v, cv = MOI.add_constrained_variables(model, MOI.NonnegativeCone(2)) @test MOI.get(model, MOI.NumberOfVariables()) == 2 MOI.delete(model, v[1]) @test !MOI.is_valid(model, v[1]) diff --git a/src/Utilities/model.jl b/src/Utilities/model.jl index 1fad5751e1..c16427ebe7 100644 --- a/src/Utilities/model.jl +++ b/src/Utilities/model.jl @@ -833,7 +833,7 @@ The model describing an linear program would be: @model(LPModel, # Name of model (), # untyped scalar sets (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan, MOI.Interval), # typed scalar sets - (MOI.Zeros, MOI.Nonnegatives, MOI.Nonpositives), # untyped vector sets + (MOI.Zeros, MOI.NonnegativeCone, MOI.Nonpositives), # untyped vector sets (), # typed vector sets (), # untyped scalar functions (MOI.ScalarAffineFunction,), # typed scalar functions @@ -869,13 +869,13 @@ struct LPModelFunctionConstraints{T} <: MOIU.StructOfConstraints moi_vectorofvariables::LPModelVectorConstraints{ T, MOIU.VectorOfConstraints{MOI.VectorOfVariables, MOI.Zeros}, - MOIU.VectorOfConstraints{MOI.VectorOfVariables, MOI.Nonnegatives}, + MOIU.VectorOfConstraints{MOI.VectorOfVariables, MOI.NonnegativeCone}, MOIU.VectorOfConstraints{MOI.VectorOfVariables, MOI.Nonpositives} } moi_vectoraffinefunction::LPModelVectorConstraints{ T, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{T}, MOI.Zeros}, - MOIU.VectorOfConstraints{MOI.VectorAffineFunction{T}, MOI.Nonnegatives}, + MOIU.VectorOfConstraints{MOI.VectorAffineFunction{T}, MOI.NonnegativeCone}, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{T}, MOI.Nonpositives} } end @@ -1050,7 +1050,7 @@ const LessThanIndicatorSetZero{T} = ( MOI.Reals, MOI.Zeros, - MOI.Nonnegatives, + MOI.NonnegativeCone, MOI.Nonpositives, MOI.Complements, MOI.NormInfinityCone, diff --git a/src/Utilities/parser.jl b/src/Utilities/parser.jl index 11b417533c..5d1189a716 100644 --- a/src/Utilities/parser.jl +++ b/src/Utilities/parser.jl @@ -265,7 +265,7 @@ MOI.Utilities.loadfromstring!( variables: x, y, z minobjective: 2x + 3y con1: x + y <= 1 - con2: [x, y] in MOI.Nonnegatives(2) + con2: [x, y] in MOI.NonnegativeCone(2) x >= 0.0 \"\"\" ) diff --git a/src/Utilities/precompile.jl b/src/Utilities/precompile.jl index 9b0dfc3660..d528f76f4d 100644 --- a/src/Utilities/precompile.jl +++ b/src/Utilities/precompile.jl @@ -17,7 +17,7 @@ function _precompile_() MOI.ScalarQuadraticFunction{T}, ) vector_sets = ( - MOI.Nonnegatives, + MOI.NonnegativeCone, MOI.Nonpositives, MOI.Zeros, MOI.Reals, diff --git a/src/Utilities/product_of_sets.jl b/src/Utilities/product_of_sets.jl index b2f5f642fa..9752766093 100644 --- a/src/Utilities/product_of_sets.jl +++ b/src/Utilities/product_of_sets.jl @@ -148,7 +148,7 @@ Generate a new [`OrderedProductOfSets`](@ref) subtype. @product_of_sets( LinearOrthants, MOI.Zeros, - MOI.Nonnegatives, + MOI.NonnegativeCone, MOI.Nonpositives, MOI.ZeroOne, ) diff --git a/src/Utilities/sets.jl b/src/Utilities/sets.jl index faf225c619..b23956e940 100644 --- a/src/Utilities/sets.jl +++ b/src/Utilities/sets.jl @@ -72,7 +72,7 @@ This is used in the vectorize and scalarize bridges. See also: [`ScalarLinearSet`](@ref). """ -const VectorLinearSet = Union{MOI.Zeros,MOI.Nonnegatives,MOI.Nonpositives} +const VectorLinearSet = Union{MOI.Zeros,MOI.NonnegativeCone,MOI.Nonpositives} """ vector_set_type(::Type{S}) where {S} @@ -85,7 +85,7 @@ See also: [`scalar_set_type`](@ref). """ vector_set_type(::Type{<:MOI.EqualTo}) = MOI.Zeros vector_set_type(::Type{<:MOI.LessThan}) = MOI.Nonpositives -vector_set_type(::Type{<:MOI.GreaterThan}) = MOI.Nonnegatives +vector_set_type(::Type{<:MOI.GreaterThan}) = MOI.NonnegativeCone """ scalar_set_type(::Type{S}, ::Type{T}) where {S,T} @@ -99,7 +99,7 @@ See also: [`vector_set_type`](@ref). """ scalar_set_type(::Type{<:MOI.Zeros}, T::Type) = MOI.EqualTo{T} scalar_set_type(::Type{<:MOI.Nonpositives}, T::Type) = MOI.LessThan{T} -scalar_set_type(::Type{<:MOI.Nonnegatives}, T::Type) = MOI.GreaterThan{T} +scalar_set_type(::Type{<:MOI.NonnegativeCone}, T::Type) = MOI.GreaterThan{T} """ is_diagonal_vectorized_index(index::Base.Integer) diff --git a/src/sets.jl b/src/sets.jl index 88564ec3d8..c8e1ba2f23 100644 --- a/src/sets.jl +++ b/src/sets.jl @@ -152,18 +152,18 @@ dual_set(s::Zeros) = Reals(dimension(s)) dual_set_type(::Type{Zeros}) = Reals """ - Nonnegatives(dimension) + NonnegativeCone(dimension) The nonnegative orthant ``\\{ x \\in \\mathbb{R}^{dimension} : x \\ge 0 \\}`` of dimension `dimension`. """ -struct Nonnegatives <: AbstractVectorSet +struct NonnegativeCone <: AbstractVectorSet dimension::Int - function Nonnegatives(dimension::Base.Integer) + function NonnegativeCone(dimension::Base.Integer) if !(dimension >= 0) throw( DimensionMismatch( - "Dimension of Nonnegatives must be >= 0, not $(dimension).", + "Dimension of NonnegativeCone must be >= 0, not $(dimension).", ), ) end @@ -171,8 +171,8 @@ struct Nonnegatives <: AbstractVectorSet end end -dual_set(s::Nonnegatives) = copy(s) -dual_set_type(::Type{Nonnegatives}) = Nonnegatives +dual_set(s::NonnegativeCone) = copy(s) +dual_set_type(::Type{NonnegativeCone}) = NonnegativeCone """ Nonpositives(dimension) @@ -1089,7 +1089,7 @@ There are three solutions: The function `F` can also be defined in terms of single variables. For example, the problem: - [x_3, x_4] -in- Nonnegatives(2) + [x_3, x_4] -in- NonnegativeCone(2) [x_1, x_2, x_3, x_4] -in- Complements(4) defines the complementarity problem where `0 <= x_1 ⟂ x_3 >= 0` and @@ -1114,7 +1114,7 @@ function Base.copy( set::Union{ Reals, Zeros, - Nonnegatives, + NonnegativeCone, Nonpositives, GreaterThan, LessThan, @@ -1157,7 +1157,7 @@ Return a `Bool` indicating whether the elimination of any dimension of By default, this function returns `false` so it should only be implemented for sets that supports dimension update. -For instance, `supports_dimension_update(MOI.Nonnegatives}` is `true` because +For instance, `supports_dimension_update(MOI.NonnegativeCone}` is `true` because the elimination of any dimension of the `n`-dimensional nonnegative orthant gives the `n-1`-dimensional nonnegative orthant. However `supports_dimension_update(MOI.ExponentialCone}` is `false`. @@ -1166,7 +1166,7 @@ function supports_dimension_update(::Type{<:AbstractVectorSet}) return false end function supports_dimension_update( - ::Type{<:Union{Reals,Zeros,Nonnegatives,Nonpositives}}, + ::Type{<:Union{Reals,Zeros,NonnegativeCone,Nonpositives}}, ) return true end @@ -1178,7 +1178,7 @@ Returns a set with the dimension modified to `new_dim`. """ function update_dimension end function update_dimension( - set::Union{Reals,Zeros,Nonnegatives,Nonpositives}, + set::Union{Reals,Zeros,NonnegativeCone,Nonpositives}, new_dim, ) return typeof(set)(new_dim) diff --git a/test/Bridges/Constraint/det.jl b/test/Bridges/Constraint/det.jl index 2a92e082f8..cf78444bc4 100644 --- a/test/Bridges/Constraint/det.jl +++ b/test/Bridges/Constraint/det.jl @@ -23,7 +23,7 @@ config = MOIT.Config() mock, var_primal, (MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64}) => [-1], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1, 1]], (MOI.VectorAffineFunction{Float64}, MOI.ExponentialCone) => exp_duals, @@ -146,7 +146,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, var_primal, - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0.5, 0.5]], (MOI.VectorAffineFunction{Float64}, MOI.GeometricMeanCone) => [geomean_dual], ( diff --git a/test/Bridges/Constraint/flip_sign.jl b/test/Bridges/Constraint/flip_sign.jl index 0eb19f565f..fc4a434467 100644 --- a/test/Bridges/Constraint/flip_sign.jl +++ b/test/Bridges/Constraint/flip_sign.jl @@ -157,7 +157,7 @@ end MOI.VectorOfVariables, MOI.VectorAffineFunction{Float64}, MOI.VectorQuadraticFunction{Float64}, - ] for S in [MOI.Nonnegatives] + ] for S in [MOI.NonnegativeCone] ], ) @@ -175,7 +175,7 @@ end bridged_mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ), ) @@ -201,7 +201,7 @@ end bridged_mock, MOI.ListOfConstraintIndices{ MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ), ) @@ -209,7 +209,7 @@ end MOI.delete(bridged_mock, func.variables[2]) new_func = MOI.VectorOfVariables(func.variables[[1, 3]]) @test MOI.get(bridged_mock, MOI.ConstraintFunction(), ci) == new_func - @test MOI.get(bridged_mock, MOI.ConstraintSet(), ci) == MOI.Nonnegatives(2) + @test MOI.get(bridged_mock, MOI.ConstraintSet(), ci) == MOI.NonnegativeCone(2) @testset "$attr" for attr in [ MOI.ConstraintPrimalStart(), @@ -302,6 +302,6 @@ end bridged_mock, ci, 1, - ((MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives, 0),), + ((MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone, 0),), ) end diff --git a/test/Bridges/Constraint/functionize.jl b/test/Bridges/Constraint/functionize.jl index c8d327c132..65b2ac8e20 100644 --- a/test/Bridges/Constraint/functionize.jl +++ b/test/Bridges/Constraint/functionize.jl @@ -146,11 +146,11 @@ end config, include = [ (F, S) for F in [MOI.VectorOfVariables], - S in [MOI.Nonnegatives, MOI.Nonpositives] + S in [MOI.NonnegativeCone, MOI.Nonpositives] ], ) - for T in [Int, Float64], S in [MOI.Nonnegatives, MOI.Nonpositives] + for T in [Int, Float64], S in [MOI.NonnegativeCone, MOI.Nonpositives] @test MOIB.added_constraint_types( MOIB.Constraint.VectorFunctionizeBridge{T,S}, ) == [(MOI.VectorAffineFunction{T}, S)] @@ -161,7 +161,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1.0, 0.0, 2.0], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0, 2, 0]], (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-3, -1]], @@ -172,7 +172,7 @@ end bridged_mock, MOI.ListOfConstraintIndices{ MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ), ) @@ -181,7 +181,7 @@ end new_func = MOI.VectorOfVariables(func.variables[[1, 3]]) @test MOI.get(bridged_mock, MOI.ConstraintFunction(), ci) == new_func @test MOI.get(bridged_mock, MOI.ConstraintSet(), ci) == - MOI.Nonnegatives(2) + MOI.NonnegativeCone(2) @testset "$attr" for attr in [ MOI.ConstraintPrimalStart(), @@ -196,7 +196,7 @@ end bridged_mock, ci, 2, - ((MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives, 0),), + ((MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone, 0),), ) end end diff --git a/test/Bridges/Constraint/geomean.jl b/test/Bridges/Constraint/geomean.jl index f493fa7e2a..dfe872cdc2 100644 --- a/test/Bridges/Constraint/geomean.jl +++ b/test/Bridges/Constraint/geomean.jl @@ -163,7 +163,7 @@ config = MOIT.Config() 0, ), (MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64}, 1), - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives, 0), + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone, 0), ), ) end @@ -353,7 +353,7 @@ config = MOIT.Config() 0, ), (MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64}, 0), - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives, 0), + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone, 0), ), ) end @@ -364,7 +364,7 @@ config = MOIT.Config() mock, [2, 2], (MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64}) => [-2, -2], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0]], ) @@ -404,7 +404,7 @@ config = MOIT.Config() mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) @test length(nonneg) == 1 @@ -414,7 +414,7 @@ config = MOIT.Config() variables: t, x lessthan1: t + -1.0x in MathOptInterface.LessThan(0.0) lessthan2: 1.0x in MathOptInterface.LessThan(2.0) - nonneg: [1.0x] in MathOptInterface.Nonnegatives(1) + nonneg: [1.0x] in MathOptInterface.NonnegativeCone(1) maxobjective: 2.0 * t """ model = MOIU.Model{Float64}() @@ -490,7 +490,7 @@ config = MOIT.Config() 0, ), (MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64}, 1), - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives, 0), + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone, 0), ), ) end diff --git a/test/Bridges/Constraint/geomean_to_relentr.jl b/test/Bridges/Constraint/geomean_to_relentr.jl index e649a381e6..963e0103c3 100644 --- a/test/Bridges/Constraint/geomean_to_relentr.jl +++ b/test/Bridges/Constraint/geomean_to_relentr.jl @@ -34,7 +34,7 @@ config = MOIT.Config() mock, var_primal, (MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64}) => [-inv(3)], - (MOI.VectorOfVariables, MOI.Nonnegatives) => [[1]], + (MOI.VectorOfVariables, MOI.NonnegativeCone) => [[1]], (MOI.VectorAffineFunction{Float64}, MOI.RelativeEntropyCone) => [relentr_dual], ) @@ -52,7 +52,7 @@ config = MOIT.Config() mock, MOI.ListOfConstraintIndices{ MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) relentr = MOI.get( @@ -83,7 +83,7 @@ config = MOIT.Config() s = """ variables: t, x, y, z, aux less: x + y + z in MathOptInterface.LessThan(3.0) - nonneg: [aux] in MathOptInterface.Nonnegatives(1) + nonneg: [aux] in MathOptInterface.NonnegativeCone(1) relentr: [0.0, x, y, z, t + aux, t + aux, t + aux] in MathOptInterface.RelativeEntropyCone(7) maxobjective: t """ @@ -169,7 +169,7 @@ config = MOIT.Config() 4, ( (MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64}, 1), - (MOI.VectorOfVariables, MOI.Nonnegatives, 0), + (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), (MOI.VectorAffineFunction{Float64}, MOI.RelativeEntropyCone, 0), ), ) @@ -184,7 +184,7 @@ config = MOIT.Config() var_primal, (MOI.ScalarAffineFunction{Float64}, MOI.EqualTo{Float64}) => fill(-inv(9), 9), - (MOI.VectorOfVariables, MOI.Nonnegatives) => [[1]], + (MOI.VectorOfVariables, MOI.NonnegativeCone) => [[1]], (MOI.VectorAffineFunction{Float64}, MOI.RelativeEntropyCone) => [relentr_dual], ) @@ -202,7 +202,7 @@ config = MOIT.Config() mock, MOI.ListOfConstraintIndices{ MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) relentr = MOI.get( @@ -242,7 +242,7 @@ config = MOIT.Config() equalto7: 1.0x7 in MathOptInterface.EqualTo(1.0) equalto8: 1.0x8 in MathOptInterface.EqualTo(1.0) equalto9: 1.0x9 in MathOptInterface.EqualTo(1.0) - nonneg: [aux] in MathOptInterface.Nonnegatives(1) + nonneg: [aux] in MathOptInterface.NonnegativeCone(1) relentr: [0.0, x1, x2, x3, x4, x5, x6, x7, x8, x9, t + aux, t + aux, t + aux, t + aux, t + aux, t + aux, t + aux, t + aux, t + aux] in MathOptInterface.RelativeEntropyCone(19) maxobjective: t """ @@ -337,7 +337,7 @@ config = MOIT.Config() 10, ( (MOI.ScalarAffineFunction{Float64}, MOI.EqualTo{Float64}, 9), - (MOI.VectorOfVariables, MOI.Nonnegatives, 0), + (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), (MOI.VectorAffineFunction{Float64}, MOI.RelativeEntropyCone, 0), ), ) @@ -351,7 +351,7 @@ config = MOIT.Config() mock, var_primal, (MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64}) => [-2], - (MOI.VectorOfVariables, MOI.Nonnegatives) => [[2]], + (MOI.VectorOfVariables, MOI.NonnegativeCone) => [[2]], (MOI.VectorAffineFunction{Float64}, MOI.RelativeEntropyCone) => [relentr_dual], ) @@ -369,7 +369,7 @@ config = MOIT.Config() mock, MOI.ListOfConstraintIndices{ MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) relentr = MOI.get( @@ -400,7 +400,7 @@ config = MOIT.Config() s = """ variables: t, x, aux less: 1.0x in MathOptInterface.LessThan(2.0) - nonneg: [aux] in MathOptInterface.Nonnegatives(1) + nonneg: [aux] in MathOptInterface.NonnegativeCone(1) relentr: [0.0, x, t + aux] in MathOptInterface.RelativeEntropyCone(3) maxobjective: 2.0t """ @@ -484,7 +484,7 @@ config = MOIT.Config() 2, ( (MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64}, 1), - (MOI.VectorOfVariables, MOI.Nonnegatives, 0), + (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), (MOI.VectorAffineFunction{Float64}, MOI.RelativeEntropyCone, 0), ), ) diff --git a/test/Bridges/Constraint/interval.jl b/test/Bridges/Constraint/interval.jl index 0d49f9799e..87d1d7dccc 100644 --- a/test/Bridges/Constraint/interval.jl +++ b/test/Bridges/Constraint/interval.jl @@ -204,7 +204,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1.0, 0.0, 2.0], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0.0, 0.0]], (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => [[-3, -1]], @@ -226,7 +226,7 @@ end ci, 3, ( - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives, 0), + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone, 0), (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives, 0), ), ) diff --git a/test/Bridges/Constraint/norm_to_lp.jl b/test/Bridges/Constraint/norm_to_lp.jl index 1fbfa67d95..d2a64e9ca0 100644 --- a/test/Bridges/Constraint/norm_to_lp.jl +++ b/test/Bridges/Constraint/norm_to_lp.jl @@ -31,7 +31,7 @@ config = MOIT.Config() (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1.0, 0.5, 1.0], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0.0, 1.0, 0.0, 0.0]], (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-1], [-1]], @@ -53,7 +53,7 @@ config = MOIT.Config() mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) @test length(nonneg) == 1 @@ -71,7 +71,7 @@ config = MOIT.Config() s = """ variables: x, y, z - nonneg: [x + -1.0y, x + -1.0z, x + y, x + z] in MathOptInterface.Nonnegatives(4) + nonneg: [x + -1.0y, x + -1.0z, x + y, x + z] in MathOptInterface.NonnegativeCone(4) x_eq: [-1.0 + x] in MathOptInterface.Zeros(1) y_eq: [-0.5 + y] in MathOptInterface.Zeros(1) maxobjective: y + z @@ -143,7 +143,7 @@ config = MOIT.Config() mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) @@ -167,7 +167,7 @@ config = MOIT.Config() bridged_mock, ci, 3, - ((MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives, 0),), + ((MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone, 0),), ) end @@ -176,7 +176,7 @@ config = MOIT.Config() (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [2, -1, -1, -1], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [vcat(fill(inv(3), 3), zeros(3)), fill(inv(3), 3)], ) MOIT.norminf3test(bridged_mock, config) @@ -194,7 +194,7 @@ config = MOIT.Config() mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) @test length(nonneg) == 2 @@ -203,8 +203,8 @@ config = MOIT.Config() s = """ variables: x, y1, y2, y3 - nonneg1: [x + -1.0y1 + -3.0, x + -1.0y2 + -3.0, x + -1.0y3 + -3.0, x + y1 + 1.0, x + y2 + 1.0, x + y3 + 1.0] in MathOptInterface.Nonnegatives(6) - nonneg2: [y1 + 1.0, y2 + 1.0, y3 + 1.0] in MathOptInterface.Nonnegatives(3) + nonneg1: [x + -1.0y1 + -3.0, x + -1.0y2 + -3.0, x + -1.0y3 + -3.0, x + y1 + 1.0, x + y2 + 1.0, x + y3 + 1.0] in MathOptInterface.NonnegativeCone(6) + nonneg2: [y1 + 1.0, y2 + 1.0, y3 + 1.0] in MathOptInterface.NonnegativeCone(3) minobjective: x """ model = MOIU.Model{Float64}() @@ -237,7 +237,7 @@ config = MOIT.Config() bridged_mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) @test length(nonneg) == 1 @@ -246,7 +246,7 @@ config = MOIT.Config() s = """ variables: x, y1, y2, y3 norminf: [x + -1.0, y1 + 2.0, y2 + 2.0, y3 + 2.0] in MathOptInterface.NormInfinityCone(4) - nonneg: [y1 + 1.0, y2 + 1.0, y3 + 1.0] in MathOptInterface.Nonnegatives(3) + nonneg: [y1 + 1.0, y2 + 1.0, y3 + 1.0] in MathOptInterface.NonnegativeCone(3) minobjective: x """ model = MOIU.Model{Float64}() @@ -272,7 +272,7 @@ config = MOIT.Config() mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) @@ -296,7 +296,7 @@ config = MOIT.Config() bridged_mock, ci, 4, - ((MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives, 1),), + ((MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone, 1),), ) end end @@ -321,7 +321,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1.0, 0.5, 0.5, 0.5, 0.5], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1.0, 1.0, 1.0, 0.0, 0.0]], (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-1], [0]], @@ -342,7 +342,7 @@ end mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) u, v = MOI.get(mock, MOI.ListOfVariableIndices())[4:5] @@ -364,7 +364,7 @@ end s = """ variables: x, y, z, u, v - nonneg: [x + -1.0u + -1.0v, u + -1.0y, v + -1.0z, u + y, v + z] in MathOptInterface.Nonnegatives(5) + nonneg: [x + -1.0u + -1.0v, u + -1.0y, v + -1.0z, u + y, v + z] in MathOptInterface.NonnegativeCone(5) x_eq: [-1.0 + x] in MathOptInterface.Zeros(1) y_eq: [-0.5 + y] in MathOptInterface.Zeros(1) maxobjective: y + z @@ -448,7 +448,7 @@ end bridged_mock, ci, 3, - ((MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives, 0),), + ((MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone, 0),), ) end @@ -457,7 +457,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [4, -1, -1, -1, 1, 1, 1], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [vcat(ones(4), zeros(3)), ones(3)], ) MOIT.normone3test(bridged_mock, config) @@ -476,7 +476,7 @@ end mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) @test length(nonneg) == 2 @@ -485,8 +485,8 @@ end s = """ variables: x, y1, y2, y3, z1, z2, z3 - nonneg1: [x + -1.0 + -1.0z1 + -1.0z2 + -1.0z3, z1 + -1.0y1 + -2.0, z2 + -1.0y2 + -2.0, z3 + -1.0y3 + -2.0, z1 + y1 + 2.0, z2 + y2 + 2.0, z3 + y3 + 2.0] in MathOptInterface.Nonnegatives(7) - nonneg2: [y1 + 1.0, y2 + 1.0, y3 + 1.0] in MathOptInterface.Nonnegatives(3) + nonneg1: [x + -1.0 + -1.0z1 + -1.0z2 + -1.0z3, z1 + -1.0y1 + -2.0, z2 + -1.0y2 + -2.0, z3 + -1.0y3 + -2.0, z1 + y1 + 2.0, z2 + y2 + 2.0, z3 + y3 + 2.0] in MathOptInterface.NonnegativeCone(7) + nonneg2: [y1 + 1.0, y2 + 1.0, y3 + 1.0] in MathOptInterface.NonnegativeCone(3) minobjective: x """ model = MOIU.Model{Float64}() @@ -519,7 +519,7 @@ end bridged_mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) @test length(nonneg) == 1 @@ -528,7 +528,7 @@ end s = """ variables: x, y1, y2, y3 normone: [x + -1.0, y1 + 2.0, y2 + 2.0, y3 + 2.0] in MathOptInterface.NormOneCone(4) - nonneg: [y1 + 1.0, y2 + 1.0, y3 + 1.0] in MathOptInterface.Nonnegatives(3) + nonneg: [y1 + 1.0, y2 + 1.0, y3 + 1.0] in MathOptInterface.NonnegativeCone(3) minobjective: x """ model = MOIU.Model{Float64}() @@ -554,7 +554,7 @@ end mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) @@ -580,7 +580,7 @@ end bridged_mock, ci, 4, - ((MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives, 1),), + ((MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone, 1),), ) end end diff --git a/test/Bridges/Constraint/quad_to_soc.jl b/test/Bridges/Constraint/quad_to_soc.jl index a9e4b739a7..814e281318 100644 --- a/test/Bridges/Constraint/quad_to_soc.jl +++ b/test/Bridges/Constraint/quad_to_soc.jl @@ -84,7 +84,7 @@ config = MOIT.Config() (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1 / 2, 7 / 4], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [zeros(2)], ( MOI.VectorAffineFunction{Float64}, diff --git a/test/Bridges/Constraint/scalarize.jl b/test/Bridges/Constraint/scalarize.jl index de84bac189..71483450a8 100644 --- a/test/Bridges/Constraint/scalarize.jl +++ b/test/Bridges/Constraint/scalarize.jl @@ -22,11 +22,11 @@ config = MOIT.Config() MOI.VectorOfVariables, MOI.VectorAffineFunction{Float64}, MOI.VectorQuadraticFunction{Float64}, - ] for S in [MOI.Nonnegatives, MOI.Nonpositives, MOI.Zeros] + ] for S in [MOI.NonnegativeCone, MOI.Nonpositives, MOI.Zeros] ], ) - # VectorOfVariables-in-Nonnegatives + # VectorOfVariables-in-NonnegativeCone # VectorAffineFunction-in-Zeros mock.optimize! = (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( @@ -59,7 +59,7 @@ config = MOIT.Config() bridged_mock, MOI.ListOfConstraintIndices{ MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ), ) @@ -67,7 +67,7 @@ config = MOIT.Config() MOI.delete(bridged_mock, func.variables[2]) new_func = MOI.VectorOfVariables(func.variables[[1, 3]]) @test MOI.get(bridged_mock, MOI.ConstraintFunction(), ci) == new_func - @test MOI.get(bridged_mock, MOI.ConstraintSet(), ci) == MOI.Nonnegatives(2) + @test MOI.get(bridged_mock, MOI.ConstraintSet(), ci) == MOI.NonnegativeCone(2) @testset "$attr" for attr in [ MOI.ConstraintPrimalStart(), @@ -89,7 +89,7 @@ config = MOIT.Config() ), ) - # VectorAffineFunction-in-Nonnegatives + # VectorAffineFunction-in-NonnegativeCone # VectorAffineFunction-in-Zeros mock.optimize! = (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( @@ -137,7 +137,7 @@ config = MOIT.Config() bridged_mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ), ) @@ -170,7 +170,7 @@ config = MOIT.Config() ) MOIT.solve_func_vectoraffine_nonneg(bridged_mock, config) - # VectorOfVariables-in-Nonnegatives + # VectorOfVariables-in-NonnegativeCone # VectorOfVariables-in-Nonpositives # VectorOfVariables-in-Zeros # VectorAffineFunction-in-Zeros @@ -183,7 +183,7 @@ config = MOIT.Config() ) MOIT.lin2vtest(bridged_mock, config) - # VectorAffineFunction-in-Nonnegatives + # VectorAffineFunction-in-NonnegativeCone # VectorAffineFunction-in-Nonpositives # VectorAffineFunction-in-Zeros mock.optimize! = diff --git a/test/Bridges/Constraint/slack.jl b/test/Bridges/Constraint/slack.jl index 64453ee4ec..c9e1310bec 100644 --- a/test/Bridges/Constraint/slack.jl +++ b/test/Bridges/Constraint/slack.jl @@ -234,7 +234,7 @@ end (F, S) for F in [ MOI.VectorAffineFunction{Float64}, MOI.VectorQuadraticFunction{Float64}, - ], S in [MOI.Nonnegatives, MOI.Nonpositives] + ], S in [MOI.NonnegativeCone, MOI.Nonpositives] ], ) @@ -249,7 +249,7 @@ end [100, -100, 100, -100], (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[1.0], [1.0]], - (MOI.VectorOfVariables, MOI.Nonnegatives) => [[1.0]], + (MOI.VectorOfVariables, MOI.NonnegativeCone) => [[1.0]], (MOI.VectorOfVariables, MOI.Nonpositives) => [[1.0]], ), ) @@ -259,7 +259,7 @@ end bridged_mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) @test length(c1) == 1 @@ -278,15 +278,15 @@ end loc = MOI.get(bridged_mock, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 2 - @test (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) in loc @test (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) in loc loc = MOI.get(mock, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 3 @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc - @test (MOI.VectorOfVariables, MOI.Nonnegatives) in loc + @test (MOI.VectorOfVariables, MOI.NonnegativeCone) in loc @test (MOI.VectorOfVariables, MOI.Nonpositives) in loc - for T in [Int, Float64], S in [MOI.Nonnegatives, MOI.Nonpositives] + for T in [Int, Float64], S in [MOI.NonnegativeCone, MOI.Nonpositives] for F in [MOI.VectorAffineFunction{T}, MOI.VectorQuadraticFunction{T}] @test MOIB.added_constraint_types( MOIB.Constraint.VectorSlackBridge{T,F,S}, diff --git a/test/Bridges/Constraint/vectorize.jl b/test/Bridges/Constraint/vectorize.jl index c34e45fc20..266a56e72a 100644 --- a/test/Bridges/Constraint/vectorize.jl +++ b/test/Bridges/Constraint/vectorize.jl @@ -40,7 +40,7 @@ config = MOIT.Config() mock, [1, 0], (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => [[-1]], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0], [1]], ), ) @@ -78,14 +78,14 @@ config = MOIT.Config() [0, 1 / 2, 1], (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => [[-1], [-2]], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[2], [0], [0]], ), (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1], (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => [[-1]], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => [[0]], + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0]], ), ) # linear14 has double variable bounds for the z variable diff --git a/test/Bridges/Variable/flip_sign.jl b/test/Bridges/Variable/flip_sign.jl index bab0b247ac..fd4cdf48c3 100644 --- a/test/Bridges/Variable/flip_sign.jl +++ b/test/Bridges/Variable/flip_sign.jl @@ -63,7 +63,7 @@ config = MOIT.Config() mock, MOI.ListOfConstraintIndices{ MathOptInterface.VectorOfVariables, - MathOptInterface.Nonnegatives, + MathOptInterface.NonnegativeCone, }(), ) con_ex = MOI.get( @@ -98,8 +98,8 @@ config = MOIT.Config() s = """ variables: x, y, z, w cw: [w] in MathOptInterface.Zeros(1) - cy: [y] in MathOptInterface.Nonnegatives(1) - cz: [z] in MathOptInterface.Nonnegatives(1) + cy: [y] in MathOptInterface.NonnegativeCone(1) + cz: [z] in MathOptInterface.NonnegativeCone(1) cex: [1*x + -1*w + 4.0, -1*y + 3.0, 1*x + 1*z + -12.0] in MathOptInterface.Zeros(3) minobjective: 3*x + -2*y + -4*z """ @@ -118,7 +118,7 @@ config = MOIT.Config() variables: x, z, w, v cv: [v] in MathOptInterface.Nonpositives(1) cw: [w] in MathOptInterface.Zeros(1) - cz: [z] in MathOptInterface.Nonnegatives(1) + cz: [z] in MathOptInterface.NonnegativeCone(1) cex: [1*x + -1*w + 4.0, 1*v + 3.0, 1*x + 1*z + -12.0] in MathOptInterface.Zeros(3) minobjective: 3*x + 2*v + -4*z """ @@ -156,7 +156,7 @@ config = MOIT.Config() vis[1], MOI.Nonpositives, 1, - ((MOI.VectorOfVariables, MOI.Nonnegatives, 0),), + ((MOI.VectorOfVariables, MOI.NonnegativeCone, 0),), ) end @@ -169,7 +169,7 @@ config = MOIT.Config() vis[2], MOI.Nonpositives, 4, - ((MOI.VectorOfVariables, MOI.Nonnegatives, 0),), + ((MOI.VectorOfVariables, MOI.NonnegativeCone, 0),), used_bridges = 0, used_constraints = 0, ) diff --git a/test/Bridges/Variable/free.jl b/test/Bridges/Variable/free.jl index ecbe544058..a055efa7e2 100644 --- a/test/Bridges/Variable/free.jl +++ b/test/Bridges/Variable/free.jl @@ -57,14 +57,14 @@ bridged_mock = MOIB.Variable.Free{Float64}(mock) mock, MOI.ListOfConstraintIndices{ MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ), ["nonneg"], ) s = """ variables: xpos, xneg - nonneg: [xpos, xneg] in MathOptInterface.Nonnegatives(2) + nonneg: [xpos, xneg] in MathOptInterface.NonnegativeCone(2) c: [4.0xpos + -4.0xneg + -1.0, 3.0xpos + -3.0xneg + -1.0] in MathOptInterface.Nonpositives(2) maxobjective: xpos + -1.0xneg """ @@ -123,7 +123,7 @@ end MOI.Reals, 2, ( - (MOI.VectorOfVariables, MOI.Nonnegatives, 0), + (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), (MOI.VectorOfVariables, MOI.Nonpositives, 0), ), ) @@ -133,7 +133,7 @@ end MOI.Reals, 1, ( - (MOI.VectorOfVariables, MOI.Nonnegatives, 0), + (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), (MOI.VectorOfVariables, MOI.Nonpositives, 0), ), ) @@ -150,7 +150,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [100, 0, 0, 100], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1.0]], (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => [[-1.0]], @@ -240,14 +240,14 @@ end mock, MOI.ListOfConstraintIndices{ MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ), ["nonneg"], ) s = """ variables: v1pos, v2pos, v1neg, v2neg - nonneg: [v1pos, v2pos, v1neg, v2neg] in MathOptInterface.Nonnegatives(4) + nonneg: [v1pos, v2pos, v1neg, v2neg] in MathOptInterface.NonnegativeCone(4) c1: v1pos + -1.0v1neg + v2pos + -1.0v2neg >= 1.0 c2: v1pos + -1.0v1neg + v2pos + -1.0v2neg <= 2.0 minobjective: v1pos + -1.0v1neg + v2pos + -1.0v2neg @@ -276,7 +276,7 @@ end MOI.Reals, 2, ( - (MOI.VectorOfVariables, MOI.Nonnegatives, 0), + (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), (MOI.VectorOfVariables, MOI.Nonpositives, 0), ), used_bridges = 0, @@ -288,7 +288,7 @@ end MOI.Reals, 1, ( - (MOI.VectorOfVariables, MOI.Nonnegatives, 0), + (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), (MOI.VectorOfVariables, MOI.Nonpositives, 0), ), ) diff --git a/test/Bridges/Variable/rsoc_to_psd.jl b/test/Bridges/Variable/rsoc_to_psd.jl index a83e18a5f5..e0623837cb 100644 --- a/test/Bridges/Variable/rsoc_to_psd.jl +++ b/test/Bridges/Variable/rsoc_to_psd.jl @@ -58,7 +58,7 @@ bridged_mock = MOIB.Variable.RSOCtoPSD{Float64}(mock) mock, MOI.ListOfConstraintIndices{ MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ) @test length(nonneg) == 1 @@ -66,7 +66,7 @@ bridged_mock = MOIB.Variable.RSOCtoPSD{Float64}(mock) s = """ variables: a, b - cab: [a, b] in MathOptInterface.Nonnegatives(2) + cab: [a, b] in MathOptInterface.NonnegativeCone(2) c: a + 0.5b <= 1.0 maxobjective: 0.5b """ @@ -102,7 +102,7 @@ bridged_mock = MOIB.Variable.RSOCtoPSD{Float64}(mock) MOI.RotatedSecondOrderCone, 2, ( - (MOI.VectorOfVariables, MOI.Nonnegatives, 0), + (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), (MOI.VectorOfVariables, MOI.PositiveSemidefiniteConeTriangle, 0), (MOI.SingleVariable, MOI.EqualTo{Float64}, 0), (MOI.ScalarAffineFunction{Float64}, MOI.EqualTo{Float64}, 0), @@ -248,7 +248,7 @@ end MOI.RotatedSecondOrderCone, 4, ( - (MOI.VectorOfVariables, MOI.Nonnegatives, 0), + (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), ( MOI.VectorOfVariables, MOI.PositiveSemidefiniteConeTriangle, diff --git a/test/Bridges/Variable/vectorize.jl b/test/Bridges/Variable/vectorize.jl index d803f6c6ef..57d9910e2a 100644 --- a/test/Bridges/Variable/vectorize.jl +++ b/test/Bridges/Variable/vectorize.jl @@ -41,14 +41,14 @@ bridged_mock = MOIB.Variable.Vectorize{Float64}(mock) mock, MOI.ListOfConstraintIndices{ MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ), ["cy"], ) s = """ variables: y - cy: [y] in MathOptInterface.Nonnegatives(1) + cy: [y] in MathOptInterface.NonnegativeCone(1) c: 2.0y >= 3.0 """ model = MOIU.Model{Float64}() diff --git a/test/Bridges/bridge_optimizer.jl b/test/Bridges/bridge_optimizer.jl index 320f7cd01a..0ba4e2bfa4 100644 --- a/test/Bridges/bridge_optimizer.jl +++ b/test/Bridges/bridge_optimizer.jl @@ -132,7 +132,7 @@ MOIU.@model( (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan, MOI.Interval), ( MOI.Zeros, - MOI.Nonnegatives, + MOI.NonnegativeCone, MOI.Nonpositives, MOI.NormInfinityCone, MOI.NormOneCone, @@ -357,17 +357,17 @@ end )) == scon_indices end - vcon_indices = MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.Nonnegatives}[] + vcon_indices = MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.NonnegativeCone}[] for (i, v) in enumerate(z) f = MOI.VectorOfVariables([v]) - c = MOI.add_constraint(model, f, MOI.Nonnegatives(1)) + c = MOI.add_constraint(model, f, MOI.NonnegativeCone(1)) push!(vcon_indices, c) @test Set(MOI.get(model, MOI.ListOfConstraintTypesPresent())) == Set([ (MOI.ScalarAffineFunction{Int}, MOI.GreaterThan{Int}), (MOI.ScalarAffineFunction{Int}, MOI.Interval{Int}), (MOI.SingleVariable, MOI.Interval{Int}), - (MOI.VectorOfVariables, MOI.Nonnegatives), + (MOI.VectorOfVariables, MOI.NonnegativeCone), ]) _test_num_constraints( model, @@ -387,7 +387,7 @@ end MOI.Interval{Int}, n + 2, ) - _test_num_constraints(model, MOI.VectorOfVariables, MOI.Nonnegatives, i) + _test_num_constraints(model, MOI.VectorOfVariables, MOI.NonnegativeCone, i) @test (@inferred MOI.get( model, MOI.ListOfConstraintIndices{ @@ -411,7 +411,7 @@ end model, MOI.ListOfConstraintIndices{ MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), )) == vcon_indices end @@ -422,7 +422,7 @@ end @test Set(MOI.get(model, MOI.ListOfConstraintTypesPresent())) == Set([ (MOI.ScalarAffineFunction{Int}, MOI.Interval{Int}), (MOI.SingleVariable, MOI.Interval{Int}), - (MOI.VectorOfVariables, MOI.Nonnegatives), + (MOI.VectorOfVariables, MOI.NonnegativeCone), ]) _test_num_constraints( model, @@ -437,7 +437,7 @@ end 1, ) _test_num_constraints(model, MOI.SingleVariable, MOI.Interval{Int}, n + 2) - _test_num_constraints(model, MOI.VectorOfVariables, MOI.Nonnegatives, n) + _test_num_constraints(model, MOI.VectorOfVariables, MOI.NonnegativeCone, n) @test (@inferred MOI.get( model, MOI.ListOfConstraintIndices{ @@ -452,7 +452,7 @@ end )) == scon_indices @test (@inferred MOI.get( model, - MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.Nonnegatives}(), + MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.NonnegativeCone}(), )) == vcon_indices end diff --git a/test/Bridges/lazy_bridge_optimizer.jl b/test/Bridges/lazy_bridge_optimizer.jl index 8a18d4574f..139e271ac1 100644 --- a/test/Bridges/lazy_bridge_optimizer.jl +++ b/test/Bridges/lazy_bridge_optimizer.jl @@ -60,7 +60,7 @@ MOIU.@model( StandardLPModel, (), (MOI.EqualTo, MOIT.UnknownScalarSet), - (MOI.Nonnegatives,), + (MOI.NonnegativeCone,), (), (), (MOI.ScalarAffineFunction,), @@ -349,7 +349,7 @@ MOIU.@model( SDPAModel, (), (MOI.EqualTo,), - (MOI.Nonnegatives, MOI.PositiveSemidefiniteConeTriangle), + (MOI.NonnegativeCone, MOI.PositiveSemidefiniteConeTriangle), (), (), (MOI.ScalarAffineFunction,), @@ -393,7 +393,7 @@ function MOI.supports_constraint( end function MOI.supports_add_constrained_variables( ::SDPAModel, - ::Type{MOI.Nonnegatives}, + ::Type{MOI.NonnegativeCone}, ) return true end @@ -578,7 +578,7 @@ end MOI.GreaterThan{T}, ) @test MOIB.bridge_type(bridged, MOI.GreaterThan{T}) == - MOIB.Variable.VectorizeBridge{T,MOI.Nonnegatives} + MOIB.Variable.VectorizeBridge{T,MOI.NonnegativeCone} @test !MOI.supports_constraint( bridged, MOI.SingleVariable, @@ -645,7 +645,7 @@ end MOI.LessThan{T}, 1, ( - (MOI.VectorOfVariables, MOI.Nonnegatives, 0), + (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), (MOI.VectorOfVariables, MOI.Nonpositives, 0), ), used_bridges = 2, @@ -771,7 +771,7 @@ Bridge graph with 1 variable nodes, 3 constraint nodes and 0 objective nodes. ) == MOIB.Constraint.VectorizeBridge{ T, MOI.VectorAffineFunction{T}, - MOI.Nonnegatives, + MOI.NonnegativeCone, MOI.ScalarAffineFunction{T}, } end @@ -1201,7 +1201,7 @@ MOIU.@model( (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan), ( MOI.Zeros, - MOI.Nonnegatives, + MOI.NonnegativeCone, MOI.Nonpositives, MOI.SecondOrderCone, MOI.NormInfinityCone, @@ -1242,7 +1242,7 @@ MOIU.@model( NoVariableModel, (MOI.ZeroOne, MOI.Integer), (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan), - (MOI.Zeros, MOI.Nonnegatives, MOI.Nonpositives, MOI.SecondOrderCone), + (MOI.Zeros, MOI.NonnegativeCone, MOI.Nonpositives, MOI.SecondOrderCone), (), (), (MOI.ScalarAffineFunction,), @@ -1296,14 +1296,14 @@ Bridge graph with 5 variable nodes, 11 constraint nodes and 0 objective nodes. [1] constrained variables in `MOI.RotatedSecondOrderCone` are supported (distance 2) by adding free variables and then constrain them, see (3). [2] constrained variables in `MOI.PositiveSemidefiniteConeTriangle` are not supported [3] constrained variables in `MOI.SecondOrderCone` are supported (distance 2) by adding free variables and then constrain them, see (1). - [4] constrained variables in `MOI.Nonnegatives` are supported (distance 2) by adding free variables and then constrain them, see (6). + [4] constrained variables in `MOI.NonnegativeCone` are supported (distance 2) by adding free variables and then constrain them, see (6). [5] constrained variables in `MOI.Interval{$T}` are supported (distance 3) by adding free variables and then constrain them, see (8). (1) `MOI.VectorOfVariables`-in-`MOI.SecondOrderCone` constraints are bridged (distance 1) by $(MOIB.Constraint.VectorFunctionizeBridge{T,MOI.SecondOrderCone}). (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.RotatedSecondOrderCone` constraints are bridged (distance 1) by $(MOIB.Constraint.RSOCtoSOCBridge{T,MOI.VectorAffineFunction{T},MOI.VectorAffineFunction{T}}). (3) `MOI.VectorOfVariables`-in-`MOI.RotatedSecondOrderCone` constraints are bridged (distance 1) by $(MOIB.Constraint.RSOCtoSOCBridge{T,MOI.VectorAffineFunction{T},MOI.VectorOfVariables}). (4) `MOI.VectorAffineFunction{$T}`-in-`MOI.PositiveSemidefiniteConeTriangle` constraints are not supported (5) `MOI.VectorOfVariables`-in-`MOI.PositiveSemidefiniteConeTriangle` constraints are not supported - (6) `MOI.VectorOfVariables`-in-`MOI.Nonnegatives` constraints are bridged (distance 1) by $(MOIB.Constraint.NonnegToNonposBridge{T,MOI.VectorAffineFunction{T},MOI.VectorOfVariables}). + (6) `MOI.VectorOfVariables`-in-`MOI.NonnegativeCone` constraints are bridged (distance 1) by $(MOIB.Constraint.NonnegToNonposBridge{T,MOI.VectorAffineFunction{T},MOI.VectorOfVariables}). (7) `MOI.SingleVariable`-in-`MOI.GreaterThan{$T}` constraints are bridged (distance 1) by $(MOIB.Constraint.GreaterToLessBridge{T,MOI.ScalarAffineFunction{T},MOI.SingleVariable}). (8) `MOI.SingleVariable`-in-`MOI.Interval{$T}` constraints are bridged (distance 2) by $(MOIB.Constraint.ScalarFunctionizeBridge{T,MOI.Interval{T}}). (9) `MOI.ScalarAffineFunction{$T}`-in-`MOI.Interval{$T}` constraints are bridged (distance 1) by $(MOIB.Constraint.SplitIntervalBridge{T,MOI.ScalarAffineFunction{T},MOI.Interval{T},MOI.GreaterThan{T},MOI.LessThan{T}}). @@ -1317,7 +1317,7 @@ MOIU.@model( OnlyNonnegVAF, (), (), - (MOI.Nonnegatives,), + (MOI.NonnegativeCone,), (), (), (), @@ -1444,12 +1444,12 @@ end end end -# Only supports GreaterThan and Nonnegatives +# Only supports GreaterThan and NonnegativeCone MOIU.@model( GreaterNonnegModel, (), (MOI.GreaterThan,), - (MOI.Nonnegatives,), + (MOI.NonnegativeCone,), (), (), (MOI.ScalarAffineFunction, MOI.ScalarQuadraticFunction), @@ -1470,7 +1470,7 @@ MOIU.@model( (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan, MOI.Interval), ( MOI.Zeros, - MOI.Nonnegatives, + MOI.NonnegativeCone, MOI.Nonpositives, MOI.SecondOrderCone, MOI.NormInfinityCone, @@ -1554,7 +1554,7 @@ MOIU.@model( ( MOI.Reals, MOI.Zeros, - MOI.Nonnegatives, + MOI.NonnegativeCone, MOI.Nonpositives, MOI.NormInfinityCone, MOI.NormOneCone, @@ -1600,7 +1600,7 @@ MOIU.@model( ( MOI.Reals, MOI.Zeros, - MOI.Nonnegatives, + MOI.NonnegativeCone, MOI.Nonpositives, MOI.NormInfinityCone, MOI.NormOneCone, @@ -1734,7 +1734,7 @@ end @testset "Supports" begin full_bridged_mock = MOIB.full_bridge_optimizer(mock, Float64) @testset "Mismatch vector/scalar" begin - for S in [MOI.Nonnegatives, MOI.Nonpositives, MOI.Zeros] + for S in [MOI.NonnegativeCone, MOI.Nonpositives, MOI.Zeros] @test !MOI.supports_constraint( full_bridged_mock, MOI.SingleVariable, @@ -1801,7 +1801,7 @@ end @test MOI.supports_constraint( full_bridged_greater_nonneg, F, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) end for F in [MOI.VectorOfVariables, MOI.VectorAffineFunction{Float64}] @@ -1895,7 +1895,7 @@ end end for S in [ MOI.Nonpositives, - MOI.Nonnegatives, + MOI.NonnegativeCone, MOI.Zeros, MOI.SecondOrderCone, ] diff --git a/test/DeprecatedTest/contconic.jl b/test/DeprecatedTest/contconic.jl index 09db6b3f1b..5cb5845e31 100644 --- a/test/DeprecatedTest/contconic.jl +++ b/test/DeprecatedTest/contconic.jl @@ -19,7 +19,7 @@ config = MOIT.Config() (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1.0, 0.0, 2.0], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0, 2, 0]], (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-3, -1]], ) @@ -35,7 +35,7 @@ config = MOIT.Config() (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [-4, -3, 16, 0], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => [[0]], + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0]], (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => [[0]], (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[7, 2, -4], [7]], @@ -104,7 +104,7 @@ end [2, -1, -1, -1], (MOI.VectorAffineFunction{Float64}, MOI.NormInfinityCone) => [vcat(1, fill(-inv(3), 3))], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [fill(inv(3), 3)], ) MOIT.norminf3test(mock, config) @@ -141,7 +141,7 @@ end [4, -1, -1, -1], (MOI.VectorAffineFunction{Float64}, MOI.NormOneCone) => [vcat(1, fill(-1, 3))], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [ones(3)], ) MOIT.normone3test(mock, config) @@ -170,7 +170,7 @@ end (MOI.VectorAffineFunction{Float64}, MOI.SecondOrderCone) => [[√2, 1, -1]], (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[√2]], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1.0]], ) MOIT.soc2ntest(mock, config) @@ -245,7 +245,7 @@ end [1.0; zeros(n - 1); ub; √ub; ones(2)], (MOI.SingleVariable, MOI.EqualTo{Float64}) => [-√ub / 4, -√ub / 4], - (MOI.VectorOfVariables, MOI.Nonnegatives) => [zeros(n)], + (MOI.VectorOfVariables, MOI.NonnegativeCone) => [zeros(n)], (MOI.SingleVariable, MOI.GreaterThan{Float64}) => [0.0], (MOI.SingleVariable, MOI.LessThan{Float64}) => [-1 / (2 * √ub)], (MOI.VectorAffineFunction{Float64}, MOI.RotatedSecondOrderCone) => [ @@ -359,7 +359,7 @@ end [-1.0, exp(-0.3) * 0.3], (MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64}) => [-exp(-0.3) * 0.3], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => [ + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [ [0.0, exp(-0.3), exp(-0.3) / 2], [0.0, 0.0, exp(-0.3) / 2], ], @@ -581,7 +581,7 @@ end mock, [0, 1, 0, 1, 1], (MOI.SingleVariable, MOI.EqualTo{Float64}) => [2], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1, 1]], (MOI.VectorOfVariables, MOI.LogDetConeTriangle) => [[-1, -2, 1, 0, 1]], @@ -593,7 +593,7 @@ end mock, [0, 1, 0, 1, 1], (MOI.SingleVariable, MOI.EqualTo{Float64}) => [2], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1, 1]], (MOI.VectorAffineFunction{Float64}, MOI.LogDetConeTriangle) => [[-1, -2, 1, 0, 1]], @@ -612,7 +612,7 @@ end mock, [0, 1, 0, 0, 1, 1], (MOI.SingleVariable, MOI.EqualTo{Float64}) => [2], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1, 1]], (MOI.VectorOfVariables, MOI.LogDetConeSquare) => [[-1, -2, 1, 0, 0, 1]], @@ -624,7 +624,7 @@ end mock, [0, 1, 0, 0, 1, 1], (MOI.SingleVariable, MOI.EqualTo{Float64}) => [2], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1, 1]], (MOI.VectorAffineFunction{Float64}, MOI.LogDetConeSquare) => [[-1, -2, 1, 0, 0, 1]], @@ -644,7 +644,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 1, 0, 1], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0.5, 0.5]], (MOI.VectorOfVariables, MOI.RootDetConeTriangle) => [[-1.0, 0.5, 0.0, 0.5]], @@ -654,7 +654,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 1, 0, 1], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0.5, 0.5]], (MOI.VectorAffineFunction{Float64}, MOI.RootDetConeTriangle) => [[-1.0, 0.5, 0.0, 0.5]], @@ -672,7 +672,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 1, 0, 0, 1], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0.5, 0.5]], (MOI.VectorOfVariables, MOI.RootDetConeSquare) => [[-1.0, 0.5, 0.0, 0.0, 0.5]], @@ -682,7 +682,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 1, 0, 0, 1], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0.5, 0.5]], (MOI.VectorAffineFunction{Float64}, MOI.RootDetConeSquare) => [[-1.0, 0.5, 0.0, 0.0, 0.5]], diff --git a/test/DeprecatedTest/contquadratic.jl b/test/DeprecatedTest/contquadratic.jl index 049ce56a92..99fddc52be 100644 --- a/test/DeprecatedTest/contquadratic.jl +++ b/test/DeprecatedTest/contquadratic.jl @@ -57,7 +57,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1 / 2, 7 / 4], - (MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [zeros(2)], (MOI.ScalarQuadraticFunction{Float64}, MOI.LessThan{Float64}) => [-1.0], diff --git a/test/FileFormats/CBF/CBF.jl b/test/FileFormats/CBF/CBF.jl index b01eec48fd..5db4ea7baa 100644 --- a/test/FileFormats/CBF/CBF.jl +++ b/test/FileFormats/CBF/CBF.jl @@ -31,7 +31,7 @@ function _set_var_and_con_names(model::MOI.ModelLike) for S in [ MOI.Reals, MOI.Zeros, - MOI.Nonnegatives, + MOI.NonnegativeCone, MOI.Nonpositives, MOI.SecondOrderCone, MOI.RotatedSecondOrderCone, @@ -224,11 +224,11 @@ const _WRITE_READ_MODELS = [ """, ), ( - "VectorOfVariables in Nonnegatives", + "VectorOfVariables in NonnegativeCone", """ variables: x, y minobjective: x - c1: [x, y] in Nonnegatives(2) + c1: [x, y] in NonnegativeCone(2) """, ), ( @@ -256,11 +256,11 @@ const _WRITE_READ_MODELS = [ """, ), ( - "VectorAffineFunction in Nonnegatives", + "VectorAffineFunction in NonnegativeCone", """ variables: x, y minobjective: 1.2x - c1: [1.1 * x, y + 1] in Nonnegatives(2) + c1: [1.1 * x, y + 1] in NonnegativeCone(2) """, ), ( @@ -408,7 +408,7 @@ const _EXAMPLE_MODELS = [ variables: X, Y, Z, x, y minobjective: 1 + x + y + X + Z c1: [X, Y, Z] in PositiveSemidefiniteConeTriangle(2) - c2: [2Y + -1x + -1y] in Nonnegatives(1) + c2: [2Y + -1x + -1y] in NonnegativeCone(1) c3: [3y + -1, x + y, 3x + -1] in PositiveSemidefiniteConeTriangle(2) """, ), @@ -418,7 +418,7 @@ const _EXAMPLE_MODELS = [ variables: a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p maxobjective: a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + -1 c1: [b] in Zeros(1) - c2: [c] in Nonnegatives(1) + c2: [c] in NonnegativeCone(1) c3: [d] in Nonpositives(1) c4: [e, f, g] in SecondOrderCone(3) c5: [h, i, j] in RotatedSecondOrderCone(3) diff --git a/test/FileFormats/MOF/MOF.jl b/test/FileFormats/MOF/MOF.jl index 13142ca2a0..b02be57e70 100644 --- a/test/FileFormats/MOF/MOF.jl +++ b/test/FileFormats/MOF/MOF.jl @@ -556,7 +556,7 @@ function test_Nonnegatives() """ variables: x, y, z minobjective: x -c1: [x, y, z] in Nonnegatives(3) +c1: [x, y, z] in NonnegativeCone(3) """, ["x", "y", "z"], ["c1"], @@ -636,7 +636,7 @@ function test_vectorquadratic_in_nonnegatives() """ variables: x, y minobjective: x -c1: [1.0*x*x + -2.0x + 1.0, 2.0y + -4.0] in Nonnegatives(2) +c1: [1.0*x*x + -2.0x + 1.0, 2.0y + -4.0] in NonnegativeCone(2) """, ["x", "y"], ["c1"], diff --git a/test/FileFormats/SDPA/SDPA.jl b/test/FileFormats/SDPA/SDPA.jl index 2d64615903..04242eb42c 100644 --- a/test/FileFormats/SDPA/SDPA.jl +++ b/test/FileFormats/SDPA/SDPA.jl @@ -33,7 +33,7 @@ function _set_var_and_con_names(model::MOI.ModelLike) model, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonnegatives, + MOI.NonnegativeCone, }(), ), MOI.get( @@ -119,7 +119,7 @@ function test_delete() MOI.add_constraint( model, MOIU.vectorize([one(T) * fy]), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) err = ErrorException( "Non-contiguous variable indices not supported. This might be due to deleted variables.", @@ -232,11 +232,11 @@ const _WRITE_READ_MODELS = [ """, ), ( - "VectorAffineFunction in Nonnegatives", + "VectorAffineFunction in NonnegativeCone", """ variables: x, y minobjective: 1.2x - c1: [1.1 * x, y + 1] in Nonnegatives(2) + c1: [1.1 * x, y + 1] in NonnegativeCone(2) """, ), ( @@ -280,7 +280,7 @@ const _EXAMPLE_MODELS = [ minobjective: 1x + -2y + -1z c1: [1x, 1y, 1z] in PositiveSemidefiniteConeTriangle(2) c2: [1z, 1x, 2.1] in PositiveSemidefiniteConeTriangle(2) - c3: [1x + 1y + 1z + -1, -1x + -1y + -1z + 8] in Nonnegatives(2) + c3: [1x + 1y + 1z + -1, -1x + -1y + -1z + 8] in NonnegativeCone(2) x in Integer() y in Integer() z in Integer() diff --git a/test/Utilities/cachingoptimizer.jl b/test/Utilities/cachingoptimizer.jl index 4b70ac4905..87911920e8 100644 --- a/test/Utilities/cachingoptimizer.jl +++ b/test/Utilities/cachingoptimizer.jl @@ -642,19 +642,19 @@ function _constrained_variables_test(model) @test !MOI.supports_add_constrained_variables(model, MOI.Reals) @test MOI.supports_add_constrained_variable(model, MOI.ZeroOne) @test !MOI.supports_constraint(model, MOI.SingleVariable, MOI.ZeroOne) - @test MOI.supports_add_constrained_variables(model, MOI.Nonnegatives) + @test MOI.supports_add_constrained_variables(model, MOI.NonnegativeCone) @test !MOI.supports_constraint( model, MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) scalar_set = MOI.ZeroOne() x, cx = MOI.add_constrained_variable(model, scalar_set) - vector_set = MOI.Nonnegatives(2) + vector_set = MOI.NonnegativeCone(2) y, cy = MOI.add_constrained_variables(model, vector_set) constraint_types = Set([ (MOI.SingleVariable, MOI.ZeroOne), - (MOI.VectorOfVariables, MOI.Nonnegatives), + (MOI.VectorOfVariables, MOI.NonnegativeCone), ]) @test Set(MOI.get(model.model_cache, MOI.ListOfConstraintTypesPresent())) == constraint_types diff --git a/test/Utilities/copy.jl b/test/Utilities/copy.jl index 8e3a19f07f..71178384ca 100644 --- a/test/Utilities/copy.jl +++ b/test/Utilities/copy.jl @@ -143,7 +143,7 @@ function test_issue_849() a = MOI.add_variable(model) b, c = MOI.add_variables(model, 2) x, cx = MOI.add_constrained_variable(model, MOI.GreaterThan(0.0)) - y, cy = MOI.add_constrained_variables(model, MOI.Nonnegatives(1)) + y, cy = MOI.add_constrained_variables(model, MOI.NonnegativeCone(1)) nlp_data = MOI.NLPBlockData( [MOI.NLPBoundsPair(0.0, 1.0) for i in 1:5], DummyEvaluator(), @@ -268,7 +268,7 @@ end function test_ConstrainedVariablesModel_allocate_true() src = MOIU.Model{Int}() x = MOI.add_variables(src, 3) - cx = MOI.add_constraint(src, [x[1], x[3], x[1], x[2]], MOI.Nonnegatives(4)) + cx = MOI.add_constraint(src, [x[1], x[3], x[1], x[2]], MOI.NonnegativeCone(4)) y, cy = MOI.add_constrained_variables(src, MOI.Nonpositives(3)) dest = ConstrainedVariablesModel(true, Bool[]) idxmap = MOI.copy_to(dest, src) @@ -284,7 +284,7 @@ end function test_ConstrainedVariablesModel_allocate_false() src = MOIU.Model{Int}() x = MOI.add_variables(src, 3) - cx = MOI.add_constraint(src, [x[1], x[3], x[1], x[2]], MOI.Nonnegatives(4)) + cx = MOI.add_constraint(src, [x[1], x[3], x[1], x[2]], MOI.NonnegativeCone(4)) y, cy = MOI.add_constrained_variables(src, MOI.Nonpositives(3)) dest = ConstrainedVariablesModel(false, Bool[]) idxmap = MOI.copy_to(dest, src) @@ -362,14 +362,14 @@ end function MOI.supports_constraint( ::OrderConstrainedVariablesModel, ::Type{MOI.VectorOfVariables}, - ::Type{MOI.Nonnegatives}, + ::Type{MOI.NonnegativeCone}, ) return false end function MOI.supports_add_constrained_variables( ::OrderConstrainedVariablesModel, - ::Type{MOI.Nonnegatives}, + ::Type{MOI.NonnegativeCone}, ) return true end @@ -377,7 +377,7 @@ end function MOI.supports_constraint( ::OrderConstrainedVariablesModel, ::Type{MOI.VectorOfVariables}, - ::Type{MOI.Nonnegatives}, + ::Type{MOI.NonnegativeCone}, ) return true end @@ -392,14 +392,14 @@ end function MOI.supports_constraint( ::ReverseOrderConstrainedVariablesModel, ::Type{MOI.VectorOfVariables}, - ::Type{MOI.Nonnegatives}, + ::Type{MOI.NonnegativeCone}, ) return true end function MOI.supports_add_constrained_variables( ::ReverseOrderConstrainedVariablesModel, - ::Type{MOI.Nonnegatives}, + ::Type{MOI.NonnegativeCone}, ) return false end @@ -407,7 +407,7 @@ end function MOI.supports_constraint( ::ReverseOrderConstrainedVariablesModel, ::Type{MOI.VectorOfVariables}, - ::Type{MOI.Nonnegatives}, + ::Type{MOI.NonnegativeCone}, ) return false end @@ -422,7 +422,7 @@ end function MOI.supports_constraint( ::OrderConstrainedVariablesModel, ::Type{MOI.VectorAffineFunction{Float64}}, - ::Type{MOI.Nonnegatives}, + ::Type{MOI.NonnegativeCone}, ) return true end @@ -504,7 +504,7 @@ function test_create_variables_using_supports_add_constrained_variable() # With vectors src = MOIU.Model{Float64}() a, c1 = MOI.add_constrained_variables(src, MOI.Nonpositives(3)) - c2 = MOI.add_constraint(src, a, MOI.Nonnegatives(3)) + c2 = MOI.add_constraint(src, a, MOI.NonnegativeCone(3)) dest = OrderConstrainedVariablesModel() index_map = MOI.copy_to(dest, src) @@ -516,7 +516,7 @@ function test_create_variables_using_supports_add_constrained_variable() @test typeof(c1) == typeof(dest.constraintIndices[1]) @test typeof(c2) == typeof(dest.constraintIndices[2]) - b, cb = MOI.add_constrained_variables(src, MOI.Nonnegatives(2)) + b, cb = MOI.add_constrained_variables(src, MOI.NonnegativeCone(2)) c3 = MOI.add_constraint(src, b, MOI.Zeros(2)) d, cd = MOI.add_constrained_variables(src, MOI.Zeros(2)) @@ -526,20 +526,20 @@ function test_create_variables_using_supports_add_constrained_variable() bridged_dest = MOI.Bridges.full_bridge_optimizer(dest, Float64) @test MOIU.sorted_variable_sets_by_cost(bridged_dest, src) == [ (MOI.VectorOfVariables, MOI.Zeros), - (MOI.VectorOfVariables, MOI.Nonnegatives), + (MOI.VectorOfVariables, MOI.NonnegativeCone), (MOI.VectorOfVariables, MOI.Nonpositives), ] - @test MOI.supports_add_constrained_variables(bridged_dest, MOI.Nonnegatives) - @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.Nonnegatives}()) == + @test MOI.supports_add_constrained_variables(bridged_dest, MOI.NonnegativeCone) + @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.NonnegativeCone}()) == 0.0 @test MOI.supports_constraint( bridged_dest, MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @test MOI.get( bridged_dest, - MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.Nonnegatives}(), + MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.NonnegativeCone}(), ) == 0.0 @test MOI.supports_add_constrained_variables(bridged_dest, MOI.Nonpositives) @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.Nonpositives}()) == @@ -572,19 +572,19 @@ function test_create_variables_using_supports_add_constrained_variable() @test MOIU.sorted_variable_sets_by_cost(bridged_dest, src) == [ (MOI.VectorOfVariables, MOI.Zeros), (MOI.VectorOfVariables, MOI.Nonpositives), - (MOI.VectorOfVariables, MOI.Nonnegatives), + (MOI.VectorOfVariables, MOI.NonnegativeCone), ] - @test MOI.supports_add_constrained_variables(bridged_dest, MOI.Nonnegatives) - @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.Nonnegatives}()) == + @test MOI.supports_add_constrained_variables(bridged_dest, MOI.NonnegativeCone) + @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.NonnegativeCone}()) == 2.0 @test MOI.supports_constraint( bridged_dest, MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @test MOI.get( bridged_dest, - MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.Nonnegatives}(), + MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.NonnegativeCone}(), ) == 1.0 @test MOI.supports_add_constrained_variables(bridged_dest, MOI.Nonpositives) @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.Nonpositives}()) == diff --git a/test/Utilities/matrix_of_constraints.jl b/test/Utilities/matrix_of_constraints.jl index 4259f72869..b7b0a73091 100644 --- a/test/Utilities/matrix_of_constraints.jl +++ b/test/Utilities/matrix_of_constraints.jl @@ -264,9 +264,9 @@ function test_contlinear(Indexing) end end -MOIU.@product_of_sets(Nonneg, MOI.Nonnegatives) -MOIU.@product_of_sets(NonposNonneg, MOI.Nonpositives, MOI.Nonnegatives) -MOIU.@product_of_sets(NonnegNonpos, MOI.Nonnegatives, MOI.Nonpositives) +MOIU.@product_of_sets(Nonneg, MOI.NonnegativeCone) +MOIU.@product_of_sets(NonposNonneg, MOI.Nonpositives, MOI.NonnegativeCone) +MOIU.@product_of_sets(NonnegNonpos, MOI.NonnegativeCone, MOI.Nonpositives) function test_contconic() test_contconic(MOIU.OneBasedIndexing) @@ -326,7 +326,7 @@ function test_contconic(Indexing) ) do optimizer return _lin3_query( optimizer, - [(F, MOI.Nonnegatives), (F, MOI.Nonpositives)], + [(F, MOI.NonnegativeCone), (F, MOI.Nonpositives)], ) end b = [1.0, -1.0] @@ -341,7 +341,7 @@ function test_contconic(Indexing) ) do optimizer return _lin3_query( optimizer, - [(F, MOI.Nonpositives), (F, MOI.Nonnegatives)], + [(F, MOI.Nonpositives), (F, MOI.NonnegativeCone)], ) end # Here, we test that it works of some constraints are bridged but not all. @@ -356,7 +356,7 @@ function test_contconic(Indexing) true, Indexing, ) do optimizer - return _lin3_query(optimizer, [(F, MOI.Nonnegatives)]) + return _lin3_query(optimizer, [(F, MOI.NonnegativeCone)]) end end @@ -428,7 +428,7 @@ function test_empty() model = MOIU.GenericOptimizer{ T, VoVorVAff{T}{ - MOIU.VectorOfConstraints{MOI.VectorOfVariables,MOI.Nonnegatives}, + MOIU.VectorOfConstraints{MOI.VectorOfVariables,MOI.NonnegativeCone}, MOIU.MatrixOfConstraints{ T, MOIU.MutableSparseMatrixCSC{T,Int,Indexing}, @@ -485,7 +485,7 @@ function test_copy(Indexing) VoVorSAfforVAff{T}{ MOIU.VectorOfConstraints{ MOI.VectorOfVariables, - MOI.Nonnegatives, + MOI.NonnegativeCone, }, MOIU.MatrixOfConstraints{ T, @@ -529,7 +529,7 @@ end MOIU.@struct_of_constraints_by_set_types( ZerosOrNot, MOI.Zeros, - Union{MOI.Nonnegatives,MOI.Nonpositives}, + Union{MOI.NonnegativeCone,MOI.Nonpositives}, ) function test_multicone() @@ -561,7 +561,7 @@ function test_multicone() MOI.add_constraint( model, MOIU.vectorize([T(3) * fy + T(1)]), - MOI.Nonnegatives(1), + MOI.NonnegativeCone(1), ) MOI.add_constraint( model, diff --git a/test/Utilities/mockoptimizer.jl b/test/Utilities/mockoptimizer.jl index 774a8aedf5..a4b944aadd 100644 --- a/test/Utilities/mockoptimizer.jl +++ b/test/Utilities/mockoptimizer.jl @@ -32,7 +32,7 @@ MOI.supports_add_constrained_variables(::NoFreeModel, ::Type{MOI.Reals}) = false optimizer, MOIT.UnknownScalarSet{Float64}, ) - @test MOI.supports_add_constrained_variables(optimizer, MOI.Nonnegatives) + @test MOI.supports_add_constrained_variables(optimizer, MOI.NonnegativeCone) @test !MOI.supports_add_constrained_variables( optimizer, MOIT.UnknownVectorSet, @@ -45,7 +45,7 @@ MOI.supports_add_constrained_variables(::NoFreeModel, ::Type{MOI.Reals}) = false ) @test !MOI.supports_add_constrained_variables( nofree_optimizer, - MOI.Nonnegatives, + MOI.NonnegativeCone, ) @test !MOI.supports_add_constrained_variables(nofree_optimizer, MOI.Reals) end diff --git a/test/Utilities/product_of_sets.jl b/test/Utilities/product_of_sets.jl index 45b6319c64..94f7b6bb4f 100644 --- a/test/Utilities/product_of_sets.jl +++ b/test/Utilities/product_of_sets.jl @@ -129,14 +129,14 @@ end MOI.Utilities.@product_of_sets( _VectorSets, MOI.Nonpositives, - MOI.Nonnegatives, + MOI.NonnegativeCone, MOI.EqualTo{T}, ) function test_vector_set_index() sets = _VectorSets{Float64}() @test MOI.Utilities.set_index(sets, MOI.Nonpositives) == 1 - @test MOI.Utilities.set_index(sets, MOI.Nonnegatives) == 2 + @test MOI.Utilities.set_index(sets, MOI.NonnegativeCone) == 2 @test MOI.Utilities.set_index(sets, MOI.EqualTo{Float64}) == 3 @test MOI.Utilities.set_index(sets, MOI.LessThan{Float64}) === nothing end @@ -144,14 +144,14 @@ end function test_vector_set_types() sets = _VectorSets{Float64}() @test MOI.Utilities.set_types(sets) == - [MOI.Nonpositives, MOI.Nonnegatives, MOI.EqualTo{Float64}] + [MOI.Nonpositives, MOI.NonnegativeCone, MOI.EqualTo{Float64}] end function test_vector_basic() sets = _VectorSets{Float64}() nonneg_i = MOI.Utilities.add_set( sets, - MOI.Utilities.set_index(sets, MOI.Nonnegatives), + MOI.Utilities.set_index(sets, MOI.NonnegativeCone), 2, ) equalto_i = MOI.Utilities.add_set( @@ -160,8 +160,8 @@ function test_vector_basic() ) MOI.Utilities.final_touch(sets) VAF = MOI.VectorAffineFunction{Float64} - @test !MOI.is_valid(sets, MOI.ConstraintIndex{VAF,MOI.Nonnegatives}(12345)) - nonneg_ci = MOI.ConstraintIndex{VAF,MOI.Nonnegatives}(nonneg_i) + @test !MOI.is_valid(sets, MOI.ConstraintIndex{VAF,MOI.NonnegativeCone}(12345)) + nonneg_ci = MOI.ConstraintIndex{VAF,MOI.NonnegativeCone}(nonneg_i) @test MOI.is_valid(sets, nonneg_ci) @test MOI.Utilities.rows(sets, nonneg_ci) == 1:2 SAF = MOI.ScalarAffineFunction{Float64} diff --git a/test/errors.jl b/test/errors.jl index eda32a23a9..345626f673 100644 --- a/test/errors.jl +++ b/test/errors.jl @@ -37,7 +37,7 @@ function test_errors_inconsistent_vectorscalar() ) @test_throws( MOI.ErrorException, - MOI.add_constraint(model, func, MOI.Nonnegatives(2)) + MOI.add_constraint(model, func, MOI.NonnegativeCone(2)) ) return end @@ -79,7 +79,7 @@ function test_errors_UnsupportedConstraint_shortcut() MOI.add_constraint(model, vi, MOI.EqualTo(0)) end @test_throws MOI.UnsupportedConstraint begin - MOI.add_constraint(model, [vi, vi], MOI.Nonnegatives(2)) + MOI.add_constraint(model, [vi, vi], MOI.NonnegativeCone(2)) end @test_throws MOI.UnsupportedConstraint begin MOI.add_constraints(model, [vi, vi], [MOI.EqualTo(0), MOI.EqualTo(0)]) diff --git a/test/hygiene.jl b/test/hygiene.jl index 376dab60d5..fe61c281c3 100644 --- a/test/hygiene.jl +++ b/test/hygiene.jl @@ -13,7 +13,7 @@ MathOptInterface.Utilities.@model( LPModel, # Name of model (), # untyped scalar sets (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan, MOI.Interval), # typed scalar sets - (MOI.Zeros, MOI.Nonnegatives, MOI.Nonpositives), # untyped vector sets + (MOI.Zeros, MOI.NonnegativeCone, MOI.Nonpositives), # untyped vector sets (), # typed vector sets (), # untyped scalar functions (MOI.ScalarAffineFunction,), # typed scalar functions diff --git a/test/sets.jl b/test/sets.jl index 7f8fcab254..6c62e2005b 100644 --- a/test/sets.jl +++ b/test/sets.jl @@ -118,7 +118,7 @@ function test_sets_DimensionMismatch() for (S, min_dimension) in ( (MOI.Reals, 0), (MOI.Zeros, 0), - (MOI.Nonnegatives, 0), + (MOI.NonnegativeCone, 0), (MOI.Nonpositives, 0), (MOI.NormInfinityCone, 1), (MOI.NormOneCone, 1), @@ -172,8 +172,8 @@ function test_sets_dual_nonpositives() end function test_sets_dual_nonnegatives() - nonnegatives3 = MOI.Nonnegatives(3) - nonnegatives4 = MOI.Nonnegatives(4) + nonnegatives3 = MOI.NonnegativeCone(3) + nonnegatives4 = MOI.NonnegativeCone(4) _self_dual_set_test(nonnegatives3) @test MOI.dual_set(nonnegatives3) != nonnegatives4 _self_dual_set_test(nonnegatives4) From 0567be1d6765efb1b356beec28bc0559da57b25f Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 18 Jul 2021 05:32:09 +0200 Subject: [PATCH 2/5] Rename Nonpositives to NonpositiveCone. --- docs/src/manual/constraints.md | 2 +- docs/src/manual/standard_form.md | 2 +- docs/src/reference/standard_form.md | 2 +- src/Bridges/Constraint/flip_sign.jl | 20 +++--- src/Bridges/Constraint/interval.jl | 6 +- src/Bridges/Constraint/vectorize.jl | 4 +- src/Bridges/Variable/flip_sign.jl | 6 +- src/Bridges/flip_sign.jl | 4 +- .../UnitTests/basic_constraint_tests.jl | 12 ++-- src/DeprecatedTest/UnitTests/constraints.jl | 10 +-- src/DeprecatedTest/UnitTests/modifications.jl | 8 +-- src/DeprecatedTest/contconic.jl | 54 ++++++++-------- src/DeprecatedTest/contlinear.jl | 10 +-- src/DeprecatedTest/modellike.jl | 30 ++++----- src/FileFormats/CBF/CBF.jl | 2 +- src/FileFormats/CBF/read.jl | 2 +- src/FileFormats/CBF/write.jl | 4 +- src/FileFormats/MOF/MOF.jl | 2 +- src/FileFormats/MOF/mof.0.6.schema.json | 4 +- src/FileFormats/MOF/read.jl | 6 +- src/FileFormats/MOF/write.jl | 2 +- src/Test/test_basic_constraint.jl | 4 +- src/Test/test_conic.jl | 60 +++++++++--------- src/Test/test_constraint.jl | 6 +- src/Test/test_linear.jl | 6 +- src/Test/test_model.jl | 30 ++++----- src/Test/test_modification.jl | 14 ++--- src/Utilities/model.jl | 8 +-- src/Utilities/precompile.jl | 2 +- src/Utilities/product_of_sets.jl | 2 +- src/Utilities/sets.jl | 6 +- src/sets.jl | 18 +++--- test/Bridges/Constraint/flip_sign.jl | 10 +-- test/Bridges/Constraint/functionize.jl | 4 +- test/Bridges/Constraint/interval.jl | 4 +- test/Bridges/Constraint/scalarize.jl | 6 +- test/Bridges/Constraint/slack.jl | 18 +++--- test/Bridges/Constraint/vectorize.jl | 6 +- test/Bridges/Variable/flip_sign.jl | 10 +-- test/Bridges/Variable/free.jl | 16 ++--- test/Bridges/Variable/vectorize.jl | 8 +-- test/Bridges/bridge_optimizer.jl | 2 +- test/Bridges/lazy_bridge_optimizer.jl | 62 +++++++++---------- test/DeprecatedTest/contconic.jl | 6 +- test/DeprecatedTest/unit.jl | 2 +- test/FileFormats/CBF/CBF.jl | 12 ++-- test/FileFormats/MOF/MOF.jl | 2 +- test/Utilities/copy.jl | 34 +++++----- test/Utilities/matrix_of_constraints.jl | 14 ++--- test/Utilities/model.jl | 10 +-- test/Utilities/product_of_sets.jl | 8 +-- test/hygiene.jl | 2 +- test/sets.jl | 6 +- 53 files changed, 295 insertions(+), 295 deletions(-) diff --git a/docs/src/manual/constraints.md b/docs/src/manual/constraints.md index 2d6c58056f..a6b5ae92de 100644 --- a/docs/src/manual/constraints.md +++ b/docs/src/manual/constraints.md @@ -109,7 +109,7 @@ nonpositive) real numbers. | ``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` | `Nonpositives` | +| ``Ax + b \in \mathbb{R}_-^n`` | `VectorAffineFunction` | `NonpositiveCone` | | ``Ax + b = 0`` | `VectorAffineFunction` | `Zeros` | By convention, solvers are not expected to support nonzero constant terms in the diff --git a/docs/src/manual/standard_form.md b/docs/src/manual/standard_form.md index efb36fa69e..3356661179 100644 --- a/docs/src/manual/standard_form.md +++ b/docs/src/manual/standard_form.md @@ -76,7 +76,7 @@ The vector-valued set types implemented in MathOptInterface.jl are: * [`Zeros(dimension)`](@ref MathOptInterface.Zeros): ``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 \}`` diff --git a/docs/src/reference/standard_form.md b/docs/src/reference/standard_form.md index c53d9f09b3..af687494d0 100644 --- a/docs/src/reference/standard_form.md +++ b/docs/src/reference/standard_form.md @@ -76,7 +76,7 @@ List of recognized vector sets. Reals Zeros NonnegativeCone -Nonpositives +NonpositiveCone NormInfinityCone NormOneCone SecondOrderCone diff --git a/src/Bridges/Constraint/flip_sign.jl b/src/Bridges/Constraint/flip_sign.jl index 5f22b8214e..2c7f422d07 100644 --- a/src/Bridges/Constraint/flip_sign.jl +++ b/src/Bridges/Constraint/flip_sign.jl @@ -136,17 +136,17 @@ end T, F<:MOI.AbstractVectorFunction, G<:MOI.AbstractVectorFunction - } <: FlipSignBridge{T, MOI.NonnegativeCone, MOI.Nonpositives, F, G} + } <: FlipSignBridge{T, MOI.NonnegativeCone, MOI.NonpositiveCone, F, G} -Transforms a `G`-in-`NonnegativeCone` 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.NonnegativeCone,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( @@ -163,20 +163,20 @@ end T, F<:MOI.AbstractVectorFunction, G<:MOI.AbstractVectorFunction, - } <: FlipSignBridge{T, MOI.Nonpositives, MOI.NonnegativeCone, F, G} + } <: FlipSignBridge{T, MOI.NonpositiveCone, MOI.NonnegativeCone, F, G} -Transforms a `G`-in-`Nonpositives` constraint into a `F`-in-`NonnegativeCone` +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.NonnegativeCone,F,G} +} <: FlipSignBridge{T,MOI.NonpositiveCone,MOI.NonnegativeCone,F,G} constraint::CI{F,MOI.NonnegativeCone} end -function MOIB.map_set(::Type{<:NonposToNonnegBridge}, set::MOI.Nonpositives) +function MOIB.map_set(::Type{<:NonposToNonnegBridge}, set::MOI.NonpositiveCone) return MOI.NonnegativeCone(set.dimension) end @@ -184,13 +184,13 @@ function MOIB.inverse_map_set( ::Type{<:NonposToNonnegBridge}, 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} diff --git a/src/Bridges/Constraint/interval.jl b/src/Bridges/Constraint/interval.jl index 2603a5b574..4ef7cee603 100644 --- a/src/Bridges/Constraint/interval.jl +++ b/src/Bridges/Constraint/interval.jl @@ -3,7 +3,7 @@ _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.NonnegativeCone(set.dimension) -_upper_set(set::MOI.Zeros) = MOI.Nonpositives(set.dimension) +_upper_set(set::MOI.Zeros) = MOI.NonpositiveCone(set.dimension) """ SplitIntervalBridge{T, F, S, LS, US} @@ -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.NonnegativeCone` and `US = MOI.Nonpositives`. +* `S = MOI.Zeros`, `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 @@ -79,7 +79,7 @@ function concrete_bridge_type( F::Type{<:MOI.AbstractVectorFunction}, ::Type{MOI.Zeros}, ) where {T} - return SplitIntervalBridge{T,F,MOI.Zeros,MOI.NonnegativeCone,MOI.Nonpositives} + return SplitIntervalBridge{T,F,MOI.Zeros,MOI.NonnegativeCone,MOI.NonpositiveCone} end # Attributes, Bridge acting as a model diff --git a/src/Bridges/Constraint/vectorize.jl b/src/Bridges/Constraint/vectorize.jl index 0426d7c8c3..378c27e93a 100644 --- a/src/Bridges/Constraint/vectorize.jl +++ b/src/Bridges/Constraint/vectorize.jl @@ -7,8 +7,8 @@ Transforms a constraint `G`-in-`scalar_set_type(S, T)` where ## Examples The constraint `SingleVariable`-in-`LessThan{Float64}` becomes -`VectorAffineFunction{Float64}`-in-`Nonpositives`, where `T = Float64`, -`F = VectorAffineFunction{Float64}`, `S = Nonpositives`, and +`VectorAffineFunction{Float64}`-in-`NonpositiveCone`, where `T = Float64`, +`F = VectorAffineFunction{Float64}`, `S = NonpositiveCone`, and `G = SingleVariable`. """ mutable struct VectorizeBridge{T,F,S,G} <: AbstractBridge diff --git a/src/Bridges/Variable/flip_sign.jl b/src/Bridges/Variable/flip_sign.jl index 553060038a..e148d461fe 100644 --- a/src/Bridges/Variable/flip_sign.jl +++ b/src/Bridges/Variable/flip_sign.jl @@ -11,13 +11,13 @@ abstract type FlipSignBridge{T,S1<:MOI.AbstractSet,S2<:MOI.AbstractSet} <: """ NonposToNonnegBridge{T} <: - FlipSignBridge{T, MOI.Nonpositives, MOI.NonnegativeCone} + FlipSignBridge{T, MOI.NonpositiveCone, MOI.NonnegativeCone} -Transforms constrained variables in `Nonpositives` into constrained variables in +Transforms constrained variables in `NonpositiveCone` into constrained variables in `NonnegativeCone`. """ struct NonposToNonnegBridge{T} <: - FlipSignBridge{T,MOI.Nonpositives,MOI.NonnegativeCone} + FlipSignBridge{T,MOI.NonpositiveCone,MOI.NonnegativeCone} variables::Vector{MOI.VariableIndex} constraint::MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.NonnegativeCone} end diff --git a/src/Bridges/flip_sign.jl b/src/Bridges/flip_sign.jl index c1cae6477b..7b3b06b934 100644 --- a/src/Bridges/flip_sign.jl +++ b/src/Bridges/flip_sign.jl @@ -2,10 +2,10 @@ const _NonnegToNonposMap{T} = Union{Variable.NonposToNonnegBridge{T},Constraint.NonnegToNonposBridge{T}} function map_set(::Type{<:_NonnegToNonposMap}, set::MOI.NonnegativeCone) - return MOI.Nonpositives(set.dimension) + return MOI.NonpositiveCone(set.dimension) end -function inverse_map_set(::Type{<:_NonnegToNonposMap}, set::MOI.Nonpositives) +function inverse_map_set(::Type{<:_NonnegToNonposMap}, set::MOI.NonpositiveCone) return MOI.NonnegativeCone(set.dimension) end diff --git a/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl b/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl index 1205666917..fc3cf646e7 100644 --- a/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl +++ b/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl @@ -57,8 +57,8 @@ const BasicConstraintTests = Dict( (dummy_vectorofvariables, 2, MOI.SOS2([1.0, 2.0])), (MOI.VectorOfVariables, MOI.Zeros) => (dummy_vectorofvariables, 2, MOI.Zeros(2)), - (MOI.VectorOfVariables, MOI.Nonpositives) => - (dummy_vectorofvariables, 2, MOI.Nonpositives(2)), + (MOI.VectorOfVariables, MOI.NonpositiveCone) => + (dummy_vectorofvariables, 2, MOI.NonpositiveCone(2)), (MOI.VectorOfVariables, MOI.NonnegativeCone) => (dummy_vectorofvariables, 2, MOI.NonnegativeCone(2)), (MOI.VectorOfVariables, MOI.NormInfinityCone) => @@ -118,8 +118,8 @@ const BasicConstraintTests = Dict( (dummy_scalar_quadratic, 1, MOI.Interval(1.0, 2.0)), (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => (dummy_vector_affine, 2, MOI.Zeros(2)), - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => - (dummy_vector_affine, 2, MOI.Nonpositives(2)), + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => + (dummy_vector_affine, 2, MOI.NonpositiveCone(2)), (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => (dummy_vector_affine, 2, MOI.NonnegativeCone(2)), (MOI.VectorAffineFunction{Float64}, MOI.Complements) => @@ -159,8 +159,8 @@ const BasicConstraintTests = Dict( ), (MOI.VectorQuadraticFunction{Float64}, MOI.Zeros) => (dummy_vector_quadratic, 2, MOI.Zeros(2)), - (MOI.VectorQuadraticFunction{Float64}, MOI.Nonpositives) => - (dummy_vector_quadratic, 2, MOI.Nonpositives(2)), + (MOI.VectorQuadraticFunction{Float64}, MOI.NonpositiveCone) => + (dummy_vector_quadratic, 2, MOI.NonpositiveCone(2)), (MOI.VectorQuadraticFunction{Float64}, MOI.NonnegativeCone) => (dummy_vector_quadratic, 2, MOI.NonnegativeCone(2)), (MOI.VectorQuadraticFunction{Float64}, MOI.NormInfinityCone) => diff --git a/src/DeprecatedTest/UnitTests/constraints.jl b/src/DeprecatedTest/UnitTests/constraints.jl index 9715771817..33bb8e6ceb 100644 --- a/src/DeprecatedTest/UnitTests/constraints.jl +++ b/src/DeprecatedTest/UnitTests/constraints.jl @@ -221,7 +221,7 @@ unittests["solve_duplicate_terms_scalar_affine"] = solve_duplicate_terms_vector_affine(model::MOI.ModelLike, config::Config) -Add a `VectorAffineFunction`-in-`Nonpositives` constraint with duplicate terms +Add a `VectorAffineFunction`-in-`NonpositiveCone` constraint with duplicate terms in the function. If `config.solve=true` confirm that it solves correctly, and if `config.duals=true`, check that the duals are computed correctly. """ @@ -243,7 +243,7 @@ function solve_duplicate_terms_vector_affine( MOI.VectorAffineTerm.(1, MOI.ScalarAffineTerm.([1.0, 1.0], [x, x])), [-1.0], ) - c = MOI.add_constraint(model, f, MOI.Nonpositives(1)) + c = MOI.add_constraint(model, f, MOI.NonpositiveCone(1)) return test_model_solution( model, config; @@ -366,7 +366,7 @@ unittests["solve_qcp_edge_cases"] = solve_qcp_edge_cases Test various edge cases relating to deleting affine constraints. This requires + ScalarAffineFunction-in-LessThan; and - + VectorAffineFunction-in-Nonpositives. + + VectorAffineFunction-in-NonpositiveCone. If `config.solve=true` confirm that it solves correctly. """ @@ -391,7 +391,7 @@ function solve_affine_deletion_edge_cases(model::MOI.ModelLike, config::Config) saf, ) # test adding a VectorAffineFunction -in- LessThan - c1 = MOI.add_constraint(model, vaf, MOI.Nonpositives(1)) + c1 = MOI.add_constraint(model, vaf, MOI.NonpositiveCone(1)) test_model_solution( model, config; @@ -421,7 +421,7 @@ function solve_affine_deletion_edge_cases(model::MOI.ModelLike, config::Config) constraint_primal = [(c2, 1.0)], ) # add a different VectorAffineFunction constraint - c3 = MOI.add_constraint(model, vaf2, MOI.Nonpositives(1)) + c3 = MOI.add_constraint(model, vaf2, MOI.NonpositiveCone(1)) test_model_solution( model, config; diff --git a/src/DeprecatedTest/UnitTests/modifications.jl b/src/DeprecatedTest/UnitTests/modifications.jl index 53ece3c254..f8fea60d07 100644 --- a/src/DeprecatedTest/UnitTests/modifications.jl +++ b/src/DeprecatedTest/UnitTests/modifications.jl @@ -306,7 +306,7 @@ modificationtests["solve_func_vectoraffine_nonneg"] = """ solve_const_vectoraffine_nonpos(model::MOI.ModelLike, config::Config) -Test modifying the constant term in a VectorAffineFunction-in-Nonpositives +Test modifying the constant term in a VectorAffineFunction-in-NonpositiveCone constraint. If `config.solve=true` confirm that it solves correctly, and if `config.duals=true`, check that the duals are computed correctly. """ @@ -330,7 +330,7 @@ function solve_const_vectoraffine_nonpos(model::MOI.ModelLike, config::Config) ], [0.0, 0.0], ), - MOI.Nonpositives(2), + MOI.NonpositiveCone(2), ) test_model_solution( model, @@ -355,7 +355,7 @@ modificationtests["solve_const_vectoraffine_nonpos"] = solve_multirow_vectoraffine_nonpos(model::MOI.ModelLike, config::Config) Test modifying the variable coefficients in a -VectorAffineFunction-in-Nonpositives constraint. If `config.solve=true` confirm +VectorAffineFunction-in-NonpositiveCone constraint. If `config.solve=true` confirm that it solves correctly. """ function solve_multirow_vectoraffine_nonpos( @@ -380,7 +380,7 @@ function solve_multirow_vectoraffine_nonpos( ], [-1.0, -1.0], ), - MOI.Nonpositives(2), + MOI.NonpositiveCone(2), ) test_model_solution( model, diff --git a/src/DeprecatedTest/contconic.jl b/src/DeprecatedTest/contconic.jl index ec50c643c4..1758f476d2 100644 --- a/src/DeprecatedTest/contconic.jl +++ b/src/DeprecatedTest/contconic.jl @@ -134,7 +134,7 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) #[ # (MOI.VectorAffineFunction{Float64},MOI.Zeros), # (MOI.VectorOfVariables,MOI.NonnegativeCone), - # (MOI.VectorOfVariables,MOI.Nonpositives) + # (MOI.VectorOfVariables,MOI.NonpositiveCone) #]) # mixed cones # min 3x + 2y - 4z + 0s @@ -159,7 +159,7 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) MOI.VectorOfVariables, MOI.NonnegativeCone, ) - @test MOI.supports_add_constrained_variables(model, MOI.Nonpositives) + @test MOI.supports_add_constrained_variables(model, MOI.NonpositiveCone) @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.Zeros) else @test MOI.supports_constraint( @@ -170,7 +170,7 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) end @test MOI.supports_constraint( @@ -183,12 +183,12 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) x = MOI.add_variable(model) @test MOI.get(model, MOI.NumberOfVariables()) == 1 if vecofvars - ys, vc = MOI.add_constrained_variables(model, MOI.Nonpositives(1)) + ys, vc = MOI.add_constrained_variables(model, MOI.NonpositiveCone(1)) y = ys[1] else y = MOI.add_variable(model) func = MOI.VectorAffineFunction{Float64}(MOI.VectorOfVariables([y])) - vc = MOI.add_constraint(model, func, MOI.Nonpositives(1)) + vc = MOI.add_constraint(model, func, MOI.NonpositiveCone(1)) end @test MOI.get(model, MOI.NumberOfVariables()) == 2 z, s = MOI.add_variables(model, 2) @@ -252,7 +252,7 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) MOI.NumberOfConstraints{ vecofvars ? MOI.VectorOfVariables : MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ) == 1 @test MOI.get( @@ -333,7 +333,7 @@ function lin3test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @test MOI.supports_constraint( model, @@ -357,7 +357,7 @@ function lin3test(model::MOI.ModelLike, config::Config) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [1.0], ), - MOI.Nonpositives(1), + MOI.NonpositiveCone(1), ) if config.query_number_of_constraints @test MOI.get( @@ -371,7 +371,7 @@ function lin3test(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ) == 1 end @@ -419,10 +419,10 @@ function lin4test(model::MOI.ModelLike, config::Config) MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone, ) - @test MOI.supports_add_constrained_variables(model, MOI.Nonpositives) + @test MOI.supports_add_constrained_variables(model, MOI.NonpositiveCone) MOI.empty!(model) @test MOI.is_empty(model) - xs, cx = MOI.add_constrained_variables(model, MOI.Nonpositives(1)) + xs, cx = MOI.add_constrained_variables(model, MOI.NonpositiveCone(1)) x = xs[1] MOI.add_constraint( model, @@ -442,7 +442,7 @@ function lin4test(model::MOI.ModelLike, config::Config) ) == 1 @test MOI.get( model, - MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.Nonpositives}(), + MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) == 1 end if config.solve @@ -638,7 +638,7 @@ function norminf2test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @test MOI.supports_constraint( model, @@ -662,7 +662,7 @@ function norminf2test(model::MOI.ModelLike, config::Config) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Nonpositives(1), + MOI.NonpositiveCone(1), ) MOI.add_constraint( model, @@ -684,7 +684,7 @@ function norminf2test(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ) == 1 @test MOI.get( @@ -961,7 +961,7 @@ function normone2test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @test MOI.supports_constraint( model, @@ -985,7 +985,7 @@ function normone2test(model::MOI.ModelLike, config::Config) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Nonpositives(1), + MOI.NonpositiveCone(1), ) MOI.add_constraint( model, @@ -1007,7 +1007,7 @@ function normone2test(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ) == 1 @test MOI.get( @@ -1277,7 +1277,7 @@ function _soc2test(model::MOI.ModelLike, config::Config, nonneg::Bool) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) end @test MOI.supports_constraint( @@ -1310,7 +1310,7 @@ function _soc2test(model::MOI.ModelLike, config::Config, nonneg::Bool) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(-1.0, y))], [1 / √2], ), - MOI.Nonpositives(1), + MOI.NonpositiveCone(1), ) end ceq = MOI.add_constraint( @@ -1337,7 +1337,7 @@ function _soc2test(model::MOI.ModelLike, config::Config, nonneg::Bool) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - nonneg ? MOI.NonnegativeCone : MOI.Nonpositives, + nonneg ? MOI.NonnegativeCone : MOI.NonpositiveCone, }(), ) == 1 @test MOI.get( @@ -1426,7 +1426,7 @@ function soc3test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @test MOI.supports_constraint( model, @@ -1450,7 +1450,7 @@ function soc3test(model::MOI.ModelLike, config::Config) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Nonpositives(1), + MOI.NonpositiveCone(1), ) MOI.add_constraint( model, @@ -1472,7 +1472,7 @@ function soc3test(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ) == 1 @test MOI.get( @@ -3914,7 +3914,7 @@ function psdt2test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @test MOI.supports_constraint( model, @@ -3942,7 +3942,7 @@ function psdt2test(model::MOI.ModelLike, config::Config) MOI.VectorAffineTerm.(1:6, MOI.ScalarAffineTerm.(-1.0, x[1:6])), zeros(6), ), - MOI.Nonpositives(6), + MOI.NonpositiveCone(6), ) α = 0.8 δ = 0.9 @@ -3999,7 +3999,7 @@ function psdt2test(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ) == 1 @test MOI.get( diff --git a/src/DeprecatedTest/contlinear.jl b/src/DeprecatedTest/contlinear.jl index cf255e18d3..0a02cef3c4 100644 --- a/src/DeprecatedTest/contlinear.jl +++ b/src/DeprecatedTest/contlinear.jl @@ -6,7 +6,7 @@ function linear1test(model::MOI.ModelLike, config::Config{T}) where {T} rtol = config.rtol # simple 2 variable, 1 constraint problem # min -x - # st x + y <= 1 (x + y - 1 ∈ Nonpositives) + # st x + y <= 1 (x + y - 1 ∈ NonpositiveCone) # x, y >= 0 (x, y ∈ NonnegativeCone) @test MOI.supports_incremental_interface(model, false) #=copy_names=# @test MOI.supports( @@ -1052,7 +1052,7 @@ function linear6test(model::MOI.ModelLike, config::Config{T}) where {T} end end -# Modify constants in NonnegativeCone and Nonpositives +# Modify constants in NonnegativeCone and NonpositiveCone function linear7test(model::MOI.ModelLike, config::Config{T}) where {T} atol = config.atol rtol = config.rtol @@ -1086,7 +1086,7 @@ function linear7test(model::MOI.ModelLike, config::Config{T}) where {T} @test MOI.supports_constraint( model, MOI.VectorAffineFunction{T}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) MOI.empty!(model) @test MOI.is_empty(model) @@ -1118,7 +1118,7 @@ function linear7test(model::MOI.ModelLike, config::Config{T}) where {T} [MOI.VectorAffineTerm{T}(1, MOI.ScalarAffineTerm{T}(one(T), y))], [zero(T)], ), - MOI.Nonpositives(1), + MOI.NonpositiveCone(1), ) if config.solve @test MOI.get(model, MOI.TerminationStatus()) == MOI.OPTIMIZE_NOT_CALLED @@ -1182,7 +1182,7 @@ function linear7test(model::MOI.ModelLike, config::Config{T}) where {T} ], [T(100)], ), - MOI.Nonpositives(1), + MOI.NonpositiveCone(1), ) end if config.solve diff --git a/src/DeprecatedTest/modellike.jl b/src/DeprecatedTest/modellike.jl index 7ab6b3c5d5..f7da14cb7b 100644 --- a/src/DeprecatedTest/modellike.jl +++ b/src/DeprecatedTest/modellike.jl @@ -94,7 +94,7 @@ function nametest(model::MOI.ModelLike; delete::Bool = true) @test MOI.get(model, MOI.VariableName(), v[1]) == "" x, cx = MOI.add_constrained_variable(model, MOI.GreaterThan(0.0)) @test MOI.get(model, MOI.VariableName(), x) == "" - y, cy = MOI.add_constrained_variables(model, MOI.Nonpositives(4)) + y, cy = MOI.add_constrained_variables(model, MOI.NonpositiveCone(4)) for yi in y @test MOI.get(model, MOI.VariableName(), yi) == "" end @@ -1044,7 +1044,7 @@ function delete_test(model::MOI.ModelLike) x = MOI.add_variable(model) cx = MOI.add_constraint(model, x, MOI.GreaterThan(0.0)) y = MOI.add_variables(model, 4) - cy = MOI.add_constraint(model, y, MOI.Nonpositives(4)) + cy = MOI.add_constraint(model, y, MOI.NonpositiveCone(4)) @test MOI.is_valid(model, x) @test MOI.is_valid(model, y[1]) @test MOI.is_valid(model, y[2]) @@ -1056,10 +1056,10 @@ function delete_test(model::MOI.ModelLike) @test MOI.get(model, MOI.ConstraintSet(), cx) == MOI.GreaterThan(0.0) @test MOI.get(model, MOI.ConstraintFunction(), cy) == MOI.VectorOfVariables(y) - @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.Nonpositives(4) + @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.NonpositiveCone(4) @test Set(MOI.get(model, MOI.ListOfConstraintTypesPresent())) == Set([ (MOI.SingleVariable, MOI.GreaterThan{Float64}), - (MOI.VectorOfVariables, MOI.Nonpositives), + (MOI.VectorOfVariables, MOI.NonpositiveCone), ]) @test MOI.get( model, @@ -1070,7 +1070,7 @@ function delete_test(model::MOI.ModelLike) ) == [cx] @test MOI.get( model, - MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.Nonpositives}(), + MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) == [cy] MOI.delete(model, y[3]) @test MOI.is_valid(model, x) @@ -1084,10 +1084,10 @@ function delete_test(model::MOI.ModelLike) @test MOI.get(model, MOI.ConstraintSet(), cx) == MOI.GreaterThan(0.0) @test MOI.get(model, MOI.ConstraintFunction(), cy) == MOI.VectorOfVariables(y[[1, 2, 4]]) - @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.Nonpositives(3) + @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.NonpositiveCone(3) @test Set(MOI.get(model, MOI.ListOfConstraintTypesPresent())) == Set([ (MOI.SingleVariable, MOI.GreaterThan{Float64}), - (MOI.VectorOfVariables, MOI.Nonpositives), + (MOI.VectorOfVariables, MOI.NonpositiveCone), ]) @test MOI.get( model, @@ -1098,7 +1098,7 @@ function delete_test(model::MOI.ModelLike) ) == [cx] @test MOI.get( model, - MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.Nonpositives}(), + MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) == [cy] MOI.delete(model, y[1]) @test MOI.is_valid(model, x) @@ -1112,10 +1112,10 @@ function delete_test(model::MOI.ModelLike) @test MOI.get(model, MOI.ConstraintSet(), cx) == MOI.GreaterThan(0.0) @test MOI.get(model, MOI.ConstraintFunction(), cy) == MOI.VectorOfVariables(y[[2, 4]]) - @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.Nonpositives(2) + @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.NonpositiveCone(2) @test Set(MOI.get(model, MOI.ListOfConstraintTypesPresent())) == Set([ (MOI.SingleVariable, MOI.GreaterThan{Float64}), - (MOI.VectorOfVariables, MOI.Nonpositives), + (MOI.VectorOfVariables, MOI.NonpositiveCone), ]) @test MOI.get( model, @@ -1126,7 +1126,7 @@ function delete_test(model::MOI.ModelLike) ) == [cx] @test MOI.get( model, - MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.Nonpositives}(), + MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) == [cy] MOI.delete(model, x) @test !MOI.is_valid(model, x) @@ -1138,9 +1138,9 @@ function delete_test(model::MOI.ModelLike) @test MOI.is_valid(model, cy) @test MOI.get(model, MOI.ConstraintFunction(), cy) == MOI.VectorOfVariables(y[[2, 4]]) - @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.Nonpositives(2) + @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.NonpositiveCone(2) @test MOI.get(model, MOI.ListOfConstraintTypesPresent()) == - [(MOI.VectorOfVariables, MOI.Nonpositives)] + [(MOI.VectorOfVariables, MOI.NonpositiveCone)] @test isempty( MOI.get( model, @@ -1152,7 +1152,7 @@ function delete_test(model::MOI.ModelLike) ) @test MOI.get( model, - MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.Nonpositives}(), + MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) == [cy] MOI.delete(model, y[[2, 4]]) @test !MOI.is_valid(model, x) @@ -1177,7 +1177,7 @@ function delete_test(model::MOI.ModelLike) model, MOI.ListOfConstraintIndices{ MOI.VectorOfVariables, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ), ) diff --git a/src/FileFormats/CBF/CBF.jl b/src/FileFormats/CBF/CBF.jl index 8687359ffa..996f847f81 100644 --- a/src/FileFormats/CBF/CBF.jl +++ b/src/FileFormats/CBF/CBF.jl @@ -13,7 +13,7 @@ MOI.Utilities.@model( MOI.Reals, MOI.Zeros, MOI.NonnegativeCone, - MOI.Nonpositives, + MOI.NonpositiveCone, MOI.SecondOrderCone, MOI.RotatedSecondOrderCone, MOI.PositiveSemidefiniteConeTriangle, diff --git a/src/FileFormats/CBF/read.jl b/src/FileFormats/CBF/read.jl index c0401e202c..a6fef35466 100644 --- a/src/FileFormats/CBF/read.jl +++ b/src/FileFormats/CBF/read.jl @@ -63,7 +63,7 @@ function _cbf_to_moi_cone( elseif cone_str == "L=" return MOI.Zeros(cone_dim) elseif cone_str == "L-" - return MOI.Nonpositives(cone_dim) + return MOI.NonpositiveCone(cone_dim) elseif cone_str == "L+" return MOI.NonnegativeCone(cone_dim) elseif cone_str == "Q" diff --git a/src/FileFormats/CBF/write.jl b/src/FileFormats/CBF/write.jl index 2fd59d8d09..05f43f9a17 100644 --- a/src/FileFormats/CBF/write.jl +++ b/src/FileFormats/CBF/write.jl @@ -31,7 +31,7 @@ end _cone_string(::Any, ::Type{MOI.Zeros}) = "L=" _cone_string(::Any, ::Type{MOI.Reals}) = "F" _cone_string(::Any, ::Type{MOI.NonnegativeCone}) = "L+" -_cone_string(::Any, ::Type{MOI.Nonpositives}) = "L-" +_cone_string(::Any, ::Type{MOI.NonpositiveCone}) = "L-" _cone_string(::Any, ::Type{MOI.SecondOrderCone}) = "Q" _cone_string(::Any, ::Type{MOI.RotatedSecondOrderCone}) = "QR" _cone_string(::Any, ::Type{MOI.ExponentialCone}) = "EXP" @@ -183,7 +183,7 @@ function _CBFDataStructure(model::Model) MOI.Zeros, MOI.Reals, MOI.NonnegativeCone, - MOI.Nonpositives, + MOI.NonpositiveCone, MOI.SecondOrderCone, MOI.RotatedSecondOrderCone, MOI.ExponentialCone, diff --git a/src/FileFormats/MOF/MOF.jl b/src/FileFormats/MOF/MOF.jl index 9de16d2f23..e81d606893 100644 --- a/src/FileFormats/MOF/MOF.jl +++ b/src/FileFormats/MOF/MOF.jl @@ -39,7 +39,7 @@ MOI.Utilities.@model( MOI.Reals, MOI.Zeros, MOI.NonnegativeCone, - MOI.Nonpositives, + MOI.NonpositiveCone, MOI.SecondOrderCone, MOI.RotatedSecondOrderCone, MOI.GeometricMeanCone, diff --git a/src/FileFormats/MOF/mof.0.6.schema.json b/src/FileFormats/MOF/mof.0.6.schema.json index a9a7809f8c..0f4a184e42 100644 --- a/src/FileFormats/MOF/mof.0.6.schema.json +++ b/src/FileFormats/MOF/mof.0.6.schema.json @@ -641,11 +641,11 @@ } }, { "description": "R₋^{dimension}", - "examples": ["{\"type\": \"Nonpositives\", \"dimension\": 3}"], + "examples": ["{\"type\": \"NonpositiveCone\", \"dimension\": 3}"], "required": ["dimension"], "properties": { "type": { - "const": "Nonpositives" + "const": "NonpositiveCone" }, "dimension": { "type": "integer", diff --git a/src/FileFormats/MOF/read.jl b/src/FileFormats/MOF/read.jl index 4d86dc63fb..e7078490ff 100644 --- a/src/FileFormats/MOF/read.jl +++ b/src/FileFormats/MOF/read.jl @@ -290,7 +290,7 @@ end Zeros, Reals, NonnegativeCone, - Nonpositives, + NonpositiveCone, SecondOrderCone, RotatedSecondOrderCone, GeometricMeanCone, @@ -379,8 +379,8 @@ function set_to_moi(::Val{:NonnegativeCone}, object::Object) return MOI.NonnegativeCone(object["dimension"]) end -function set_to_moi(::Val{:Nonpositives}, object::Object) - return MOI.Nonpositives(object["dimension"]) +function set_to_moi(::Val{:NonpositiveCone}, object::Object) + return MOI.NonpositiveCone(object["dimension"]) end function set_to_moi(::Val{:SecondOrderCone}, object::Object) diff --git a/src/FileFormats/MOF/write.jl b/src/FileFormats/MOF/write.jl index 30b4bcf445..f18e6138ea 100644 --- a/src/FileFormats/MOF/write.jl +++ b/src/FileFormats/MOF/write.jl @@ -265,7 +265,7 @@ head_name(::Type{<:MOI.Semicontinuous}) = "Semicontinuous" head_name(::Type{MOI.Zeros}) = "Zeros" head_name(::Type{MOI.Reals}) = "Reals" head_name(::Type{MOI.NonnegativeCone}) = "NonnegativeCone" -head_name(::Type{MOI.Nonpositives}) = "Nonpositives" +head_name(::Type{MOI.NonpositiveCone}) = "NonpositiveCone" head_name(::Type{MOI.SecondOrderCone}) = "SecondOrderCone" head_name(::Type{MOI.RotatedSecondOrderCone}) = "RotatedSecondOrderCone" head_name(::Type{MOI.GeometricMeanCone}) = "GeometricMeanCone" diff --git a/src/Test/test_basic_constraint.jl b/src/Test/test_basic_constraint.jl index a8ae4ed86c..30bf1d8173 100644 --- a/src/Test/test_basic_constraint.jl +++ b/src/Test/test_basic_constraint.jl @@ -78,7 +78,7 @@ end _set(::Type{T}, ::Type{MOI.SOS1}) where {T} = MOI.SOS1(convert.(T, 1:2)) _set(::Type{T}, ::Type{MOI.SOS2}) where {T} = MOI.SOS2(convert.(T, 1:2)) _set(::Type{MOI.Zeros}) = MOI.Zeros(2) -_set(::Type{MOI.Nonpositives}) = MOI.Nonpositives(2) +_set(::Type{MOI.NonpositiveCone}) = MOI.NonpositiveCone(2) _set(::Type{MOI.NonnegativeCone}) = MOI.NonnegativeCone(2) _set(::Type{MOI.NormInfinityCone}) = MOI.NormInfinityCone(3) _set(::Type{MOI.NormOneCone}) = MOI.NormOneCone(3) @@ -224,7 +224,7 @@ for s in [ :SOS1, :SOS2, :Zeros, - :Nonpositives, + :NonpositiveCone, :NonnegativeCone, :NormInfinityCone, :NormOneCone, diff --git a/src/Test/test_conic.jl b/src/Test/test_conic.jl index b14cef73f4..0f723b8fbc 100644 --- a/src/Test/test_conic.jl +++ b/src/Test/test_conic.jl @@ -237,7 +237,7 @@ function _test_conic_linear_helper_2( ) @requires MOI.supports_add_constrained_variables( model, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @requires MOI.supports_constraint( model, @@ -253,7 +253,7 @@ function _test_conic_linear_helper_2( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) end @requires MOI.supports_constraint( @@ -264,12 +264,12 @@ function _test_conic_linear_helper_2( x = MOI.add_variable(model) @test MOI.get(model, MOI.NumberOfVariables()) == 1 if use_VectorOfVariables - ys, vc = MOI.add_constrained_variables(model, MOI.Nonpositives(1)) + ys, vc = MOI.add_constrained_variables(model, MOI.NonpositiveCone(1)) y = ys[1] else y = MOI.add_variable(model) func = MOI.VectorAffineFunction{Float64}(MOI.VectorOfVariables([y])) - vc = MOI.add_constraint(model, func, MOI.Nonpositives(1)) + vc = MOI.add_constraint(model, func, MOI.NonpositiveCone(1)) end @test MOI.get(model, MOI.NumberOfVariables()) == 2 z, s = MOI.add_variables(model, 2) @@ -333,7 +333,7 @@ function _test_conic_linear_helper_2( MOI.NumberOfConstraints{ use_VectorOfVariables ? MOI.VectorOfVariables : MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ) == 1 @test MOI.get( @@ -447,7 +447,7 @@ function setup_test( mock, [-4, -3, 16, 0], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0]], - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => [[0]], + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[0]], (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[7, 2, -4], [7]], ), @@ -477,7 +477,7 @@ function test_conic_linear_INFEASIBLE(model::MOI.ModelLike, config::Config) @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @requires MOI.supports_constraint( model, @@ -499,7 +499,7 @@ function test_conic_linear_INFEASIBLE(model::MOI.ModelLike, config::Config) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [1.0], ), - MOI.Nonpositives(1), + MOI.NonpositiveCone(1), ) if _supports(config, MOI.NumberOfConstraints) @test MOI.get( @@ -513,7 +513,7 @@ function test_conic_linear_INFEASIBLE(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ) == 1 end @@ -568,9 +568,9 @@ function test_conic_linear_INFEASIBLE_2(model::MOI.ModelLike, config::Config) MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone, ) - @requires MOI.supports_add_constrained_variables(model, MOI.Nonpositives) + @requires MOI.supports_add_constrained_variables(model, MOI.NonpositiveCone) - xs, cx = MOI.add_constrained_variables(model, MOI.Nonpositives(1)) + xs, cx = MOI.add_constrained_variables(model, MOI.NonpositiveCone(1)) x = xs[1] MOI.add_constraint( model, @@ -590,7 +590,7 @@ function test_conic_linear_INFEASIBLE_2(model::MOI.ModelLike, config::Config) ) == 1 @test MOI.get( model, - MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.Nonpositives}(), + MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) == 1 end if _supports(config, MOI.optimize!) @@ -869,7 +869,7 @@ function test_conic_NormInfinityCone_INFEASIBLE( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @requires MOI.supports_constraint( model, @@ -892,7 +892,7 @@ function test_conic_NormInfinityCone_INFEASIBLE( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Nonpositives(1), + MOI.NonpositiveCone(1), ) MOI.add_constraint( model, @@ -914,7 +914,7 @@ function test_conic_NormInfinityCone_INFEASIBLE( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ) == 1 @test MOI.get( @@ -1296,7 +1296,7 @@ function test_conic_NormOneCone_INFEASIBLE(model::MOI.ModelLike, config::Config) @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @requires MOI.supports_constraint( model, @@ -1319,7 +1319,7 @@ function test_conic_NormOneCone_INFEASIBLE(model::MOI.ModelLike, config::Config) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Nonpositives(1), + MOI.NonpositiveCone(1), ) MOI.add_constraint( model, @@ -1341,7 +1341,7 @@ function test_conic_NormOneCone_INFEASIBLE(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ) == 1 @test MOI.get( @@ -1728,7 +1728,7 @@ function _test_conic_SecondOrderCone_helper_2( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) end @requires MOI.supports_constraint( @@ -1760,7 +1760,7 @@ function _test_conic_SecondOrderCone_helper_2( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(-1.0, y))], [1 / √2], ), - MOI.Nonpositives(1), + MOI.NonpositiveCone(1), ) end ceq = MOI.add_constraint( @@ -1787,7 +1787,7 @@ function _test_conic_SecondOrderCone_helper_2( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - nonneg ? MOI.NonnegativeCone : MOI.Nonpositives, + nonneg ? MOI.NonnegativeCone : MOI.NonpositiveCone, }(), ) == 1 @test MOI.get( @@ -1885,7 +1885,7 @@ end config::Config, ) -Test a SecondOrderCone with Nonpositives constraints. +Test a SecondOrderCone with NonpositiveCone constraints. """ function test_conic_SecondOrderCone_Nonpositives( model::MOI.ModelLike, @@ -1908,7 +1908,7 @@ function setup_test( (MOI.VectorAffineFunction{Float64}, MOI.SecondOrderCone) => [[√2, 1, -1]], (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[√2]], - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[-1.0]], ), ) @@ -1954,7 +1954,7 @@ function test_conic_SecondOrderCone_INFEASIBLE( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @requires MOI.supports_constraint( model, @@ -1977,7 +1977,7 @@ function test_conic_SecondOrderCone_INFEASIBLE( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Nonpositives(1), + MOI.NonpositiveCone(1), ) MOI.add_constraint( model, @@ -1999,7 +1999,7 @@ function test_conic_SecondOrderCone_INFEASIBLE( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ) == 1 @test MOI.get( @@ -5521,7 +5521,7 @@ function test_conic_PositiveSemidefiniteConeTriangle( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @requires MOI.supports_constraint( model, @@ -5548,7 +5548,7 @@ function test_conic_PositiveSemidefiniteConeTriangle( MOI.VectorAffineTerm.(1:6, MOI.ScalarAffineTerm.(-1.0, x[1:6])), zeros(6), ), - MOI.Nonpositives(6), + MOI.NonpositiveCone(6), ) α = 0.8 δ = 0.9 @@ -5605,7 +5605,7 @@ function test_conic_PositiveSemidefiniteConeTriangle( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ) == 1 @test MOI.get( @@ -5686,7 +5686,7 @@ function setup_test( [2η / 3, 0, η / 3, 0, 0, 0, η * δ * (1 - 1 / √3) / 2], (MOI.ScalarAffineFunction{Float64}, MOI.GreaterThan{Float64}) => [δ * (1 - 1 / √3) / 2], - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => [[ + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[ 0, -α / √3 + δ / (2 * √6) * (2 * √2 - 1), 0, diff --git a/src/Test/test_constraint.jl b/src/Test/test_constraint.jl index a0be6a9b02..2ea37b3d4d 100644 --- a/src/Test/test_constraint.jl +++ b/src/Test/test_constraint.jl @@ -329,7 +329,7 @@ end config::Config, ) -Add a `VectorAffineFunction`-in-`Nonpositives` constraint with duplicate terms +Add a `VectorAffineFunction`-in-`NonpositiveCone` constraint with duplicate terms in the function. """ function test_constraint_VectorAffineFunction_duplicate( @@ -349,7 +349,7 @@ function test_constraint_VectorAffineFunction_duplicate( MOI.VectorAffineTerm.(1, MOI.ScalarAffineTerm.([1.0, 1.0], [x, x])), [-1.0], ) - c = MOI.add_constraint(model, f, MOI.Nonpositives(1)) + c = MOI.add_constraint(model, f, MOI.NonpositiveCone(1)) _test_model_solution( model, config; @@ -373,7 +373,7 @@ function setup_test( MOI.OPTIMAL, (MOI.FEASIBLE_POINT, [0.5]), MOI.FEASIBLE_POINT, - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[-0.5]], ), ) diff --git a/src/Test/test_linear.jl b/src/Test/test_linear.jl index 7578b7e7d1..cded24b049 100644 --- a/src/Test/test_linear.jl +++ b/src/Test/test_linear.jl @@ -1288,7 +1288,7 @@ function test_linear_VectorAffineFunction( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{T}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) x = MOI.add_variable(model) y = MOI.add_variable(model) @@ -1318,7 +1318,7 @@ function test_linear_VectorAffineFunction( [MOI.VectorAffineTerm{T}(1, MOI.ScalarAffineTerm{T}(one(T), y))], [zero(T)], ), - MOI.Nonpositives(1), + MOI.NonpositiveCone(1), ) if _supports(config, MOI.optimize!) @test MOI.get(model, MOI.TerminationStatus()) == MOI.OPTIMIZE_NOT_CALLED @@ -1382,7 +1382,7 @@ function test_linear_VectorAffineFunction( ], [T(100)], ), - MOI.Nonpositives(1), + MOI.NonpositiveCone(1), ) end if _supports(config, MOI.optimize!) diff --git a/src/Test/test_model.jl b/src/Test/test_model.jl index 3a39a99966..e7cdaf074e 100644 --- a/src/Test/test_model.jl +++ b/src/Test/test_model.jl @@ -294,7 +294,7 @@ function test_model_Name_VariableName_ConstraintName( @test MOI.get(model, MOI.VariableName(), v[1]) == "" x, cx = MOI.add_constrained_variable(model, MOI.GreaterThan(0.0)) @test MOI.get(model, MOI.VariableName(), x) == "" - y, cy = MOI.add_constrained_variables(model, MOI.Nonpositives(4)) + y, cy = MOI.add_constrained_variables(model, MOI.NonpositiveCone(4)) for yi in y @test MOI.get(model, MOI.VariableName(), yi) == "" end @@ -880,7 +880,7 @@ function test_model_delete(model::MOI.ModelLike, config::Config) x = MOI.add_variable(model) cx = MOI.add_constraint(model, x, MOI.GreaterThan(0.0)) y = MOI.add_variables(model, 4) - cy = MOI.add_constraint(model, y, MOI.Nonpositives(4)) + cy = MOI.add_constraint(model, y, MOI.NonpositiveCone(4)) @test MOI.is_valid(model, x) @test MOI.is_valid(model, y[1]) @test MOI.is_valid(model, y[2]) @@ -892,10 +892,10 @@ function test_model_delete(model::MOI.ModelLike, config::Config) @test MOI.get(model, MOI.ConstraintSet(), cx) == MOI.GreaterThan(0.0) @test MOI.get(model, MOI.ConstraintFunction(), cy) == MOI.VectorOfVariables(y) - @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.Nonpositives(4) + @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.NonpositiveCone(4) @test Set(MOI.get(model, MOI.ListOfConstraintTypesPresent())) == Set([ (MOI.SingleVariable, MOI.GreaterThan{Float64}), - (MOI.VectorOfVariables, MOI.Nonpositives), + (MOI.VectorOfVariables, MOI.NonpositiveCone), ]) @test MOI.get( model, @@ -906,7 +906,7 @@ function test_model_delete(model::MOI.ModelLike, config::Config) ) == [cx] @test MOI.get( model, - MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.Nonpositives}(), + MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) == [cy] MOI.delete(model, y[3]) @test MOI.is_valid(model, x) @@ -920,10 +920,10 @@ function test_model_delete(model::MOI.ModelLike, config::Config) @test MOI.get(model, MOI.ConstraintSet(), cx) == MOI.GreaterThan(0.0) @test MOI.get(model, MOI.ConstraintFunction(), cy) == MOI.VectorOfVariables(y[[1, 2, 4]]) - @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.Nonpositives(3) + @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.NonpositiveCone(3) @test Set(MOI.get(model, MOI.ListOfConstraintTypesPresent())) == Set([ (MOI.SingleVariable, MOI.GreaterThan{Float64}), - (MOI.VectorOfVariables, MOI.Nonpositives), + (MOI.VectorOfVariables, MOI.NonpositiveCone), ]) @test MOI.get( model, @@ -934,7 +934,7 @@ function test_model_delete(model::MOI.ModelLike, config::Config) ) == [cx] @test MOI.get( model, - MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.Nonpositives}(), + MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) == [cy] MOI.delete(model, y[1]) @test MOI.is_valid(model, x) @@ -948,10 +948,10 @@ function test_model_delete(model::MOI.ModelLike, config::Config) @test MOI.get(model, MOI.ConstraintSet(), cx) == MOI.GreaterThan(0.0) @test MOI.get(model, MOI.ConstraintFunction(), cy) == MOI.VectorOfVariables(y[[2, 4]]) - @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.Nonpositives(2) + @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.NonpositiveCone(2) @test Set(MOI.get(model, MOI.ListOfConstraintTypesPresent())) == Set([ (MOI.SingleVariable, MOI.GreaterThan{Float64}), - (MOI.VectorOfVariables, MOI.Nonpositives), + (MOI.VectorOfVariables, MOI.NonpositiveCone), ]) @test MOI.get( model, @@ -962,7 +962,7 @@ function test_model_delete(model::MOI.ModelLike, config::Config) ) == [cx] @test MOI.get( model, - MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.Nonpositives}(), + MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) == [cy] MOI.delete(model, x) @test !MOI.is_valid(model, x) @@ -974,9 +974,9 @@ function test_model_delete(model::MOI.ModelLike, config::Config) @test MOI.is_valid(model, cy) @test MOI.get(model, MOI.ConstraintFunction(), cy) == MOI.VectorOfVariables(y[[2, 4]]) - @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.Nonpositives(2) + @test MOI.get(model, MOI.ConstraintSet(), cy) == MOI.NonpositiveCone(2) @test MOI.get(model, MOI.ListOfConstraintTypesPresent()) == - [(MOI.VectorOfVariables, MOI.Nonpositives)] + [(MOI.VectorOfVariables, MOI.NonpositiveCone)] @test isempty( MOI.get( model, @@ -988,7 +988,7 @@ function test_model_delete(model::MOI.ModelLike, config::Config) ) @test MOI.get( model, - MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.Nonpositives}(), + MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) == [cy] MOI.delete(model, y[[2, 4]]) @test !MOI.is_valid(model, x) @@ -1013,7 +1013,7 @@ function test_model_delete(model::MOI.ModelLike, config::Config) model, MOI.ListOfConstraintIndices{ MOI.VectorOfVariables, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ), ) diff --git a/src/Test/test_modification.jl b/src/Test/test_modification.jl index c21e03584c..c4228d2d6e 100644 --- a/src/Test/test_modification.jl +++ b/src/Test/test_modification.jl @@ -481,7 +481,7 @@ end config::Config, ) -Test modifying the constant term in a VectorAffineFunction-in-Nonpositives +Test modifying the constant term in a VectorAffineFunction-in-NonpositiveCone constraint. If `config.solve=true` confirm that it solves correctly, and if `config.duals=true`, check that the duals are computed correctly. """ @@ -507,7 +507,7 @@ function test_modification_const_vectoraffine_nonpos( ], [0.0, 0.0], ), - MOI.Nonpositives(2), + MOI.NonpositiveCone(2), ) _test_model_solution( model, @@ -555,7 +555,7 @@ end ) Test modifying the variable coefficients in a -VectorAffineFunction-in-Nonpositives constraint. If `config.solve=true` confirm +VectorAffineFunction-in-NonpositiveCone constraint. If `config.solve=true` confirm that it solves correctly. """ function test_modification_multirow_vectoraffine_nonpos( @@ -575,7 +575,7 @@ function test_modification_multirow_vectoraffine_nonpos( ], [-1.0, -1.0], ), - MOI.Nonpositives(2), + MOI.NonpositiveCone(2), ) _test_model_solution( model, @@ -841,7 +841,7 @@ end Test various edge cases relating to deleting affine constraints. This requires + ScalarAffineFunction-in-LessThan; and - + VectorAffineFunction-in-Nonpositives. + + VectorAffineFunction-in-NonpositiveCone. """ function test_modification_affine_deletion_edge_cases( model::MOI.ModelLike, @@ -866,7 +866,7 @@ function test_modification_affine_deletion_edge_cases( saf, ) # test adding a VectorAffineFunction -in- LessThan - c1 = MOI.add_constraint(model, vaf, MOI.Nonpositives(1)) + c1 = MOI.add_constraint(model, vaf, MOI.NonpositiveCone(1)) _test_model_solution( model, config; @@ -896,7 +896,7 @@ function test_modification_affine_deletion_edge_cases( constraint_primal = [(c2, 1.0)], ) # add a different VectorAffineFunction constraint - c3 = MOI.add_constraint(model, vaf2, MOI.Nonpositives(1)) + c3 = MOI.add_constraint(model, vaf2, MOI.NonpositiveCone(1)) _test_model_solution( model, config; diff --git a/src/Utilities/model.jl b/src/Utilities/model.jl index c16427ebe7..120c4f126e 100644 --- a/src/Utilities/model.jl +++ b/src/Utilities/model.jl @@ -833,7 +833,7 @@ The model describing an linear program would be: @model(LPModel, # Name of model (), # untyped scalar sets (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan, MOI.Interval), # typed scalar sets - (MOI.Zeros, MOI.NonnegativeCone, MOI.Nonpositives), # untyped vector sets + (MOI.Zeros, MOI.NonnegativeCone, MOI.NonpositiveCone), # untyped vector sets (), # typed vector sets (), # untyped scalar functions (MOI.ScalarAffineFunction,), # typed scalar functions @@ -870,13 +870,13 @@ struct LPModelFunctionConstraints{T} <: MOIU.StructOfConstraints T, MOIU.VectorOfConstraints{MOI.VectorOfVariables, MOI.Zeros}, MOIU.VectorOfConstraints{MOI.VectorOfVariables, MOI.NonnegativeCone}, - MOIU.VectorOfConstraints{MOI.VectorOfVariables, MOI.Nonpositives} + MOIU.VectorOfConstraints{MOI.VectorOfVariables, MOI.NonpositiveCone} } moi_vectoraffinefunction::LPModelVectorConstraints{ T, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{T}, MOI.Zeros}, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{T}, MOI.NonnegativeCone}, - MOIU.VectorOfConstraints{MOI.VectorAffineFunction{T}, MOI.Nonpositives} + MOIU.VectorOfConstraints{MOI.VectorAffineFunction{T}, MOI.NonpositiveCone} } end const LPModel{T} = MOIU.GenericModel{T, LPModelFunctionConstraints{T}} @@ -1051,7 +1051,7 @@ const LessThanIndicatorSetZero{T} = MOI.Reals, MOI.Zeros, MOI.NonnegativeCone, - MOI.Nonpositives, + MOI.NonpositiveCone, MOI.Complements, MOI.NormInfinityCone, MOI.NormOneCone, diff --git a/src/Utilities/precompile.jl b/src/Utilities/precompile.jl index d528f76f4d..5020888e02 100644 --- a/src/Utilities/precompile.jl +++ b/src/Utilities/precompile.jl @@ -18,7 +18,7 @@ function _precompile_() ) vector_sets = ( MOI.NonnegativeCone, - MOI.Nonpositives, + MOI.NonpositiveCone, MOI.Zeros, MOI.Reals, MOI.SecondOrderCone, diff --git a/src/Utilities/product_of_sets.jl b/src/Utilities/product_of_sets.jl index 9752766093..dfe605da00 100644 --- a/src/Utilities/product_of_sets.jl +++ b/src/Utilities/product_of_sets.jl @@ -149,7 +149,7 @@ Generate a new [`OrderedProductOfSets`](@ref) subtype. LinearOrthants, MOI.Zeros, MOI.NonnegativeCone, - MOI.Nonpositives, + MOI.NonpositiveCone, MOI.ZeroOne, ) ``` diff --git a/src/Utilities/sets.jl b/src/Utilities/sets.jl index b23956e940..705e42f573 100644 --- a/src/Utilities/sets.jl +++ b/src/Utilities/sets.jl @@ -72,7 +72,7 @@ This is used in the vectorize and scalarize bridges. See also: [`ScalarLinearSet`](@ref). """ -const VectorLinearSet = Union{MOI.Zeros,MOI.NonnegativeCone,MOI.Nonpositives} +const VectorLinearSet = Union{MOI.Zeros,MOI.NonnegativeCone,MOI.NonpositiveCone} """ vector_set_type(::Type{S}) where {S} @@ -84,7 +84,7 @@ This is used in the vectorize and scalarize bridges. See also: [`scalar_set_type`](@ref). """ vector_set_type(::Type{<:MOI.EqualTo}) = MOI.Zeros -vector_set_type(::Type{<:MOI.LessThan}) = MOI.Nonpositives +vector_set_type(::Type{<:MOI.LessThan}) = MOI.NonpositiveCone vector_set_type(::Type{<:MOI.GreaterThan}) = MOI.NonnegativeCone """ @@ -98,7 +98,7 @@ This is used in the vectorize and scalarize bridges. See also: [`vector_set_type`](@ref). """ scalar_set_type(::Type{<:MOI.Zeros}, T::Type) = MOI.EqualTo{T} -scalar_set_type(::Type{<:MOI.Nonpositives}, T::Type) = MOI.LessThan{T} +scalar_set_type(::Type{<:MOI.NonpositiveCone}, T::Type) = MOI.LessThan{T} scalar_set_type(::Type{<:MOI.NonnegativeCone}, T::Type) = MOI.GreaterThan{T} """ diff --git a/src/sets.jl b/src/sets.jl index c8e1ba2f23..e0901ccf0c 100644 --- a/src/sets.jl +++ b/src/sets.jl @@ -175,18 +175,18 @@ dual_set(s::NonnegativeCone) = copy(s) dual_set_type(::Type{NonnegativeCone}) = NonnegativeCone """ - Nonpositives(dimension) + NonpositiveCone(dimension) The nonpositive orthant ``\\{ x \\in \\mathbb{R}^{dimension} : x \\le 0 \\}`` of dimension `dimension`. """ -struct Nonpositives <: AbstractVectorSet +struct NonpositiveCone <: AbstractVectorSet dimension::Int - function Nonpositives(dimension::Base.Integer) + function NonpositiveCone(dimension::Base.Integer) if !(dimension >= 0) throw( DimensionMismatch( - "Dimension of Nonpositives must be >= 0, not $(dimension).", + "Dimension of NonpositiveCone must be >= 0, not $(dimension).", ), ) end @@ -194,8 +194,8 @@ struct Nonpositives <: AbstractVectorSet end end -dual_set(s::Nonpositives) = copy(s) -dual_set_type(::Type{Nonpositives}) = Nonpositives +dual_set(s::NonpositiveCone) = copy(s) +dual_set_type(::Type{NonpositiveCone}) = NonpositiveCone """ GreaterThan{T <: Real}(lower::T) @@ -1115,7 +1115,7 @@ function Base.copy( Reals, Zeros, NonnegativeCone, - Nonpositives, + NonpositiveCone, GreaterThan, LessThan, EqualTo, @@ -1166,7 +1166,7 @@ function supports_dimension_update(::Type{<:AbstractVectorSet}) return false end function supports_dimension_update( - ::Type{<:Union{Reals,Zeros,NonnegativeCone,Nonpositives}}, + ::Type{<:Union{Reals,Zeros,NonnegativeCone,NonpositiveCone}}, ) return true end @@ -1178,7 +1178,7 @@ Returns a set with the dimension modified to `new_dim`. """ function update_dimension end function update_dimension( - set::Union{Reals,Zeros,NonnegativeCone,Nonpositives}, + set::Union{Reals,Zeros,NonnegativeCone,NonpositiveCone}, new_dim, ) return typeof(set)(new_dim) diff --git a/test/Bridges/Constraint/flip_sign.jl b/test/Bridges/Constraint/flip_sign.jl index fc4a434467..3ae0c7bab8 100644 --- a/test/Bridges/Constraint/flip_sign.jl +++ b/test/Bridges/Constraint/flip_sign.jl @@ -183,14 +183,14 @@ end bridged_mock, ci, 2, - ((MOI.VectorAffineFunction{Float64}, MOI.Nonpositives, 1),), + ((MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone, 1),), ) mock.optimize! = (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1.0, 0.0, 2.0], - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[0.0, -2.0, 0.0]], (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-3.0, -1.0]], @@ -224,7 +224,7 @@ end bridged_mock, ci, 2, - ((MOI.VectorAffineFunction{Float64}, MOI.Nonpositives, 0),), + ((MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone, 0),), ) end @@ -239,7 +239,7 @@ end MOI.VectorOfVariables, MOI.VectorAffineFunction{Float64}, MOI.VectorQuadraticFunction{Float64}, - ] for S in [MOI.Nonpositives] + ] for S in [MOI.NonpositiveCone] ], ) @@ -284,7 +284,7 @@ end bridged_mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ), ) diff --git a/test/Bridges/Constraint/functionize.jl b/test/Bridges/Constraint/functionize.jl index 65b2ac8e20..e6f1d7e59b 100644 --- a/test/Bridges/Constraint/functionize.jl +++ b/test/Bridges/Constraint/functionize.jl @@ -146,11 +146,11 @@ end config, include = [ (F, S) for F in [MOI.VectorOfVariables], - S in [MOI.NonnegativeCone, MOI.Nonpositives] + S in [MOI.NonnegativeCone, MOI.NonpositiveCone] ], ) - for T in [Int, Float64], S in [MOI.NonnegativeCone, MOI.Nonpositives] + for T in [Int, Float64], S in [MOI.NonnegativeCone, MOI.NonpositiveCone] @test MOIB.added_constraint_types( MOIB.Constraint.VectorFunctionizeBridge{T,S}, ) == [(MOI.VectorAffineFunction{T}, S)] diff --git a/test/Bridges/Constraint/interval.jl b/test/Bridges/Constraint/interval.jl index 87d1d7dccc..20117eb5b6 100644 --- a/test/Bridges/Constraint/interval.jl +++ b/test/Bridges/Constraint/interval.jl @@ -206,7 +206,7 @@ end [1.0, 0.0, 2.0], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0.0, 0.0]], - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[-3, -1]], ) MOIT.lin1vtest(bridged_mock, config) @@ -227,7 +227,7 @@ end 3, ( (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone, 0), - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives, 0), + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone, 0), ), ) end diff --git a/test/Bridges/Constraint/scalarize.jl b/test/Bridges/Constraint/scalarize.jl index 71483450a8..20623eea62 100644 --- a/test/Bridges/Constraint/scalarize.jl +++ b/test/Bridges/Constraint/scalarize.jl @@ -22,7 +22,7 @@ config = MOIT.Config() MOI.VectorOfVariables, MOI.VectorAffineFunction{Float64}, MOI.VectorQuadraticFunction{Float64}, - ] for S in [MOI.NonnegativeCone, MOI.Nonpositives, MOI.Zeros] + ] for S in [MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.Zeros] ], ) @@ -171,7 +171,7 @@ config = MOIT.Config() MOIT.solve_func_vectoraffine_nonneg(bridged_mock, config) # VectorOfVariables-in-NonnegativeCone - # VectorOfVariables-in-Nonpositives + # VectorOfVariables-in-NonpositiveCone # VectorOfVariables-in-Zeros # VectorAffineFunction-in-Zeros mock.optimize! = @@ -184,7 +184,7 @@ config = MOIT.Config() MOIT.lin2vtest(bridged_mock, config) # VectorAffineFunction-in-NonnegativeCone - # VectorAffineFunction-in-Nonpositives + # VectorAffineFunction-in-NonpositiveCone # VectorAffineFunction-in-Zeros mock.optimize! = (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( diff --git a/test/Bridges/Constraint/slack.jl b/test/Bridges/Constraint/slack.jl index c9e1310bec..59cf79e035 100644 --- a/test/Bridges/Constraint/slack.jl +++ b/test/Bridges/Constraint/slack.jl @@ -171,7 +171,7 @@ end MOI.VectorAffineTerm.(1, MOI.ScalarAffineTerm.([1.0, 2.0], [x, y])), [0.0], ) - ci = MOI.add_constraint(bridged_mock, f, MOI.Nonpositives(1)) + ci = MOI.add_constraint(bridged_mock, f, MOI.NonpositiveCone(1)) @test MOI.get(bridged_mock, MOI.ConstraintFunction(), ci) ≈ f newf = MOI.VectorAffineFunction( @@ -180,7 +180,7 @@ end ) MOI.set(bridged_mock, MOI.ConstraintFunction(), ci, newf) @test MOI.get(bridged_mock, MOI.ConstraintFunction(), ci) ≈ newf - @test MOI.get(bridged_mock, MOI.ConstraintSet(), ci) == MOI.Nonpositives(1) + @test MOI.get(bridged_mock, MOI.ConstraintSet(), ci) == MOI.NonpositiveCone(1) MOI.modify(bridged_mock, ci, MOI.VectorConstantChange([1.0])) @test MOI.get(bridged_mock, MOI.ConstraintFunction(), ci) ≈ MOI.VectorAffineFunction( @@ -210,7 +210,7 @@ end ci, 2, ( - (MOI.VectorOfVariables, MOI.Nonpositives, 0), + (MOI.VectorOfVariables, MOI.NonpositiveCone, 0), (MOI.VectorAffineFunction{Float64}, MOI.Zeros, 0), ), ) @@ -234,7 +234,7 @@ end (F, S) for F in [ MOI.VectorAffineFunction{Float64}, MOI.VectorQuadraticFunction{Float64}, - ], S in [MOI.NonnegativeCone, MOI.Nonpositives] + ], S in [MOI.NonnegativeCone, MOI.NonpositiveCone] ], ) @@ -250,7 +250,7 @@ end (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[1.0], [1.0]], (MOI.VectorOfVariables, MOI.NonnegativeCone) => [[1.0]], - (MOI.VectorOfVariables, MOI.Nonpositives) => [[1.0]], + (MOI.VectorOfVariables, MOI.NonpositiveCone) => [[1.0]], ), ) MOIT.linear7test(bridged_mock, config) @@ -269,7 +269,7 @@ end bridged_mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ) @test length(c2) == 1 @@ -279,14 +279,14 @@ end loc = MOI.get(bridged_mock, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 2 @test (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) in loc - @test (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) in loc loc = MOI.get(mock, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 3 @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc @test (MOI.VectorOfVariables, MOI.NonnegativeCone) in loc - @test (MOI.VectorOfVariables, MOI.Nonpositives) in loc + @test (MOI.VectorOfVariables, MOI.NonpositiveCone) in loc - for T in [Int, Float64], S in [MOI.NonnegativeCone, MOI.Nonpositives] + for T in [Int, Float64], S in [MOI.NonnegativeCone, MOI.NonpositiveCone] for F in [MOI.VectorAffineFunction{T}, MOI.VectorQuadraticFunction{T}] @test MOIB.added_constraint_types( MOIB.Constraint.VectorSlackBridge{T,F,S}, diff --git a/test/Bridges/Constraint/vectorize.jl b/test/Bridges/Constraint/vectorize.jl index 266a56e72a..2ef8e20e24 100644 --- a/test/Bridges/Constraint/vectorize.jl +++ b/test/Bridges/Constraint/vectorize.jl @@ -39,7 +39,7 @@ config = MOIT.Config() (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 0], - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => [[-1]], + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[-1]], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0], [1]], ), @@ -76,7 +76,7 @@ config = MOIT.Config() (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [0, 1 / 2, 1], - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[-1], [-2]], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[2], [0], [0]], @@ -84,7 +84,7 @@ config = MOIT.Config() (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1], - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => [[-1]], + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[-1]], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0]], ), ) diff --git a/test/Bridges/Variable/flip_sign.jl b/test/Bridges/Variable/flip_sign.jl index fd4cdf48c3..885fd7821d 100644 --- a/test/Bridges/Variable/flip_sign.jl +++ b/test/Bridges/Variable/flip_sign.jl @@ -89,7 +89,7 @@ config = MOIT.Config() bridged_mock, MOI.ListOfConstraintIndices{ MathOptInterface.VectorOfVariables, - MathOptInterface.Nonpositives, + MathOptInterface.NonpositiveCone, }(), )[1] MOI.set(bridged_mock, MOI.ConstraintName(), con_v, "cv") @@ -116,7 +116,7 @@ config = MOIT.Config() @testset "Test Bridged model" begin s = """ variables: x, z, w, v - cv: [v] in MathOptInterface.Nonpositives(1) + cv: [v] in MathOptInterface.NonpositiveCone(1) cw: [w] in MathOptInterface.Zeros(1) cz: [z] in MathOptInterface.NonnegativeCone(1) cex: [1*x + -1*w + 4.0, 1*v + 3.0, 1*x + 1*z + -12.0] in MathOptInterface.Zeros(3) @@ -154,7 +154,7 @@ config = MOIT.Config() _test_delete_bridged_variable( bridged_mock, vis[1], - MOI.Nonpositives, + MOI.NonpositiveCone, 1, ((MOI.VectorOfVariables, MOI.NonnegativeCone, 0),), ) @@ -163,11 +163,11 @@ config = MOIT.Config() @testset "Delete in vector" begin MOI.empty!(bridged_mock) vis, ci = - MOI.add_constrained_variables(bridged_mock, MOI.Nonpositives(4)) + MOI.add_constrained_variables(bridged_mock, MOI.NonpositiveCone(4)) _test_delete_bridged_variable( bridged_mock, vis[2], - MOI.Nonpositives, + MOI.NonpositiveCone, 4, ((MOI.VectorOfVariables, MOI.NonnegativeCone, 0),), used_bridges = 0, diff --git a/test/Bridges/Variable/free.jl b/test/Bridges/Variable/free.jl index a055efa7e2..304db6294e 100644 --- a/test/Bridges/Variable/free.jl +++ b/test/Bridges/Variable/free.jl @@ -36,7 +36,7 @@ bridged_mock = MOIB.Variable.Free{Float64}(mock) mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ), ["c"], @@ -65,7 +65,7 @@ bridged_mock = MOIB.Variable.Free{Float64}(mock) s = """ variables: xpos, xneg nonneg: [xpos, xneg] in MathOptInterface.NonnegativeCone(2) - c: [4.0xpos + -4.0xneg + -1.0, 3.0xpos + -3.0xneg + -1.0] in MathOptInterface.Nonpositives(2) + c: [4.0xpos + -4.0xneg + -1.0, 3.0xpos + -3.0xneg + -1.0] in MathOptInterface.NonpositiveCone(2) maxobjective: xpos + -1.0xneg """ model = MOIU.Model{Float64}() @@ -75,7 +75,7 @@ bridged_mock = MOIB.Variable.Free{Float64}(mock) @testset "Bridged model" begin s = """ variables: x - c: [4.0x + -1.0, 3.0x + -1.0] in MathOptInterface.Nonpositives(2) + c: [4.0x + -1.0, 3.0x + -1.0] in MathOptInterface.NonpositiveCone(2) maxobjective: 1.0x """ model = MOIU.Model{Float64}() @@ -124,7 +124,7 @@ end 2, ( (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), - (MOI.VectorOfVariables, MOI.Nonpositives, 0), + (MOI.VectorOfVariables, MOI.NonpositiveCone, 0), ), ) _test_delete_bridged_variable( @@ -134,7 +134,7 @@ end 1, ( (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), - (MOI.VectorOfVariables, MOI.Nonpositives, 0), + (MOI.VectorOfVariables, MOI.NonpositiveCone, 0), ), ) end @@ -152,7 +152,7 @@ end [100, 0, 0, 100], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1.0]], - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[-1.0]], ), ) @@ -277,7 +277,7 @@ end 2, ( (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), - (MOI.VectorOfVariables, MOI.Nonpositives, 0), + (MOI.VectorOfVariables, MOI.NonpositiveCone, 0), ), used_bridges = 0, used_constraints = 0, @@ -289,7 +289,7 @@ end 1, ( (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), - (MOI.VectorOfVariables, MOI.Nonpositives, 0), + (MOI.VectorOfVariables, MOI.NonpositiveCone, 0), ), ) end diff --git a/test/Bridges/Variable/vectorize.jl b/test/Bridges/Variable/vectorize.jl index 57d9910e2a..fa917a66d2 100644 --- a/test/Bridges/Variable/vectorize.jl +++ b/test/Bridges/Variable/vectorize.jl @@ -134,7 +134,7 @@ end @testset "get `UnknownVariableAttribute``" begin err = ArgumentError( - "Variable bridge of type `$(MathOptInterface.Bridges.Variable.VectorizeBridge{Float64,MathOptInterface.Nonpositives})`" * + "Variable bridge of type `$(MathOptInterface.Bridges.Variable.VectorizeBridge{Float64,MathOptInterface.NonpositiveCone})`" * " does not support accessing the attribute `MathOptInterface.DeprecatedTest.UnknownVariableAttribute()`.", ) @test_throws err MOI.get( @@ -188,14 +188,14 @@ end mock, MOI.ListOfConstraintIndices{ MOI.VectorOfVariables, - MOI.Nonpositives, + MOI.NonpositiveCone, }(), ), ["zc"], ) s = """ variables: x, z - zc: [z] in MathOptInterface.Nonpositives(1) + zc: [z] in MathOptInterface.NonpositiveCone(1) xc: 2.0x <= 4.0 ec: [x, 1.0, z + 5.0] in MathOptInterface.ExponentialCone() """ @@ -241,6 +241,6 @@ end y, MOI.LessThan{Float64}, 2, - ((MOI.VectorOfVariables, MOI.Nonpositives, 0),), + ((MOI.VectorOfVariables, MOI.NonpositiveCone, 0),), ) end diff --git a/test/Bridges/bridge_optimizer.jl b/test/Bridges/bridge_optimizer.jl index 0ba4e2bfa4..51dc56304d 100644 --- a/test/Bridges/bridge_optimizer.jl +++ b/test/Bridges/bridge_optimizer.jl @@ -133,7 +133,7 @@ MOIU.@model( ( MOI.Zeros, MOI.NonnegativeCone, - MOI.Nonpositives, + MOI.NonpositiveCone, MOI.NormInfinityCone, MOI.NormOneCone, MOI.SecondOrderCone, diff --git a/test/Bridges/lazy_bridge_optimizer.jl b/test/Bridges/lazy_bridge_optimizer.jl index 139e271ac1..bb2d27f752 100644 --- a/test/Bridges/lazy_bridge_optimizer.jl +++ b/test/Bridges/lazy_bridge_optimizer.jl @@ -444,32 +444,32 @@ end model = SDPAModel{T}() bridged = MOIB.LazyBridgeOptimizer(model) @testset "Variable" begin - @testset "Nonpositives" begin + @testset "NonpositiveCone" begin @test !MOI.supports_constraint( model, MOI.VectorOfVariables, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @test !MOI.supports_constraint( bridged, MOI.VectorOfVariables, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @test !MOI.supports_add_constrained_variables( bridged, - MOI.Nonpositives, + MOI.NonpositiveCone, ) MOIB.add_bridge(bridged, MOIB.Variable.NonposToNonnegBridge{T}) @test !MOI.supports_constraint( bridged, MOI.VectorOfVariables, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @test MOI.supports_add_constrained_variables( bridged, - MOI.Nonpositives, + MOI.NonpositiveCone, ) - @test MOIB.bridge_type(bridged, MOI.Nonpositives) == + @test MOIB.bridge_type(bridged, MOI.NonpositiveCone) == MOIB.Variable.NonposToNonnegBridge{T} end @testset "Zeros" begin @@ -589,7 +589,7 @@ end MOI.LessThan{T}, ) @test MOIB.bridge_type(bridged, MOI.LessThan{T}) == - MOIB.Variable.VectorizeBridge{T,MOI.Nonpositives} + MOIB.Variable.VectorizeBridge{T,MOI.NonpositiveCone} @test !MOI.supports_constraint( bridged, MOI.SingleVariable, @@ -646,7 +646,7 @@ end 1, ( (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), - (MOI.VectorOfVariables, MOI.Nonpositives, 0), + (MOI.VectorOfVariables, MOI.NonpositiveCone, 0), ), used_bridges = 2, ) @@ -860,10 +860,10 @@ Bridge graph with 1 variable nodes, 0 constraint nodes and 0 objective nodes. """ Constrained variables in `MOI.LessThan{$T}` are not supported and cannot be bridged into supported constrained variables and constraints. See details below: [1] constrained variables in `MOI.LessThan{$T}` are not supported because: - Cannot use `$(MOIB.Variable.VectorizeBridge{T,MOI.Nonpositives})` because: - [2] constrained variables in `MOI.Nonpositives` are not supported + Cannot use `$(MOIB.Variable.VectorizeBridge{T,MOI.NonpositiveCone})` because: + [2] constrained variables in `MOI.NonpositiveCone` are not supported Cannot add free variables and then constrain them because free variables are bridged but no functionize bridge was added. - [2] constrained variables in `MOI.Nonpositives` are not supported because no added bridge supports bridging it. + [2] constrained variables in `MOI.NonpositiveCone` are not supported because no added bridge supports bridging it. Cannot add free variables and then constrain them because free variables are bridged but no functionize bridge was added. """, ) @@ -874,8 +874,8 @@ Constrained variables in `MOI.LessThan{$T}` are not supported and cannot be brid MOI.Utilities.replace_acronym( """ Bridge graph with 2 variable nodes, 0 constraint nodes and 0 objective nodes. - [1] constrained variables in `MOI.LessThan{$T}` are bridged (distance 2) by $(MOIB.Variable.VectorizeBridge{T,MOI.Nonpositives}). - [2] constrained variables in `MOI.Nonpositives` are bridged (distance 1) by $(MOIB.Variable.NonposToNonnegBridge{T}). + [1] constrained variables in `MOI.LessThan{$T}` are bridged (distance 2) by $(MOIB.Variable.VectorizeBridge{T,MOI.NonpositiveCone}). + [2] constrained variables in `MOI.NonpositiveCone` are bridged (distance 1) by $(MOIB.Variable.NonposToNonnegBridge{T}). """, ) end @@ -902,11 +902,11 @@ Bridge graph with 1 variable nodes, 1 constraint nodes and 0 objective nodes. """ Constrained variables in `MOI.LessThan{$T}` are not supported and cannot be bridged into supported constrained variables and constraints. See details below: [1] constrained variables in `MOI.LessThan{$T}` are not supported because: - Cannot use `$(MOIB.Variable.VectorizeBridge{T,MOI.Nonpositives})` because: - [2] constrained variables in `MOI.Nonpositives` are not supported + Cannot use `$(MOIB.Variable.VectorizeBridge{T,MOI.NonpositiveCone})` because: + [2] constrained variables in `MOI.NonpositiveCone` are not supported Cannot add free variables and then constrain them because: (1) `MOI.ScalarAffineFunction{$T}`-in-`MOI.LessThan{$T}` constraints are not supported - [2] constrained variables in `MOI.Nonpositives` are not supported because no added bridge supports bridging it. + [2] constrained variables in `MOI.NonpositiveCone` are not supported because no added bridge supports bridging it. Cannot add free variables and then constrain them because free variables are bridged but no functionize bridge was added. (1) `MOI.ScalarAffineFunction{$T}`-in-`MOI.LessThan{$T}` constraints are not supported because no added bridge supports bridging it. """, @@ -918,8 +918,8 @@ Constrained variables in `MOI.LessThan{$T}` are not supported and cannot be brid MOI.Utilities.replace_acronym( """ Bridge graph with 2 variable nodes, 1 constraint nodes and 0 objective nodes. - [1] constrained variables in `MOI.LessThan{$T}` are bridged (distance 2) by $(MOIB.Variable.VectorizeBridge{T,MOI.Nonpositives}). - [2] constrained variables in `MOI.Nonpositives` are bridged (distance 1) by $(MOIB.Variable.NonposToNonnegBridge{T}). + [1] constrained variables in `MOI.LessThan{$T}` are bridged (distance 2) by $(MOIB.Variable.VectorizeBridge{T,MOI.NonpositiveCone}). + [2] constrained variables in `MOI.NonpositiveCone` are bridged (distance 1) by $(MOIB.Variable.NonposToNonnegBridge{T}). (1) `MOI.ScalarAffineFunction{$T}`-in-`MOI.LessThan{$T}` constraints are not supported """, ) @@ -976,10 +976,10 @@ Bridge graph with 2 variable nodes, 1 constraint nodes and 0 objective nodes. """ `MOI.ScalarAffineFunction{$T}`-in-`MOI.Interval{$T}` constraints are not supported and cannot be bridged into supported constrained variables and constraints. See details below: [2] constrained variables in `MOI.LessThan{$T}` are not supported because: - Cannot use `$(MOIB.Variable.VectorizeBridge{T,MOI.Nonpositives})` because: - [3] constrained variables in `MOI.Nonpositives` are not supported + Cannot use `$(MOIB.Variable.VectorizeBridge{T,MOI.NonpositiveCone})` because: + [3] constrained variables in `MOI.NonpositiveCone` are not supported Cannot add free variables and then constrain them because free variables are bridged but no functionize bridge was added. - [3] constrained variables in `MOI.Nonpositives` are not supported because no added bridge supports bridging it. + [3] constrained variables in `MOI.NonpositiveCone` are not supported because no added bridge supports bridging it. Cannot add free variables and then constrain them because free variables are bridged but no functionize bridge was added. [4] constrained variables in `MOI.Interval{$T}` are not supported because no added bridge supports bridging it. Cannot add free variables and then constrain them because free variables are bridged but no functionize bridge was added. @@ -1202,7 +1202,7 @@ MOIU.@model( ( MOI.Zeros, MOI.NonnegativeCone, - MOI.Nonpositives, + MOI.NonpositiveCone, MOI.SecondOrderCone, MOI.NormInfinityCone, MOI.NormOneCone, @@ -1242,7 +1242,7 @@ MOIU.@model( NoVariableModel, (MOI.ZeroOne, MOI.Integer), (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan), - (MOI.Zeros, MOI.NonnegativeCone, MOI.Nonpositives, MOI.SecondOrderCone), + (MOI.Zeros, MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.SecondOrderCone), (), (), (MOI.ScalarAffineFunction,), @@ -1471,7 +1471,7 @@ MOIU.@model( ( MOI.Zeros, MOI.NonnegativeCone, - MOI.Nonpositives, + MOI.NonpositiveCone, MOI.SecondOrderCone, MOI.NormInfinityCone, MOI.NormOneCone, @@ -1555,7 +1555,7 @@ MOIU.@model( MOI.Reals, MOI.Zeros, MOI.NonnegativeCone, - MOI.Nonpositives, + MOI.NonpositiveCone, MOI.NormInfinityCone, MOI.NormOneCone, MOI.SecondOrderCone, @@ -1601,7 +1601,7 @@ MOIU.@model( MOI.Reals, MOI.Zeros, MOI.NonnegativeCone, - MOI.Nonpositives, + MOI.NonpositiveCone, MOI.NormInfinityCone, MOI.NormOneCone, MOI.SecondOrderCone, @@ -1650,7 +1650,7 @@ end @test !MOI.supports_constraint( bridged, MOI.VectorAffineFunction{Float64}, - MOI.Nonpositives, + MOI.NonpositiveCone, ) end @@ -1734,7 +1734,7 @@ end @testset "Supports" begin full_bridged_mock = MOIB.full_bridge_optimizer(mock, Float64) @testset "Mismatch vector/scalar" begin - for S in [MOI.NonnegativeCone, MOI.Nonpositives, MOI.Zeros] + for S in [MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.Zeros] @test !MOI.supports_constraint( full_bridged_mock, MOI.SingleVariable, @@ -1797,7 +1797,7 @@ end F, MOI.RelativeEntropyCone, ) - @test !MOI.supports_constraint(greater_nonneg_mock, F, MOI.Nonpositives) + @test !MOI.supports_constraint(greater_nonneg_mock, F, MOI.NonpositiveCone) @test MOI.supports_constraint( full_bridged_greater_nonneg, F, @@ -1894,7 +1894,7 @@ end ) end for S in [ - MOI.Nonpositives, + MOI.NonpositiveCone, MOI.NonnegativeCone, MOI.Zeros, MOI.SecondOrderCone, diff --git a/test/DeprecatedTest/contconic.jl b/test/DeprecatedTest/contconic.jl index 5cb5845e31..6ae2cbdc61 100644 --- a/test/DeprecatedTest/contconic.jl +++ b/test/DeprecatedTest/contconic.jl @@ -36,7 +36,7 @@ config = MOIT.Config() mock, [-4, -3, 16, 0], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0]], - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => [[0]], + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[0]], (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[7, 2, -4], [7]], ) @@ -181,7 +181,7 @@ end (MOI.VectorAffineFunction{Float64}, MOI.SecondOrderCone) => [[√2, 1, -1]], (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[√2]], - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[-1.0]], ) MOIT.soc2ptest(mock, config) @@ -537,7 +537,7 @@ end [2η / 3, 0, η / 3, 0, 0, 0, η * δ * (1 - 1 / √3) / 2], (MOI.ScalarAffineFunction{Float64}, MOI.GreaterThan{Float64}) => [δ * (1 - 1 / √3) / 2], - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => [[ + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[ 0, -α / √3 + δ / (2 * √6) * (2 * √2 - 1), 0, diff --git a/test/DeprecatedTest/unit.jl b/test/DeprecatedTest/unit.jl index b055d29167..1e65bc5327 100644 --- a/test/DeprecatedTest/unit.jl +++ b/test/DeprecatedTest/unit.jl @@ -227,7 +227,7 @@ end MOI.OPTIMAL, (MOI.FEASIBLE_POINT, [0.5]), MOI.FEASIBLE_POINT, - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives) => + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[-0.5]], ), ) diff --git a/test/FileFormats/CBF/CBF.jl b/test/FileFormats/CBF/CBF.jl index 5db4ea7baa..df12252e72 100644 --- a/test/FileFormats/CBF/CBF.jl +++ b/test/FileFormats/CBF/CBF.jl @@ -32,7 +32,7 @@ function _set_var_and_con_names(model::MOI.ModelLike) MOI.Reals, MOI.Zeros, MOI.NonnegativeCone, - MOI.Nonpositives, + MOI.NonpositiveCone, MOI.SecondOrderCone, MOI.RotatedSecondOrderCone, MOI.PositiveSemidefiniteConeTriangle, @@ -232,11 +232,11 @@ const _WRITE_READ_MODELS = [ """, ), ( - "VectorOfVariables in Nonpositives", + "VectorOfVariables in NonpositiveCone", """ variables: x, y minobjective: x - c1: [y, x] in Nonpositives(2) + c1: [y, x] in NonpositiveCone(2) """, ), ( @@ -264,11 +264,11 @@ const _WRITE_READ_MODELS = [ """, ), ( - "VectorAffineFunction in Nonpositives", + "VectorAffineFunction in NonpositiveCone", """ variables: x minobjective: 1.2x - c1: [-1.1 * x + 1] in Nonpositives(1) + c1: [-1.1 * x + 1] in NonpositiveCone(1) """, ), ( @@ -419,7 +419,7 @@ const _EXAMPLE_MODELS = [ maxobjective: a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + -1 c1: [b] in Zeros(1) c2: [c] in NonnegativeCone(1) - c3: [d] in Nonpositives(1) + c3: [d] in NonpositiveCone(1) c4: [e, f, g] in SecondOrderCone(3) c5: [h, i, j] in RotatedSecondOrderCone(3) c6: [m, l, k] in ExponentialCone() diff --git a/test/FileFormats/MOF/MOF.jl b/test/FileFormats/MOF/MOF.jl index b02be57e70..e0e39526e9 100644 --- a/test/FileFormats/MOF/MOF.jl +++ b/test/FileFormats/MOF/MOF.jl @@ -568,7 +568,7 @@ function test_Nonpositives() """ variables: x, y, z minobjective: x -c1: [x, y, z] in Nonpositives(3) +c1: [x, y, z] in NonpositiveCone(3) """, ["x", "y", "z"], ["c1"], diff --git a/test/Utilities/copy.jl b/test/Utilities/copy.jl index 71178384ca..b4f8958d73 100644 --- a/test/Utilities/copy.jl +++ b/test/Utilities/copy.jl @@ -269,7 +269,7 @@ function test_ConstrainedVariablesModel_allocate_true() src = MOIU.Model{Int}() x = MOI.add_variables(src, 3) cx = MOI.add_constraint(src, [x[1], x[3], x[1], x[2]], MOI.NonnegativeCone(4)) - y, cy = MOI.add_constrained_variables(src, MOI.Nonpositives(3)) + y, cy = MOI.add_constrained_variables(src, MOI.NonpositiveCone(3)) dest = ConstrainedVariablesModel(true, Bool[]) idxmap = MOI.copy_to(dest, src) for vi in x @@ -285,7 +285,7 @@ function test_ConstrainedVariablesModel_allocate_false() src = MOIU.Model{Int}() x = MOI.add_variables(src, 3) cx = MOI.add_constraint(src, [x[1], x[3], x[1], x[2]], MOI.NonnegativeCone(4)) - y, cy = MOI.add_constrained_variables(src, MOI.Nonpositives(3)) + y, cy = MOI.add_constrained_variables(src, MOI.NonpositiveCone(3)) dest = ConstrainedVariablesModel(false, Bool[]) idxmap = MOI.copy_to(dest, src) for vi in x @@ -384,7 +384,7 @@ end function MOI.supports_add_constrained_variables( ::OrderConstrainedVariablesModel, - ::Type{MOI.Nonpositives}, + ::Type{MOI.NonpositiveCone}, ) return false end @@ -414,7 +414,7 @@ end function MOI.supports_add_constrained_variables( ::ReverseOrderConstrainedVariablesModel, - ::Type{MOI.Nonpositives}, + ::Type{MOI.NonpositiveCone}, ) return true end @@ -430,7 +430,7 @@ end function MOI.supports_constraint( ::ReverseOrderConstrainedVariablesModel, ::Type{MOI.VectorAffineFunction{Float64}}, - ::Type{MOI.Nonpositives}, + ::Type{MOI.NonpositiveCone}, ) return true end @@ -503,7 +503,7 @@ From Issue #987 function test_create_variables_using_supports_add_constrained_variable() # With vectors src = MOIU.Model{Float64}() - a, c1 = MOI.add_constrained_variables(src, MOI.Nonpositives(3)) + a, c1 = MOI.add_constrained_variables(src, MOI.NonpositiveCone(3)) c2 = MOI.add_constraint(src, a, MOI.NonnegativeCone(3)) dest = OrderConstrainedVariablesModel() @@ -520,14 +520,14 @@ function test_create_variables_using_supports_add_constrained_variable() c3 = MOI.add_constraint(src, b, MOI.Zeros(2)) d, cd = MOI.add_constrained_variables(src, MOI.Zeros(2)) - c4 = MOI.add_constraint(src, d, MOI.Nonpositives(2)) + c4 = MOI.add_constraint(src, d, MOI.NonpositiveCone(2)) dest = OrderConstrainedVariablesModel() bridged_dest = MOI.Bridges.full_bridge_optimizer(dest, Float64) @test MOIU.sorted_variable_sets_by_cost(bridged_dest, src) == [ (MOI.VectorOfVariables, MOI.Zeros), (MOI.VectorOfVariables, MOI.NonnegativeCone), - (MOI.VectorOfVariables, MOI.Nonpositives), + (MOI.VectorOfVariables, MOI.NonpositiveCone), ] @test MOI.supports_add_constrained_variables(bridged_dest, MOI.NonnegativeCone) @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.NonnegativeCone}()) == @@ -541,17 +541,17 @@ function test_create_variables_using_supports_add_constrained_variable() bridged_dest, MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.NonnegativeCone}(), ) == 0.0 - @test MOI.supports_add_constrained_variables(bridged_dest, MOI.Nonpositives) - @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.Nonpositives}()) == + @test MOI.supports_add_constrained_variables(bridged_dest, MOI.NonpositiveCone) + @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.NonpositiveCone}()) == 1.0 @test MOI.supports_constraint( bridged_dest, MOI.VectorOfVariables, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @test MOI.get( bridged_dest, - MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.Nonpositives}(), + MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) == 1.0 @test MOI.supports_add_constrained_variables(bridged_dest, MOI.Zeros) @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.Zeros}()) == 1.0 @@ -571,7 +571,7 @@ function test_create_variables_using_supports_add_constrained_variable() bridged_dest = MOI.Bridges.full_bridge_optimizer(dest, Float64) @test MOIU.sorted_variable_sets_by_cost(bridged_dest, src) == [ (MOI.VectorOfVariables, MOI.Zeros), - (MOI.VectorOfVariables, MOI.Nonpositives), + (MOI.VectorOfVariables, MOI.NonpositiveCone), (MOI.VectorOfVariables, MOI.NonnegativeCone), ] @test MOI.supports_add_constrained_variables(bridged_dest, MOI.NonnegativeCone) @@ -586,17 +586,17 @@ function test_create_variables_using_supports_add_constrained_variable() bridged_dest, MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.NonnegativeCone}(), ) == 1.0 - @test MOI.supports_add_constrained_variables(bridged_dest, MOI.Nonpositives) - @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.Nonpositives}()) == + @test MOI.supports_add_constrained_variables(bridged_dest, MOI.NonpositiveCone) + @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.NonpositiveCone}()) == 0.0 @test MOI.supports_constraint( bridged_dest, MOI.VectorOfVariables, - MOI.Nonpositives, + MOI.NonpositiveCone, ) @test MOI.get( bridged_dest, - MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.Nonpositives}(), + MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) == 1.0 @test MOI.supports_add_constrained_variables(bridged_dest, MOI.Zeros) @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.Zeros}()) == 1.0 diff --git a/test/Utilities/matrix_of_constraints.jl b/test/Utilities/matrix_of_constraints.jl index b7b0a73091..e873e05d80 100644 --- a/test/Utilities/matrix_of_constraints.jl +++ b/test/Utilities/matrix_of_constraints.jl @@ -265,8 +265,8 @@ function test_contlinear(Indexing) end MOIU.@product_of_sets(Nonneg, MOI.NonnegativeCone) -MOIU.@product_of_sets(NonposNonneg, MOI.Nonpositives, MOI.NonnegativeCone) -MOIU.@product_of_sets(NonnegNonpos, MOI.NonnegativeCone, MOI.Nonpositives) +MOIU.@product_of_sets(NonposNonneg, MOI.NonpositiveCone, MOI.NonnegativeCone) +MOIU.@product_of_sets(NonnegNonpos, MOI.NonnegativeCone, MOI.NonpositiveCone) function test_contconic() test_contconic(MOIU.OneBasedIndexing) @@ -326,7 +326,7 @@ function test_contconic(Indexing) ) do optimizer return _lin3_query( optimizer, - [(F, MOI.NonnegativeCone), (F, MOI.Nonpositives)], + [(F, MOI.NonnegativeCone), (F, MOI.NonpositiveCone)], ) end b = [1.0, -1.0] @@ -341,7 +341,7 @@ function test_contconic(Indexing) ) do optimizer return _lin3_query( optimizer, - [(F, MOI.Nonpositives), (F, MOI.NonnegativeCone)], + [(F, MOI.NonpositiveCone), (F, MOI.NonnegativeCone)], ) end # Here, we test that it works of some constraints are bridged but not all. @@ -400,7 +400,7 @@ function test_nametest() VoVorSAff{T}{ MOIU.VectorOfConstraints{ MOI.VectorOfVariables, - MOI.Nonpositives, + MOI.NonpositiveCone, }, MOIU.MatrixOfConstraints{ T, @@ -529,7 +529,7 @@ end MOIU.@struct_of_constraints_by_set_types( ZerosOrNot, MOI.Zeros, - Union{MOI.NonnegativeCone,MOI.Nonpositives}, + Union{MOI.NonnegativeCone,MOI.NonpositiveCone}, ) function test_multicone() @@ -566,7 +566,7 @@ function test_multicone() MOI.add_constraint( model, MOIU.vectorize([T(6), T(7) * fx, T(4)]), - MOI.Nonpositives(1), + MOI.NonpositiveCone(1), ) MOIU.final_touch(model, nothing) _test_matrix_equal( diff --git a/test/Utilities/model.jl b/test/Utilities/model.jl index 184b257eac..931cd16f40 100644 --- a/test/Utilities/model.jl +++ b/test/Utilities/model.jl @@ -352,10 +352,10 @@ function test_quadratic_functions() }(), ) f7 = MOI.VectorOfVariables([x, y]) - c7 = MOI.add_constraint(model, f7, MOI.Nonpositives(2)) + c7 = MOI.add_constraint(model, f7, MOI.NonpositiveCone(2)) @test 1 == @inferred MOI.get( model, - MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.Nonpositives}(), + MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) f8 = MOI.VectorOfVariables([x, y]) @@ -388,7 +388,7 @@ function test_quadratic_functions() ) in loc @test (MOI.VectorOfVariables, MOI.RotatedSecondOrderCone) in loc @test (MOI.VectorAffineFunction{Int}, MOI.SecondOrderCone) in loc - @test (MOI.VectorOfVariables, MOI.Nonpositives) in loc + @test (MOI.VectorOfVariables, MOI.NonpositiveCone) in loc end @test MOI.is_valid(model, c4) MOI.delete(model, c4) @@ -433,11 +433,11 @@ function test_quadratic_functions() @test f.constants == [6, 8] @test 1 == @inferred MOI.get( model, - MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.Nonpositives}(), + MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) @test [c7] == @inferred MOI.get( model, - MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.Nonpositives}(), + MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) f = MOI.get(model, MOI.ConstraintFunction(), c7) @test f.variables == [x] diff --git a/test/Utilities/product_of_sets.jl b/test/Utilities/product_of_sets.jl index 94f7b6bb4f..46eb467abd 100644 --- a/test/Utilities/product_of_sets.jl +++ b/test/Utilities/product_of_sets.jl @@ -128,14 +128,14 @@ end MOI.Utilities.@product_of_sets( _VectorSets, - MOI.Nonpositives, + MOI.NonpositiveCone, MOI.NonnegativeCone, MOI.EqualTo{T}, ) function test_vector_set_index() sets = _VectorSets{Float64}() - @test MOI.Utilities.set_index(sets, MOI.Nonpositives) == 1 + @test MOI.Utilities.set_index(sets, MOI.NonpositiveCone) == 1 @test MOI.Utilities.set_index(sets, MOI.NonnegativeCone) == 2 @test MOI.Utilities.set_index(sets, MOI.EqualTo{Float64}) == 3 @test MOI.Utilities.set_index(sets, MOI.LessThan{Float64}) === nothing @@ -144,7 +144,7 @@ end function test_vector_set_types() sets = _VectorSets{Float64}() @test MOI.Utilities.set_types(sets) == - [MOI.Nonpositives, MOI.NonnegativeCone, MOI.EqualTo{Float64}] + [MOI.NonpositiveCone, MOI.NonnegativeCone, MOI.EqualTo{Float64}] end function test_vector_basic() @@ -220,7 +220,7 @@ function test_vector_ConstraintTypesPresent() MOI.Utilities.add_set(sets, 3) MOI.Utilities.final_touch(sets) @test MOI.get(sets, MOI.ListOfConstraintTypesPresent()) == [ - (MOI.VectorAffineFunction{Float64}, MOI.Nonpositives), + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone), (MOI.ScalarAffineFunction{Float64}, MOI.EqualTo{Float64}), ] end diff --git a/test/hygiene.jl b/test/hygiene.jl index fe61c281c3..b776bb145d 100644 --- a/test/hygiene.jl +++ b/test/hygiene.jl @@ -13,7 +13,7 @@ MathOptInterface.Utilities.@model( LPModel, # Name of model (), # untyped scalar sets (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan, MOI.Interval), # typed scalar sets - (MOI.Zeros, MOI.NonnegativeCone, MOI.Nonpositives), # untyped vector sets + (MOI.Zeros, MOI.NonnegativeCone, MOI.NonpositiveCone), # untyped vector sets (), # typed vector sets (), # untyped scalar functions (MOI.ScalarAffineFunction,), # typed scalar functions diff --git a/test/sets.jl b/test/sets.jl index 6c62e2005b..8876626287 100644 --- a/test/sets.jl +++ b/test/sets.jl @@ -119,7 +119,7 @@ function test_sets_DimensionMismatch() (MOI.Reals, 0), (MOI.Zeros, 0), (MOI.NonnegativeCone, 0), - (MOI.Nonpositives, 0), + (MOI.NonpositiveCone, 0), (MOI.NormInfinityCone, 1), (MOI.NormOneCone, 1), (MOI.SecondOrderCone, 1), @@ -163,8 +163,8 @@ function _self_dual_set_test(set) end function test_sets_dual_nonpositives() - nonpositives3 = MOI.Nonpositives(3) - nonpositives4 = MOI.Nonpositives(4) + nonpositives3 = MOI.NonpositiveCone(3) + nonpositives4 = MOI.NonpositiveCone(4) _self_dual_set_test(nonpositives3) @test MOI.dual_set(nonpositives3) != nonpositives4 _self_dual_set_test(nonpositives4) From e5c833d33dde2d7e82b3a793294a30c847757631 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 18 Jul 2021 05:36:03 +0200 Subject: [PATCH 3/5] Rename Zeros to ZeroCone. --- docs/src/manual/constraints.md | 2 +- docs/src/manual/standard_form.md | 2 +- src/Bridges/Constraint/interval.jl | 16 ++-- src/Bridges/Constraint/scalarize.jl | 2 +- src/Bridges/Constraint/slack.jl | 12 +-- src/Bridges/Variable/Variable.jl | 2 +- src/Bridges/Variable/zeros.jl | 8 +- .../UnitTests/basic_constraint_tests.jl | 12 +-- src/DeprecatedTest/contconic.jl | 66 +++++++------- src/DeprecatedTest/contlinear.jl | 4 +- src/DeprecatedTest/intconic.jl | 8 +- src/DeprecatedTest/modellike.jl | 22 ++--- src/FileFormats/CBF/CBF.jl | 2 +- src/FileFormats/CBF/read.jl | 2 +- src/FileFormats/CBF/write.jl | 4 +- src/FileFormats/MOF/MOF.jl | 2 +- src/FileFormats/MOF/mof.0.6.schema.json | 4 +- src/FileFormats/MOF/read.jl | 6 +- src/FileFormats/MOF/write.jl | 2 +- src/Test/test_basic_constraint.jl | 4 +- src/Test/test_conic.jl | 90 +++++++++---------- src/Test/test_linear.jl | 8 +- src/Test/test_model.jl | 2 +- src/Test/test_quadratic.jl | 8 +- src/Utilities/model.jl | 8 +- src/Utilities/precompile.jl | 2 +- src/Utilities/product_of_sets.jl | 2 +- src/Utilities/sets.jl | 6 +- src/sets.jl | 26 +++--- test/Bridges/Constraint/flip_sign.jl | 2 +- test/Bridges/Constraint/functionize.jl | 2 +- test/Bridges/Constraint/interval.jl | 10 +-- test/Bridges/Constraint/norm_to_lp.jl | 28 +++--- test/Bridges/Constraint/rsoc.jl | 4 +- test/Bridges/Constraint/scalarize.jl | 16 ++-- test/Bridges/Constraint/slack.jl | 8 +- test/Bridges/Constraint/soc_to_psd.jl | 2 +- test/Bridges/Constraint/vectorize.jl | 4 +- test/Bridges/Variable/flip_sign.jl | 14 +-- test/Bridges/Variable/map.jl | 4 +- test/Bridges/Variable/soc_to_rsoc.jl | 8 +- test/Bridges/Variable/zeros.jl | 14 +-- test/Bridges/bridge_optimizer.jl | 2 +- test/Bridges/lazy_bridge_optimizer.jl | 60 ++++++------- test/DeprecatedTest/contconic.jl | 26 +++--- test/DeprecatedTest/contlinear.jl | 2 +- test/FileFormats/CBF/CBF.jl | 14 +-- test/FileFormats/MOF/MOF.jl | 4 +- test/Utilities/copy.jl | 26 +++--- test/Utilities/matrix_of_constraints.jl | 14 +-- test/Utilities/product_of_sets.jl | 6 +- test/constraints.jl | 2 +- test/dummy.jl | 2 +- test/errors.jl | 2 +- test/hygiene.jl | 2 +- test/sets.jl | 6 +- 56 files changed, 309 insertions(+), 309 deletions(-) diff --git a/docs/src/manual/constraints.md b/docs/src/manual/constraints.md index a6b5ae92de..f29410f80e 100644 --- a/docs/src/manual/constraints.md +++ b/docs/src/manual/constraints.md @@ -110,7 +110,7 @@ nonpositive) real numbers. | ``\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` | `Zeros` | +| ``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 diff --git a/docs/src/manual/standard_form.md b/docs/src/manual/standard_form.md index 3356661179..6ee0902405 100644 --- a/docs/src/manual/standard_form.md +++ b/docs/src/manual/standard_form.md @@ -73,7 +73,7 @@ The vector-valued set types implemented in MathOptInterface.jl are: * [`Reals(dimension)`](@ref MathOptInterface.Reals): ``\mathbb{R}^\mbox{dimension}`` -* [`Zeros(dimension)`](@ref MathOptInterface.Zeros): ``0^\mbox{dimension}`` +* [`ZeroCone(dimension)`](@ref MathOptInterface.ZeroCone): ``0^\mbox{dimension}`` * [`NonnegativeCone(dimension)`](@ref MathOptInterface.NonnegativeCone): ``\{ x \in \mathbb{R}^\mbox{dimension} : x \ge 0 \}`` * [`NonpositiveCone(dimension)`](@ref MathOptInterface.NonpositiveCone): diff --git a/src/Bridges/Constraint/interval.jl b/src/Bridges/Constraint/interval.jl index 4ef7cee603..54eba8a152 100644 --- a/src/Bridges/Constraint/interval.jl +++ b/src/Bridges/Constraint/interval.jl @@ -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.NonnegativeCone(set.dimension) -_upper_set(set::MOI.Zeros) = MOI.NonpositiveCone(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} @@ -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.NonnegativeCone` and `US = MOI.NonpositiveCone`. +* `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 @@ -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 @@ -77,9 +77,9 @@ 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.NonnegativeCone,MOI.NonpositiveCone} + return SplitIntervalBridge{T,F,MOI.ZeroCone,MOI.NonnegativeCone,MOI.NonpositiveCone} end # Attributes, Bridge acting as a model @@ -286,7 +286,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 diff --git a/src/Bridges/Constraint/scalarize.jl b/src/Bridges/Constraint/scalarize.jl index fe8d1ad601..31bcebc703 100644 --- a/src/Bridges/Constraint/scalarize.jl +++ b/src/Bridges/Constraint/scalarize.jl @@ -30,7 +30,7 @@ function MOI.supports_constraint( F::Type{<:MOI.AbstractVectorFunction}, ::Type{<:MOIU.VectorLinearSet}, ) where {T} - # If `F` is `MOI.VectorAffineFunction{Complex{Float64}}`, `S` is `MOI.Zeros` and `T` is `Float64`, + # If `F` is `MOI.VectorAffineFunction{Complex{Float64}}`, `S` is `MOI.ZeroCone` and `T` is `Float64`, # it would create a set `MOI.EqualTo{Float64}` which is incorrect hence we say # we only support it if the coefficient type of `F` is `T`. return MOIU.is_coefficient_type(F, T) diff --git a/src/Bridges/Constraint/slack.jl b/src/Bridges/Constraint/slack.jl index 29278a5765..0e39a110b1 100644 --- a/src/Bridges/Constraint/slack.jl +++ b/src/Bridges/Constraint/slack.jl @@ -266,15 +266,15 @@ end VectorSlackBridge{T, F, S} The `VectorSlackBridge` converts a constraint `G`-in-`S` where `G` is a function different -from `VectorOfVariables` into the constraints `F`in-`Zeros` and `VectorOfVariables`-in-`S`. +from `VectorOfVariables` into the constraints `F`in-`ZeroCone` and `VectorOfVariables`-in-`S`. `F` is the result of subtracting a `VectorOfVariables` from `G`. Tipically `G` is the same as `F`, but that is not mandatory. """ struct VectorSlackBridge{T,F,S} <: - AbstractSlackBridge{T,MOI.VectorOfVariables,MOI.Zeros,F,S} + AbstractSlackBridge{T,MOI.VectorOfVariables,MOI.ZeroCone,F,S} slack::Vector{MOI.VariableIndex} slack_in_set::CI{MOI.VectorOfVariables,S} - equality::CI{F,MOI.Zeros} + equality::CI{F,MOI.ZeroCone} end function bridge_constraint( @@ -286,7 +286,7 @@ function bridge_constraint( d = MOI.dimension(s) slack, slack_in_set = MOI.add_constrained_variables(model, s) new_f = MOIU.operate(-, T, f, MOI.VectorOfVariables(slack)) - equality = MOI.add_constraint(model, new_f, MOI.Zeros(d)) + equality = MOI.add_constraint(model, new_f, MOI.ZeroCone(d)) return VectorSlackBridge{T,F,S}(slack, slack_in_set, equality) end @@ -301,7 +301,7 @@ end function MOI.supports_constraint( ::Type{VectorSlackBridge{T}}, ::Type{<:MOI.VectorOfVariables}, - ::Type{<:MOI.Zeros}, + ::Type{<:MOI.ZeroCone}, ) where {T} return false end @@ -309,7 +309,7 @@ end function MOI.supports_constraint( ::Type{VectorSlackBridge{T}}, ::Type{<:MOI.AbstractVectorFunction}, - ::Type{<:MOI.Zeros}, + ::Type{<:MOI.ZeroCone}, ) where {T} return false end diff --git a/src/Bridges/Variable/Variable.jl b/src/Bridges/Variable/Variable.jl index 5972c53408..d421183a72 100644 --- a/src/Bridges/Variable/Variable.jl +++ b/src/Bridges/Variable/Variable.jl @@ -32,7 +32,7 @@ end include("set_map.jl") include("zeros.jl") -const Zeros{T,OT<:MOI.ModelLike} = SingleBridgeOptimizer{ZerosBridge{T},OT} +const ZeroCone{T,OT<:MOI.ModelLike} = SingleBridgeOptimizer{ZerosBridge{T},OT} include("free.jl") const Free{T,OT<:MOI.ModelLike} = SingleBridgeOptimizer{FreeBridge{T},OT} diff --git a/src/Bridges/Variable/zeros.jl b/src/Bridges/Variable/zeros.jl index d0553c9a5e..2f965eed73 100644 --- a/src/Bridges/Variable/zeros.jl +++ b/src/Bridges/Variable/zeros.jl @@ -1,7 +1,7 @@ """ ZerosBridge{T} <: Bridges.Variable.AbstractBridge -Transforms constrained variables in [`MathOptInterface.Zeros`](@ref) to zeros, +Transforms constrained variables in [`MathOptInterface.ZeroCone`](@ref) to zeros, which ends up creating no variables in the underlying model. The bridged variables are therefore similar to parameters with zero values. @@ -22,12 +22,12 @@ end function bridge_constrained_variable( ::Type{ZerosBridge{T}}, model::MOI.ModelLike, - set::MOI.Zeros, + set::MOI.ZeroCone, ) where {T} return ZerosBridge{T}(MOI.dimension(set)) end -function supports_constrained_variable(::Type{<:ZerosBridge}, ::Type{MOI.Zeros}) +function supports_constrained_variable(::Type{<:ZerosBridge}, ::Type{MOI.ZeroCone}) return true end @@ -52,7 +52,7 @@ MOI.delete(::MOI.ModelLike, ::ZerosBridge) = nothing # Attributes, Bridge acting as a constraint function MOI.get(::MOI.ModelLike, ::MOI.ConstraintSet, bridge::ZerosBridge) - return MOI.Zeros(bridge.n) + return MOI.ZeroCone(bridge.n) end function MOI.get( diff --git a/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl b/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl index fc3cf646e7..8d978b25c1 100644 --- a/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl +++ b/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl @@ -55,8 +55,8 @@ const BasicConstraintTests = Dict( (dummy_vectorofvariables, 2, MOI.SOS1([1.0, 2.0])), (MOI.VectorOfVariables, MOI.SOS2{Float64}) => (dummy_vectorofvariables, 2, MOI.SOS2([1.0, 2.0])), - (MOI.VectorOfVariables, MOI.Zeros) => - (dummy_vectorofvariables, 2, MOI.Zeros(2)), + (MOI.VectorOfVariables, MOI.ZeroCone) => + (dummy_vectorofvariables, 2, MOI.ZeroCone(2)), (MOI.VectorOfVariables, MOI.NonpositiveCone) => (dummy_vectorofvariables, 2, MOI.NonpositiveCone(2)), (MOI.VectorOfVariables, MOI.NonnegativeCone) => @@ -116,8 +116,8 @@ const BasicConstraintTests = Dict( (dummy_scalar_quadratic, 1, MOI.EqualTo(1.0)), (MOI.ScalarQuadraticFunction{Float64}, MOI.Interval{Float64}) => (dummy_scalar_quadratic, 1, MOI.Interval(1.0, 2.0)), - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => - (dummy_vector_affine, 2, MOI.Zeros(2)), + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => + (dummy_vector_affine, 2, MOI.ZeroCone(2)), (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => (dummy_vector_affine, 2, MOI.NonpositiveCone(2)), (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => @@ -157,8 +157,8 @@ const BasicConstraintTests = Dict( 2, MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.GreaterThan(3.0)), ), - (MOI.VectorQuadraticFunction{Float64}, MOI.Zeros) => - (dummy_vector_quadratic, 2, MOI.Zeros(2)), + (MOI.VectorQuadraticFunction{Float64}, MOI.ZeroCone) => + (dummy_vector_quadratic, 2, MOI.ZeroCone(2)), (MOI.VectorQuadraticFunction{Float64}, MOI.NonpositiveCone) => (dummy_vector_quadratic, 2, MOI.NonpositiveCone(2)), (MOI.VectorQuadraticFunction{Float64}, MOI.NonnegativeCone) => diff --git a/src/DeprecatedTest/contconic.jl b/src/DeprecatedTest/contconic.jl index 1758f476d2..f6001491aa 100644 --- a/src/DeprecatedTest/contconic.jl +++ b/src/DeprecatedTest/contconic.jl @@ -32,7 +32,7 @@ function _lin1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) MOI.empty!(model) @test MOI.is_empty(model) @@ -57,7 +57,7 @@ function _lin1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) ), [-3.0, -2.0], ), - MOI.Zeros(2), + MOI.ZeroCone(2), ) if config.query_number_of_constraints @test MOI.get( @@ -72,7 +72,7 @@ function _lin1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 1 end @@ -82,7 +82,7 @@ function _lin1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) vecofvars ? MOI.VectorOfVariables : MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone, ) in loc - @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) in loc MOI.set( model, MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}(), @@ -132,7 +132,7 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) rtol = config.rtol #@test MOI.supportsproblem(model, MOI.ScalarAffineFunction{Float64}, #[ - # (MOI.VectorAffineFunction{Float64},MOI.Zeros), + # (MOI.VectorAffineFunction{Float64},MOI.ZeroCone), # (MOI.VectorOfVariables,MOI.NonnegativeCone), # (MOI.VectorOfVariables,MOI.NonpositiveCone) #]) @@ -160,7 +160,7 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) MOI.NonnegativeCone, ) @test MOI.supports_add_constrained_variables(model, MOI.NonpositiveCone) - @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.Zeros) + @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.ZeroCone) else @test MOI.supports_constraint( model, @@ -176,7 +176,7 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) MOI.empty!(model) @test MOI.is_empty(model) @@ -214,7 +214,7 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) ), [4.0, 3.0, -12.0], ), - MOI.Zeros(3), + MOI.ZeroCone(3), ) if vecofvars # test fallback @@ -231,12 +231,12 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) end vov = MOI.VectorOfVariables([s]) if vecofvars - vs = MOI.add_constraint(model, vov, MOI.Zeros(1)) + vs = MOI.add_constraint(model, vov, MOI.ZeroCone(1)) else vs = MOI.add_constraint( model, MOI.VectorAffineFunction{Float64}(vov), - MOI.Zeros(1), + MOI.ZeroCone(1), ) end if config.query_number_of_constraints @@ -244,7 +244,7 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 2 - vecofvars @test MOI.get( @@ -493,12 +493,12 @@ function _norminf1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) ) @test MOI.supports(model, MOI.ObjectiveSense()) if vecofvars - @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.Zeros) + @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.ZeroCone) else @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) end @test MOI.supports_constraint( @@ -524,7 +524,7 @@ function _norminf1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Zeros(1), + MOI.ZeroCone(1), ) ceq2 = MOI.add_constraint( model, @@ -532,7 +532,7 @@ function _norminf1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, y))], [-0.5], ), - MOI.Zeros(1), + MOI.ZeroCone(1), ) vov = MOI.VectorOfVariables([x, y, z]) if vecofvars @@ -549,7 +549,7 @@ function _norminf1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 2 @test MOI.get( @@ -563,7 +563,7 @@ function _norminf1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) end loc = MOI.get(model, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 2 - @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) in loc @test ( vecofvars ? MOI.VectorOfVariables : MOI.VectorAffineFunction{Float64}, MOI.NormInfinityCone, @@ -820,12 +820,12 @@ function _normone1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) ) @test MOI.supports(model, MOI.ObjectiveSense()) if vecofvars - @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.Zeros) + @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.ZeroCone) else @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) end @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.NormOneCone) @@ -847,7 +847,7 @@ function _normone1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Zeros(1), + MOI.ZeroCone(1), ) ceq2 = MOI.add_constraint( model, @@ -855,7 +855,7 @@ function _normone1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, y))], [-0.5], ), - MOI.Zeros(1), + MOI.ZeroCone(1), ) vov = MOI.VectorOfVariables([x, y, z]) if vecofvars @@ -872,7 +872,7 @@ function _normone1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 2 @test MOI.get( @@ -886,7 +886,7 @@ function _normone1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) end loc = MOI.get(model, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 2 - @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) in loc @test ( vecofvars ? MOI.VectorOfVariables : MOI.VectorAffineFunction{Float64}, MOI.NormOneCone, @@ -1149,7 +1149,7 @@ function _soc1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) MOI.SecondOrderCone, ) end - @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.Zeros) + @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.ZeroCone) MOI.empty!(model) @test MOI.is_empty(model) if vecofvars @@ -1179,14 +1179,14 @@ function _soc1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Zeros(1), + MOI.ZeroCone(1), ) if config.query_number_of_constraints @test MOI.get( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 1 @test MOI.get( @@ -1200,7 +1200,7 @@ function _soc1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) end loc = MOI.get(model, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 2 - @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) in loc @test ( vecofvars ? MOI.VectorOfVariables : MOI.VectorAffineFunction{Float64}, MOI.SecondOrderCone, @@ -1265,7 +1265,7 @@ function _soc2test(model::MOI.ModelLike, config::Config, nonneg::Bool) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) if nonneg @test MOI.supports_constraint( @@ -1319,7 +1319,7 @@ function _soc2test(model::MOI.ModelLike, config::Config, nonneg::Bool) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(-1.0, t))], [1.0], ), - MOI.Zeros(1), + MOI.ZeroCone(1), ) csoc = MOI.add_constraint( model, @@ -1344,7 +1344,7 @@ function _soc2test(model::MOI.ModelLike, config::Config, nonneg::Bool) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 1 @test MOI.get( @@ -1521,7 +1521,7 @@ function soc4test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) @test MOI.supports_constraint( model, @@ -1540,7 +1540,7 @@ function soc4test(model::MOI.ModelLike, config::Config) ), [-1.0, 0.0, 0.0], ), - MOI.Zeros(3), + MOI.ZeroCone(3), ) c2 = MOI.add_constraint( model, @@ -1552,7 +1552,7 @@ function soc4test(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 1 @test MOI.get( diff --git a/src/DeprecatedTest/contlinear.jl b/src/DeprecatedTest/contlinear.jl index 0a02cef3c4..45be8bab0d 100644 --- a/src/DeprecatedTest/contlinear.jl +++ b/src/DeprecatedTest/contlinear.jl @@ -2181,7 +2181,7 @@ function linear15test(model::MOI.ModelLike, config::Config{T}) where {T} MOI.ObjectiveFunction{MOI.ScalarAffineFunction{T}}(), ) @test MOI.supports(model, MOI.ObjectiveSense()) - @test MOI.supports_constraint(model, MOI.VectorAffineFunction{T}, MOI.Zeros) + @test MOI.supports_constraint(model, MOI.VectorAffineFunction{T}, MOI.ZeroCone) MOI.empty!(model) @test MOI.is_empty(model) x = MOI.add_variables(model, 1) @@ -2194,7 +2194,7 @@ function linear15test(model::MOI.ModelLike, config::Config{T}) where {T} MOI.VectorAffineTerm{T}.(2, MOI.ScalarAffineTerm{T}.([one(T)], x)), zeros(2), ), - MOI.Zeros(2), + MOI.ZeroCone(2), ) MOI.set( model, diff --git a/src/DeprecatedTest/intconic.jl b/src/DeprecatedTest/intconic.jl index b9ef229a08..2d6af9cbfd 100644 --- a/src/DeprecatedTest/intconic.jl +++ b/src/DeprecatedTest/intconic.jl @@ -16,7 +16,7 @@ function intsoc1test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) @test MOI.supports_constraint(model, MOI.SingleVariable, MOI.ZeroOne) @test MOI.supports_constraint( @@ -42,7 +42,7 @@ function intsoc1test(model::MOI.ModelLike, config::Config) [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Zeros(1), + MOI.ZeroCone(1), ) csoc = MOI.add_constraint( model, @@ -54,7 +54,7 @@ function intsoc1test(model::MOI.ModelLike, config::Config) model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 1 @test MOI.get( @@ -64,7 +64,7 @@ function intsoc1test(model::MOI.ModelLike, config::Config) end loc = MOI.get(model, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 2 - @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) in loc @test (MOI.VectorOfVariables, MOI.SecondOrderCone) in loc bin1 = MOI.add_constraint(model, MOI.SingleVariable(y), MOI.ZeroOne()) # We test this after the creation of every `SingleVariable` constraint diff --git a/src/DeprecatedTest/modellike.jl b/src/DeprecatedTest/modellike.jl index f7da14cb7b..8bc069d645 100644 --- a/src/DeprecatedTest/modellike.jl +++ b/src/DeprecatedTest/modellike.jl @@ -357,7 +357,7 @@ function emptytest(model::MOI.ModelLike) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) c = MOI.add_constraint( model, @@ -368,7 +368,7 @@ function emptytest(model::MOI.ModelLike) ), [-3.0, -2.0], ), - MOI.Zeros(2), + MOI.ZeroCone(2), ) MOI.set( model, @@ -389,7 +389,7 @@ function emptytest(model::MOI.ModelLike) ) == 0 @test MOI.get( model, - MOI.NumberOfConstraints{MOI.VectorAffineFunction{Float64},MOI.Zeros}(), + MOI.NumberOfConstraints{MOI.VectorAffineFunction{Float64},MOI.ZeroCone}(), ) == 0 @test isempty(MOI.get(model, MOI.ListOfConstraintTypesPresent())) @test !MOI.is_valid(model, v[1]) @@ -731,7 +731,7 @@ function copytest(dest::MOI.ModelLike, src::MOI.ModelLike; copy_names = false) ), [-3.0, -2.0], ), - MOI.Zeros(2), + MOI.ZeroCone(2), ) MOI.set(src, MOI.ConstraintName(), cva, "cva") MOI.set( @@ -761,7 +761,7 @@ function copytest(dest::MOI.ModelLike, src::MOI.ModelLike; copy_names = false) @test MOI.supports_constraint( dest, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) dict = MOI.copy_to(dest, src, copy_names = copy_names) dest_name(src_name) = copy_names ? src_name : "" @@ -805,13 +805,13 @@ function copytest(dest::MOI.ModelLike, src::MOI.ModelLike; copy_names = false) ) == [dict[csa]] @test MOI.get( dest, - MOI.NumberOfConstraints{MOI.VectorAffineFunction{Float64},MOI.Zeros}(), + MOI.NumberOfConstraints{MOI.VectorAffineFunction{Float64},MOI.ZeroCone}(), ) == 1 @test MOI.get( dest, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == [dict[cva]] loc = MOI.get(dest, MOI.ListOfConstraintTypesPresent()) @@ -819,7 +819,7 @@ function copytest(dest::MOI.ModelLike, src::MOI.ModelLike; copy_names = false) @test (MOI.SingleVariable, MOI.EqualTo{Float64}) in loc @test (MOI.VectorOfVariables, MOI.NonnegativeCone) in loc @test (MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64}) in loc - @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) in loc @test MOI.get(dest, MOI.ConstraintFunction(), dict[csv]) == MOI.SingleVariable(dict[w]) @test MOI.get(dest, MOI.ConstraintSet(), dict[csv]) == MOI.EqualTo(2.0) @@ -846,7 +846,7 @@ function copytest(dest::MOI.ModelLike, src::MOI.ModelLike; copy_names = false) ), [-3.0, -2.0], ) - @test MOI.get(dest, MOI.ConstraintSet(), dict[cva]) == MOI.Zeros(2) + @test MOI.get(dest, MOI.ConstraintSet(), dict[cva]) == MOI.ZeroCone(2) @test MOI.get( dest, MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}(), @@ -886,13 +886,13 @@ function supports_constrainttest( MOI.EqualTo{BadT}, ) @test !MOI.supports_constraint(model, MOI.SingleVariable, MOI.EqualTo{BadT}) - @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.Zeros) + @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.ZeroCone) @test !MOI.supports_constraint( model, MOI.VectorOfVariables, MOI.EqualTo{GoodT}, ) # vector in scalar - @test !MOI.supports_constraint(model, MOI.SingleVariable, MOI.Zeros) # scalar in vector + @test !MOI.supports_constraint(model, MOI.SingleVariable, MOI.ZeroCone) # scalar in vector @test !MOI.supports_constraint( model, MOI.VectorOfVariables, diff --git a/src/FileFormats/CBF/CBF.jl b/src/FileFormats/CBF/CBF.jl index 996f847f81..d8d70b5aec 100644 --- a/src/FileFormats/CBF/CBF.jl +++ b/src/FileFormats/CBF/CBF.jl @@ -11,7 +11,7 @@ MOI.Utilities.@model( (), ( MOI.Reals, - MOI.Zeros, + MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.SecondOrderCone, diff --git a/src/FileFormats/CBF/read.jl b/src/FileFormats/CBF/read.jl index a6fef35466..5d09142e34 100644 --- a/src/FileFormats/CBF/read.jl +++ b/src/FileFormats/CBF/read.jl @@ -61,7 +61,7 @@ function _cbf_to_moi_cone( if cone_str == "F" return MOI.Reals(cone_dim) elseif cone_str == "L=" - return MOI.Zeros(cone_dim) + return MOI.ZeroCone(cone_dim) elseif cone_str == "L-" return MOI.NonpositiveCone(cone_dim) elseif cone_str == "L+" diff --git a/src/FileFormats/CBF/write.jl b/src/FileFormats/CBF/write.jl index 05f43f9a17..dfc8012ea8 100644 --- a/src/FileFormats/CBF/write.jl +++ b/src/FileFormats/CBF/write.jl @@ -28,7 +28,7 @@ mutable struct _CBFDataStructure end end -_cone_string(::Any, ::Type{MOI.Zeros}) = "L=" +_cone_string(::Any, ::Type{MOI.ZeroCone}) = "L=" _cone_string(::Any, ::Type{MOI.Reals}) = "F" _cone_string(::Any, ::Type{MOI.NonnegativeCone}) = "L+" _cone_string(::Any, ::Type{MOI.NonpositiveCone}) = "L-" @@ -180,7 +180,7 @@ end function _CBFDataStructure(model::Model) data = _CBFDataStructure() for S in ( - MOI.Zeros, + MOI.ZeroCone, MOI.Reals, MOI.NonnegativeCone, MOI.NonpositiveCone, diff --git a/src/FileFormats/MOF/MOF.jl b/src/FileFormats/MOF/MOF.jl index e81d606893..bbffc0f724 100644 --- a/src/FileFormats/MOF/MOF.jl +++ b/src/FileFormats/MOF/MOF.jl @@ -37,7 +37,7 @@ MOI.Utilities.@model( ), ( MOI.Reals, - MOI.Zeros, + MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.SecondOrderCone, diff --git a/src/FileFormats/MOF/mof.0.6.schema.json b/src/FileFormats/MOF/mof.0.6.schema.json index 0f4a184e42..ef292838b8 100644 --- a/src/FileFormats/MOF/mof.0.6.schema.json +++ b/src/FileFormats/MOF/mof.0.6.schema.json @@ -615,11 +615,11 @@ } }, { "description": "{0}^{dimension}", - "examples": ["{\"type\": \"Zeros\", \"dimension\": 3}"], + "examples": ["{\"type\": \"ZeroCone\", \"dimension\": 3}"], "required": ["dimension"], "properties": { "type": { - "const": "Zeros" + "const": "ZeroCone" }, "dimension": { "type": "integer", diff --git a/src/FileFormats/MOF/read.jl b/src/FileFormats/MOF/read.jl index e7078490ff..6bf39a9f79 100644 --- a/src/FileFormats/MOF/read.jl +++ b/src/FileFormats/MOF/read.jl @@ -287,7 +287,7 @@ end Interval, Semiinteger, Semicontinuous, - Zeros, + ZeroCone, Reals, NonnegativeCone, NonpositiveCone, @@ -367,8 +367,8 @@ end # ========== Non-typed vector sets ========== -function set_to_moi(::Val{:Zeros}, object::Object) - return MOI.Zeros(object["dimension"]) +function set_to_moi(::Val{:ZeroCone}, object::Object) + return MOI.ZeroCone(object["dimension"]) end function set_to_moi(::Val{:Reals}, object::Object) diff --git a/src/FileFormats/MOF/write.jl b/src/FileFormats/MOF/write.jl index f18e6138ea..762ec5cb7b 100644 --- a/src/FileFormats/MOF/write.jl +++ b/src/FileFormats/MOF/write.jl @@ -262,7 +262,7 @@ head_name(::Type{<:MOI.Semiinteger}) = "Semiinteger" head_name(::Type{<:MOI.Semicontinuous}) = "Semicontinuous" # ========== Non-typed vector sets ========== -head_name(::Type{MOI.Zeros}) = "Zeros" +head_name(::Type{MOI.ZeroCone}) = "ZeroCone" head_name(::Type{MOI.Reals}) = "Reals" head_name(::Type{MOI.NonnegativeCone}) = "NonnegativeCone" head_name(::Type{MOI.NonpositiveCone}) = "NonpositiveCone" diff --git a/src/Test/test_basic_constraint.jl b/src/Test/test_basic_constraint.jl index 30bf1d8173..2b94574a2f 100644 --- a/src/Test/test_basic_constraint.jl +++ b/src/Test/test_basic_constraint.jl @@ -77,7 +77,7 @@ function _set(::Type{T}, ::Type{MOI.Semiinteger}) where {T} end _set(::Type{T}, ::Type{MOI.SOS1}) where {T} = MOI.SOS1(convert.(T, 1:2)) _set(::Type{T}, ::Type{MOI.SOS2}) where {T} = MOI.SOS2(convert.(T, 1:2)) -_set(::Type{MOI.Zeros}) = MOI.Zeros(2) +_set(::Type{MOI.ZeroCone}) = MOI.ZeroCone(2) _set(::Type{MOI.NonpositiveCone}) = MOI.NonpositiveCone(2) _set(::Type{MOI.NonnegativeCone}) = MOI.NonnegativeCone(2) _set(::Type{MOI.NormInfinityCone}) = MOI.NormInfinityCone(3) @@ -223,7 +223,7 @@ for s in [ :Semiinteger, :SOS1, :SOS2, - :Zeros, + :ZeroCone, :NonpositiveCone, :NonnegativeCone, :NormInfinityCone, diff --git a/src/Test/test_conic.jl b/src/Test/test_conic.jl index 0f723b8fbc..8cfaf70ead 100644 --- a/src/Test/test_conic.jl +++ b/src/Test/test_conic.jl @@ -45,7 +45,7 @@ function _test_conic_linear_helper( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) v = MOI.add_variables(model, 3) @test MOI.get(model, MOI.NumberOfVariables()) == 3 @@ -68,7 +68,7 @@ function _test_conic_linear_helper( ), [-3.0, -2.0], ), - MOI.Zeros(2), + MOI.ZeroCone(2), ) if _supports(config, MOI.NumberOfConstraints) @test MOI.get( @@ -83,7 +83,7 @@ function _test_conic_linear_helper( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 1 end @@ -94,7 +94,7 @@ function _test_conic_linear_helper( MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone, ) in loc - @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) in loc MOI.set( model, MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}(), @@ -156,7 +156,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1.0, 0.0, 2.0], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-3, -1]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-3, -1]], ), ) return @@ -187,7 +187,7 @@ function setup_test( [1.0, 0.0, 2.0], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0, 2, 0]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-3, -1]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-3, -1]], ), ) return @@ -242,7 +242,7 @@ function _test_conic_linear_helper_2( @requires MOI.supports_constraint( model, MOI.VectorOfVariables, - MOI.Zeros, + MOI.ZeroCone, ) else @requires MOI.supports_constraint( @@ -259,7 +259,7 @@ function _test_conic_linear_helper_2( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) x = MOI.add_variable(model) @test MOI.get(model, MOI.NumberOfVariables()) == 1 @@ -295,7 +295,7 @@ function _test_conic_linear_helper_2( ), [4.0, 3.0, -12.0], ), - MOI.Zeros(3), + MOI.ZeroCone(3), ) if use_VectorOfVariables # test fallback @@ -312,12 +312,12 @@ function _test_conic_linear_helper_2( end vov = MOI.VectorOfVariables([s]) if use_VectorOfVariables - vs = MOI.add_constraint(model, vov, MOI.Zeros(1)) + vs = MOI.add_constraint(model, vov, MOI.ZeroCone(1)) else vs = MOI.add_constraint( model, MOI.VectorAffineFunction{Float64}(vov), - MOI.Zeros(1), + MOI.ZeroCone(1), ) end if _supports(config, MOI.NumberOfConstraints) @@ -325,7 +325,7 @@ function _test_conic_linear_helper_2( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 2 - use_VectorOfVariables @test MOI.get( @@ -414,7 +414,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [-4, -3, 16, 0], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[7, 2, -4]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[7, 2, -4]], ), ) return @@ -448,7 +448,7 @@ function setup_test( [-4, -3, 16, 0], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0]], (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[0]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[7, 2, -4], [7]], ), ) @@ -657,13 +657,13 @@ function _test_conic_NormInfinityCone_helper( @requires MOI.supports_constraint( model, MOI.VectorOfVariables, - MOI.Zeros, + MOI.ZeroCone, ) else @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) end @requires MOI.supports_constraint( @@ -688,7 +688,7 @@ function _test_conic_NormInfinityCone_helper( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Zeros(1), + MOI.ZeroCone(1), ) ceq2 = MOI.add_constraint( model, @@ -696,7 +696,7 @@ function _test_conic_NormInfinityCone_helper( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, y))], [-0.5], ), - MOI.Zeros(1), + MOI.ZeroCone(1), ) vov = MOI.VectorOfVariables([x, y, z]) if use_VectorOfVariables @@ -713,7 +713,7 @@ function _test_conic_NormInfinityCone_helper( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 2 @test MOI.get( @@ -727,7 +727,7 @@ function _test_conic_NormInfinityCone_helper( end loc = MOI.get(model, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 2 - @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) in loc @test ( use_VectorOfVariables ? MOI.VectorOfVariables : MOI.VectorAffineFunction{Float64}, @@ -796,7 +796,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 0.5, 1], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-1], [-1]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-1], [-1]], (MOI.VectorOfVariables, MOI.NormInfinityCone) => [[1, 0, -1]], ), ) @@ -829,7 +829,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 0.5, 1], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-1], [-1]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-1], [-1]], (MOI.VectorAffineFunction{Float64}, MOI.NormInfinityCone) => [[1, 0, -1]], ), @@ -1087,13 +1087,13 @@ function _test_conic_NormOneCone_helper( @requires MOI.supports_constraint( model, MOI.VectorOfVariables, - MOI.Zeros, + MOI.ZeroCone, ) else @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) end @requires MOI.supports_constraint( @@ -1118,7 +1118,7 @@ function _test_conic_NormOneCone_helper( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Zeros(1), + MOI.ZeroCone(1), ) ceq2 = MOI.add_constraint( model, @@ -1126,7 +1126,7 @@ function _test_conic_NormOneCone_helper( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, y))], [-0.5], ), - MOI.Zeros(1), + MOI.ZeroCone(1), ) vov = MOI.VectorOfVariables([x, y, z]) if use_VectorOfVariables @@ -1143,7 +1143,7 @@ function _test_conic_NormOneCone_helper( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 2 @test MOI.get( @@ -1157,7 +1157,7 @@ function _test_conic_NormOneCone_helper( end loc = MOI.get(model, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 2 - @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) in loc @test ( use_VectorOfVariables ? MOI.VectorOfVariables : MOI.VectorAffineFunction{Float64}, @@ -1225,7 +1225,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 0.5, 0.5], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-1], [0]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-1], [0]], (MOI.VectorOfVariables, MOI.NormOneCone) => [[1, -1, -1]], ), ) @@ -1257,7 +1257,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 0.5, 0.5], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-1], [0]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-1], [0]], (MOI.VectorAffineFunction{Float64}, MOI.NormOneCone) => [[1, -1, -1]], ), @@ -1532,7 +1532,7 @@ function _test_conic_SecondOrderCone_helper( MOI.SecondOrderCone, ) end - @requires MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.Zeros) + @requires MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.ZeroCone) if use_VectorOfVariables xyz, csoc = MOI.add_constrained_variables(model, MOI.SecondOrderCone(3)) @@ -1561,14 +1561,14 @@ function _test_conic_SecondOrderCone_helper( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Zeros(1), + MOI.ZeroCone(1), ) if _supports(config, MOI.NumberOfConstraints) @test MOI.get( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 1 @test MOI.get( @@ -1582,7 +1582,7 @@ function _test_conic_SecondOrderCone_helper( end loc = MOI.get(model, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 2 - @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) in loc @test ( use_VectorOfVariables ? MOI.VectorOfVariables : MOI.VectorAffineFunction{Float64}, @@ -1646,7 +1646,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1.0, 1 / √2, 1 / √2], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-√2]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-√2]], ), ) return @@ -1680,7 +1680,7 @@ function setup_test( [1.0, 1 / √2, 1 / √2], (MOI.VectorAffineFunction{Float64}, MOI.SecondOrderCone) => [[√2, -1, -1]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-√2]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-√2]], ), ) return @@ -1716,7 +1716,7 @@ function _test_conic_SecondOrderCone_helper_2( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) if nonneg @requires MOI.supports_constraint( @@ -1769,7 +1769,7 @@ function _test_conic_SecondOrderCone_helper_2( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(-1.0, t))], [1.0], ), - MOI.Zeros(1), + MOI.ZeroCone(1), ) csoc = MOI.add_constraint( model, @@ -1794,7 +1794,7 @@ function _test_conic_SecondOrderCone_helper_2( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 1 @test MOI.get( @@ -1871,7 +1871,7 @@ function setup_test( [-1 / √2, 1 / √2, 1.0], (MOI.VectorAffineFunction{Float64}, MOI.SecondOrderCone) => [[√2, 1, -1]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[√2]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[√2]], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1.0]], ), @@ -1907,7 +1907,7 @@ function setup_test( [-1 / √2, 1 / √2, 1.0], (MOI.VectorAffineFunction{Float64}, MOI.SecondOrderCone) => [[√2, 1, -1]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[√2]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[√2]], (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[-1.0]], ), @@ -2077,7 +2077,7 @@ function test_conic_SecondOrderCone_out_of_order( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) @requires MOI.supports_constraint( model, @@ -2095,7 +2095,7 @@ function test_conic_SecondOrderCone_out_of_order( ), [-1.0, 0.0, 0.0], ), - MOI.Zeros(3), + MOI.ZeroCone(3), ) c2 = MOI.add_constraint( model, @@ -2107,7 +2107,7 @@ function test_conic_SecondOrderCone_out_of_order( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 1 @test MOI.get( @@ -2163,7 +2163,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1.0, 2 / √5, 1 / √5, 2 / √5, 1 / √5], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-√5, -2.0, -1.0]], ), ) diff --git a/src/Test/test_linear.jl b/src/Test/test_linear.jl index cded24b049..c6cfb188b5 100644 --- a/src/Test/test_linear.jl +++ b/src/Test/test_linear.jl @@ -2739,7 +2739,7 @@ end This test checks solving a problem given a `VectorAffineFunction` with an empty row equivalent to `0 == 0`. -Models not supporting `VectorAffineFunction`-in-`Zeros` should use a bridge. +Models not supporting `VectorAffineFunction`-in-`ZeroCone` should use a bridge. """ function test_linear_VectorAffineFunction_empty_row( model::MOI.ModelLike, @@ -2756,7 +2756,7 @@ function test_linear_VectorAffineFunction_empty_row( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{T}, - MOI.Zeros, + MOI.ZeroCone, ) x = MOI.add_variables(model, 1) # Create a VectorAffineFunction with two rows, but only one term, belonging @@ -2768,7 +2768,7 @@ function test_linear_VectorAffineFunction_empty_row( MOI.VectorAffineTerm{T}.(2, MOI.ScalarAffineTerm{T}.([one(T)], x)), zeros(2), ), - MOI.Zeros(2), + MOI.ZeroCone(2), ) MOI.set( model, @@ -2807,7 +2807,7 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [0.0], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[0.0, 0.0]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[0.0, 0.0]], ), ) return diff --git a/src/Test/test_model.jl b/src/Test/test_model.jl index e7cdaf074e..d20c77088f 100644 --- a/src/Test/test_model.jl +++ b/src/Test/test_model.jl @@ -649,7 +649,7 @@ function test_model_supports_constraint_SingleVariable_EqualTo( MOI.EqualTo{UInt8}, ) # Scalar-in-vector - @test !MOI.supports_constraint(model, MOI.SingleVariable, MOI.Zeros) + @test !MOI.supports_constraint(model, MOI.SingleVariable, MOI.ZeroCone) return end diff --git a/src/Test/test_quadratic.jl b/src/Test/test_quadratic.jl index d4074a885c..d0c478be22 100644 --- a/src/Test/test_quadratic.jl +++ b/src/Test/test_quadratic.jl @@ -1276,7 +1276,7 @@ function test_quadratic_Integer_SecondOrderCone( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, ) @requires MOI.supports_constraint(model, MOI.SingleVariable, MOI.ZeroOne) @requires MOI.supports_constraint( @@ -1300,7 +1300,7 @@ function test_quadratic_Integer_SecondOrderCone( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1.0, x))], [-1.0], ), - MOI.Zeros(1), + MOI.ZeroCone(1), ) MOI.add_constraint( model, @@ -1312,7 +1312,7 @@ function test_quadratic_Integer_SecondOrderCone( model, MOI.NumberOfConstraints{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) == 1 @test MOI.get( @@ -1322,7 +1322,7 @@ function test_quadratic_Integer_SecondOrderCone( end loc = MOI.get(model, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 2 - @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) in loc @test (MOI.VectorOfVariables, MOI.SecondOrderCone) in loc bin1 = MOI.add_constraint(model, MOI.SingleVariable(y), MOI.ZeroOne()) # We test this after the creation of every `SingleVariable` constraint diff --git a/src/Utilities/model.jl b/src/Utilities/model.jl index 120c4f126e..ec19b327f4 100644 --- a/src/Utilities/model.jl +++ b/src/Utilities/model.jl @@ -833,7 +833,7 @@ The model describing an linear program would be: @model(LPModel, # Name of model (), # untyped scalar sets (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan, MOI.Interval), # typed scalar sets - (MOI.Zeros, MOI.NonnegativeCone, MOI.NonpositiveCone), # untyped vector sets + (MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone), # untyped vector sets (), # typed vector sets (), # untyped scalar functions (MOI.ScalarAffineFunction,), # typed scalar functions @@ -868,13 +868,13 @@ struct LPModelFunctionConstraints{T} <: MOIU.StructOfConstraints } moi_vectorofvariables::LPModelVectorConstraints{ T, - MOIU.VectorOfConstraints{MOI.VectorOfVariables, MOI.Zeros}, + MOIU.VectorOfConstraints{MOI.VectorOfVariables, MOI.ZeroCone}, MOIU.VectorOfConstraints{MOI.VectorOfVariables, MOI.NonnegativeCone}, MOIU.VectorOfConstraints{MOI.VectorOfVariables, MOI.NonpositiveCone} } moi_vectoraffinefunction::LPModelVectorConstraints{ T, - MOIU.VectorOfConstraints{MOI.VectorAffineFunction{T}, MOI.Zeros}, + MOIU.VectorOfConstraints{MOI.VectorAffineFunction{T}, MOI.ZeroCone}, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{T}, MOI.NonnegativeCone}, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{T}, MOI.NonpositiveCone} } @@ -1049,7 +1049,7 @@ const LessThanIndicatorSetZero{T} = ), ( MOI.Reals, - MOI.Zeros, + MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.Complements, diff --git a/src/Utilities/precompile.jl b/src/Utilities/precompile.jl index 5020888e02..6737a01040 100644 --- a/src/Utilities/precompile.jl +++ b/src/Utilities/precompile.jl @@ -19,7 +19,7 @@ function _precompile_() vector_sets = ( MOI.NonnegativeCone, MOI.NonpositiveCone, - MOI.Zeros, + MOI.ZeroCone, MOI.Reals, MOI.SecondOrderCone, MOI.RotatedSecondOrderCone, diff --git a/src/Utilities/product_of_sets.jl b/src/Utilities/product_of_sets.jl index dfe605da00..7ca3a63bb5 100644 --- a/src/Utilities/product_of_sets.jl +++ b/src/Utilities/product_of_sets.jl @@ -147,7 +147,7 @@ Generate a new [`OrderedProductOfSets`](@ref) subtype. ```julia @product_of_sets( LinearOrthants, - MOI.Zeros, + MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.ZeroOne, diff --git a/src/Utilities/sets.jl b/src/Utilities/sets.jl index 705e42f573..b876fe8498 100644 --- a/src/Utilities/sets.jl +++ b/src/Utilities/sets.jl @@ -72,7 +72,7 @@ This is used in the vectorize and scalarize bridges. See also: [`ScalarLinearSet`](@ref). """ -const VectorLinearSet = Union{MOI.Zeros,MOI.NonnegativeCone,MOI.NonpositiveCone} +const VectorLinearSet = Union{MOI.ZeroCone,MOI.NonnegativeCone,MOI.NonpositiveCone} """ vector_set_type(::Type{S}) where {S} @@ -83,7 +83,7 @@ This is used in the vectorize and scalarize bridges. See also: [`scalar_set_type`](@ref). """ -vector_set_type(::Type{<:MOI.EqualTo}) = MOI.Zeros +vector_set_type(::Type{<:MOI.EqualTo}) = MOI.ZeroCone vector_set_type(::Type{<:MOI.LessThan}) = MOI.NonpositiveCone vector_set_type(::Type{<:MOI.GreaterThan}) = MOI.NonnegativeCone @@ -97,7 +97,7 @@ This is used in the vectorize and scalarize bridges. See also: [`vector_set_type`](@ref). """ -scalar_set_type(::Type{<:MOI.Zeros}, T::Type) = MOI.EqualTo{T} +scalar_set_type(::Type{<:MOI.ZeroCone}, T::Type) = MOI.EqualTo{T} scalar_set_type(::Type{<:MOI.NonpositiveCone}, T::Type) = MOI.LessThan{T} scalar_set_type(::Type{<:MOI.NonnegativeCone}, T::Type) = MOI.GreaterThan{T} diff --git a/src/sets.jl b/src/sets.jl index e0901ccf0c..c67f98e449 100644 --- a/src/sets.jl +++ b/src/sets.jl @@ -47,7 +47,7 @@ If the dual cone is not defined it returns an error. ```jldocstest julia> dual_set(Reals(4)) -Zeros(4) +ZeroCone(4) julia> dual_set(SecondOrderCone(5)) SecondOrderCone(5) @@ -70,7 +70,7 @@ Return the type of dual set of sets of type `S`, as returned by ```jldocstest julia> dual_set_type(Reals) -Zeros +ZeroCone julia> dual_set_type(SecondOrderCone) SecondOrderCone @@ -125,22 +125,22 @@ struct Reals <: AbstractVectorSet end end -dual_set(s::Reals) = Zeros(dimension(s)) -dual_set_type(::Type{Reals}) = Zeros +dual_set(s::Reals) = ZeroCone(dimension(s)) +dual_set_type(::Type{Reals}) = ZeroCone """ - Zeros(dimension) + ZeroCone(dimension) The set ``\\{ 0 \\}^{dimension}`` (containing only the origin) of dimension `dimension`. """ -struct Zeros <: AbstractVectorSet +struct ZeroCone <: AbstractVectorSet dimension::Int - function Zeros(dimension::Base.Integer) + function ZeroCone(dimension::Base.Integer) if !(dimension >= 0) throw( DimensionMismatch( - "Dimension of Zeros must be >= 0, not $(dimension).", + "Dimension of ZeroCone must be >= 0, not $(dimension).", ), ) end @@ -148,8 +148,8 @@ struct Zeros <: AbstractVectorSet end end -dual_set(s::Zeros) = Reals(dimension(s)) -dual_set_type(::Type{Zeros}) = Reals +dual_set(s::ZeroCone) = Reals(dimension(s)) +dual_set_type(::Type{ZeroCone}) = Reals """ NonnegativeCone(dimension) @@ -1113,7 +1113,7 @@ end function Base.copy( set::Union{ Reals, - Zeros, + ZeroCone, NonnegativeCone, NonpositiveCone, GreaterThan, @@ -1166,7 +1166,7 @@ function supports_dimension_update(::Type{<:AbstractVectorSet}) return false end function supports_dimension_update( - ::Type{<:Union{Reals,Zeros,NonnegativeCone,NonpositiveCone}}, + ::Type{<:Union{Reals,ZeroCone,NonnegativeCone,NonpositiveCone}}, ) return true end @@ -1178,7 +1178,7 @@ Returns a set with the dimension modified to `new_dim`. """ function update_dimension end function update_dimension( - set::Union{Reals,Zeros,NonnegativeCone,NonpositiveCone}, + set::Union{Reals,ZeroCone,NonnegativeCone,NonpositiveCone}, new_dim, ) return typeof(set)(new_dim) diff --git a/test/Bridges/Constraint/flip_sign.jl b/test/Bridges/Constraint/flip_sign.jl index 3ae0c7bab8..87b620af63 100644 --- a/test/Bridges/Constraint/flip_sign.jl +++ b/test/Bridges/Constraint/flip_sign.jl @@ -192,7 +192,7 @@ end [1.0, 0.0, 2.0], (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[0.0, -2.0, 0.0]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-3.0, -1.0]], ) MOIT.lin1vtest(bridged_mock, config) diff --git a/test/Bridges/Constraint/functionize.jl b/test/Bridges/Constraint/functionize.jl index e6f1d7e59b..75ae9c34e4 100644 --- a/test/Bridges/Constraint/functionize.jl +++ b/test/Bridges/Constraint/functionize.jl @@ -163,7 +163,7 @@ end [1.0, 0.0, 2.0], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0, 2, 0]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-3, -1]], ) MOIT.lin1vtest(bridged_mock, config) diff --git a/test/Bridges/Constraint/interval.jl b/test/Bridges/Constraint/interval.jl index 20117eb5b6..2bc7c0df7c 100644 --- a/test/Bridges/Constraint/interval.jl +++ b/test/Bridges/Constraint/interval.jl @@ -25,9 +25,9 @@ config_with_basis = MOIT.Config(basis = true) (MOI.SingleVariable, MOI.EqualTo{T}), (MOI.ScalarAffineFunction{T}, MOI.EqualTo{T}), (MOI.ScalarQuadraticFunction{T}, MOI.EqualTo{T}), - (MOI.VectorOfVariables, MOI.Zeros), - (MOI.VectorAffineFunction{T}, MOI.Zeros), - (MOI.VectorQuadraticFunction{T}, MOI.Zeros), + (MOI.VectorOfVariables, MOI.ZeroCone), + (MOI.VectorAffineFunction{T}, MOI.ZeroCone), + (MOI.VectorQuadraticFunction{T}, MOI.ZeroCone), ], ) end @@ -198,7 +198,7 @@ end ), ) end -@testset "Zeros" begin +@testset "ZeroCone" begin bridged_mock = MOIB.Constraint.SplitInterval{Float64}(mock) mock.optimize! = (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( @@ -216,7 +216,7 @@ end bridged_mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ), ) diff --git a/test/Bridges/Constraint/norm_to_lp.jl b/test/Bridges/Constraint/norm_to_lp.jl index d2a64e9ca0..53bf21f0e6 100644 --- a/test/Bridges/Constraint/norm_to_lp.jl +++ b/test/Bridges/Constraint/norm_to_lp.jl @@ -33,7 +33,7 @@ config = MOIT.Config() [1.0, 0.5, 1.0], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0.0, 1.0, 0.0, 0.0]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-1], [-1]], ) @@ -62,7 +62,7 @@ config = MOIT.Config() mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) @test length(zeros) == 2 @@ -72,8 +72,8 @@ config = MOIT.Config() s = """ variables: x, y, z nonneg: [x + -1.0y, x + -1.0z, x + y, x + z] in MathOptInterface.NonnegativeCone(4) - x_eq: [-1.0 + x] in MathOptInterface.Zeros(1) - y_eq: [-0.5 + y] in MathOptInterface.Zeros(1) + x_eq: [-1.0 + x] in MathOptInterface.ZeroCone(1) + y_eq: [-0.5 + y] in MathOptInterface.ZeroCone(1) maxobjective: y + z """ model = MOIU.Model{Float64}() @@ -106,7 +106,7 @@ config = MOIT.Config() bridged_mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) @test length(zeros) == 2 @@ -116,8 +116,8 @@ config = MOIT.Config() s = """ variables: x, y, z norminf: [1.0x, y, z] in MathOptInterface.NormInfinityCone(3) - x_eq: [-1.0 + x] in MathOptInterface.Zeros(1) - y_eq: [-0.5 + y] in MathOptInterface.Zeros(1) + x_eq: [-1.0 + x] in MathOptInterface.ZeroCone(1) + y_eq: [-0.5 + y] in MathOptInterface.ZeroCone(1) maxobjective: y + z """ model = MOIU.Model{Float64}() @@ -323,7 +323,7 @@ end [1.0, 0.5, 0.5, 0.5, 0.5], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1.0, 1.0, 1.0, 0.0, 0.0]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-1], [0]], ) @@ -355,7 +355,7 @@ end mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) @test length(zeros) == 2 @@ -365,8 +365,8 @@ end s = """ variables: x, y, z, u, v nonneg: [x + -1.0u + -1.0v, u + -1.0y, v + -1.0z, u + y, v + z] in MathOptInterface.NonnegativeCone(5) - x_eq: [-1.0 + x] in MathOptInterface.Zeros(1) - y_eq: [-0.5 + y] in MathOptInterface.Zeros(1) + x_eq: [-1.0 + x] in MathOptInterface.ZeroCone(1) + y_eq: [-0.5 + y] in MathOptInterface.ZeroCone(1) maxobjective: y + z """ model = MOIU.Model{Float64}() @@ -393,7 +393,7 @@ end bridged_mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) @test length(zeros) == 2 @@ -403,8 +403,8 @@ end s = """ variables: x, y, z normone: [1.0x, y, z] in MathOptInterface.NormOneCone(3) - x_eq: [-1.0 + x] in MathOptInterface.Zeros(1) - y_eq: [-0.5 + y] in MathOptInterface.Zeros(1) + x_eq: [-1.0 + x] in MathOptInterface.ZeroCone(1) + y_eq: [-0.5 + y] in MathOptInterface.ZeroCone(1) maxobjective: y + z """ model = MOIU.Model{Float64}() diff --git a/test/Bridges/Constraint/rsoc.jl b/test/Bridges/Constraint/rsoc.jl index 56398f3474..9c1b01a165 100644 --- a/test/Bridges/Constraint/rsoc.jl +++ b/test/Bridges/Constraint/rsoc.jl @@ -91,7 +91,7 @@ end mock, [1.0, 1 / √2, 1 / √2], (MOI.VectorAffineFunction{Float64}, MOI.RotatedSecondOrderCone) => [[1 - 1 / √2, 1 + 1 / √2, -1]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-√2]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-√2]], ) MOIT.soc1vtest(bridged_mock, config) mock.optimize! = @@ -99,7 +99,7 @@ end mock, [1.0, 1 / √2, 1 / √2], (MOI.VectorAffineFunction{Float64}, MOI.RotatedSecondOrderCone) => [[1 - 1 / √2, 1 + 1 / √2, -1]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-√2]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-√2]], ) MOIT.soc1ftest(bridged_mock, config) ci = first( diff --git a/test/Bridges/Constraint/scalarize.jl b/test/Bridges/Constraint/scalarize.jl index 20623eea62..5cfe343ee8 100644 --- a/test/Bridges/Constraint/scalarize.jl +++ b/test/Bridges/Constraint/scalarize.jl @@ -22,12 +22,12 @@ config = MOIT.Config() MOI.VectorOfVariables, MOI.VectorAffineFunction{Float64}, MOI.VectorQuadraticFunction{Float64}, - ] for S in [MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.Zeros] + ] for S in [MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.ZeroCone] ], ) # VectorOfVariables-in-NonnegativeCone - # VectorAffineFunction-in-Zeros + # VectorAffineFunction-in-ZeroCone mock.optimize! = (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, @@ -41,7 +41,7 @@ config = MOIT.Config() bridged_mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ), ) @@ -90,7 +90,7 @@ config = MOIT.Config() ) # VectorAffineFunction-in-NonnegativeCone - # VectorAffineFunction-in-Zeros + # VectorAffineFunction-in-ZeroCone mock.optimize! = (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, @@ -107,7 +107,7 @@ config = MOIT.Config() bridged_mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ), ) @@ -172,8 +172,8 @@ config = MOIT.Config() # VectorOfVariables-in-NonnegativeCone # VectorOfVariables-in-NonpositiveCone - # VectorOfVariables-in-Zeros - # VectorAffineFunction-in-Zeros + # VectorOfVariables-in-ZeroCone + # VectorAffineFunction-in-ZeroCone mock.optimize! = (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, @@ -185,7 +185,7 @@ config = MOIT.Config() # VectorAffineFunction-in-NonnegativeCone # VectorAffineFunction-in-NonpositiveCone - # VectorAffineFunction-in-Zeros + # VectorAffineFunction-in-ZeroCone mock.optimize! = (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, diff --git a/test/Bridges/Constraint/slack.jl b/test/Bridges/Constraint/slack.jl index 59cf79e035..663a9ec575 100644 --- a/test/Bridges/Constraint/slack.jl +++ b/test/Bridges/Constraint/slack.jl @@ -211,7 +211,7 @@ end 2, ( (MOI.VectorOfVariables, MOI.NonpositiveCone, 0), - (MOI.VectorAffineFunction{Float64}, MOI.Zeros, 0), + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone, 0), ), ) @@ -247,7 +247,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [100, -100, 100, -100], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[1.0], [1.0]], (MOI.VectorOfVariables, MOI.NonnegativeCone) => [[1.0]], (MOI.VectorOfVariables, MOI.NonpositiveCone) => [[1.0]], @@ -282,7 +282,7 @@ end @test (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) in loc loc = MOI.get(mock, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 3 - @test (MOI.VectorAffineFunction{Float64}, MOI.Zeros) in loc + @test (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) in loc @test (MOI.VectorOfVariables, MOI.NonnegativeCone) in loc @test (MOI.VectorOfVariables, MOI.NonpositiveCone) in loc @@ -290,7 +290,7 @@ end for F in [MOI.VectorAffineFunction{T}, MOI.VectorQuadraticFunction{T}] @test MOIB.added_constraint_types( MOIB.Constraint.VectorSlackBridge{T,F,S}, - ) == [(F, MOI.Zeros)] + ) == [(F, MOI.ZeroCone)] end end end diff --git a/test/Bridges/Constraint/soc_to_psd.jl b/test/Bridges/Constraint/soc_to_psd.jl index e1fb2f919e..bb7b7951ed 100644 --- a/test/Bridges/Constraint/soc_to_psd.jl +++ b/test/Bridges/Constraint/soc_to_psd.jl @@ -34,7 +34,7 @@ config = MOIT.Config() MOI.VectorAffineFunction{Float64}, MOI.PositiveSemidefiniteConeTriangle, ) => [[√2 / 2, -1 / 2, √2 / 4, -1 / 2, √2 / 4, √2 / 4]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-√2]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-√2]], ) MOIT.soc1vtest(bridged_mock, config) MOIT.soc1ftest(bridged_mock, config) diff --git a/test/Bridges/Constraint/vectorize.jl b/test/Bridges/Constraint/vectorize.jl index 2ef8e20e24..aecbe28244 100644 --- a/test/Bridges/Constraint/vectorize.jl +++ b/test/Bridges/Constraint/vectorize.jl @@ -97,7 +97,7 @@ config = MOIT.Config() (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, ones(3), - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[2]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[2]], ) MOIT.psdt0vtest(bridged_mock, config) @@ -124,6 +124,6 @@ config = MOIT.Config() bridged_mock, ci, 3, - ((MOI.VectorAffineFunction{Float64}, MOI.Zeros, 0),), + ((MOI.VectorAffineFunction{Float64}, MOI.ZeroCone, 0),), ) end diff --git a/test/Bridges/Variable/flip_sign.jl b/test/Bridges/Variable/flip_sign.jl index 885fd7821d..50ca8dddf1 100644 --- a/test/Bridges/Variable/flip_sign.jl +++ b/test/Bridges/Variable/flip_sign.jl @@ -19,7 +19,7 @@ config = MOIT.Config() (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [-4, 3, 16, 0], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[7, 2, -4]], ) MOIT.lin2vtest(bridged_mock, config) @@ -56,7 +56,7 @@ config = MOIT.Config() mock, MOI.ListOfConstraintIndices{ MathOptInterface.VectorOfVariables, - MathOptInterface.Zeros, + MathOptInterface.ZeroCone, }(), )[1] con_yz = MOI.get( @@ -70,7 +70,7 @@ config = MOIT.Config() mock, MOI.ListOfConstraintIndices{ MathOptInterface.VectorAffineFunction{Float64}, - MathOptInterface.Zeros, + MathOptInterface.ZeroCone, }(), )[1] @@ -97,10 +97,10 @@ config = MOIT.Config() @testset "Test Mock model" begin s = """ variables: x, y, z, w - cw: [w] in MathOptInterface.Zeros(1) + cw: [w] in MathOptInterface.ZeroCone(1) cy: [y] in MathOptInterface.NonnegativeCone(1) cz: [z] in MathOptInterface.NonnegativeCone(1) - cex: [1*x + -1*w + 4.0, -1*y + 3.0, 1*x + 1*z + -12.0] in MathOptInterface.Zeros(3) + cex: [1*x + -1*w + 4.0, -1*y + 3.0, 1*x + 1*z + -12.0] in MathOptInterface.ZeroCone(3) minobjective: 3*x + -2*y + -4*z """ model = MOIU.Model{Float64}() @@ -117,9 +117,9 @@ config = MOIT.Config() s = """ variables: x, z, w, v cv: [v] in MathOptInterface.NonpositiveCone(1) - cw: [w] in MathOptInterface.Zeros(1) + cw: [w] in MathOptInterface.ZeroCone(1) cz: [z] in MathOptInterface.NonnegativeCone(1) - cex: [1*x + -1*w + 4.0, 1*v + 3.0, 1*x + 1*z + -12.0] in MathOptInterface.Zeros(3) + cex: [1*x + -1*w + 4.0, 1*v + 3.0, 1*x + 1*z + -12.0] in MathOptInterface.ZeroCone(3) minobjective: 3*x + 2*v + -4*z """ model = MOIU.Model{Float64}() diff --git a/test/Bridges/Variable/map.jl b/test/Bridges/Variable/map.jl index e83b827dd4..d35727d361 100644 --- a/test/Bridges/Variable/map.jl +++ b/test/Bridges/Variable/map.jl @@ -50,7 +50,7 @@ cannot_unbridge_err = ErrorException( end b2 = VariableDummyBridge(2) -set2 = MOI.Zeros(4) +set2 = MOI.ZeroCone(4) F2 = MOI.VectorOfVariables S2 = typeof(set2) v2, c2 = MOIB.Variable.add_keys_for_bridge(map, () -> b2, set2) @@ -87,7 +87,7 @@ v2, c2 = MOIB.Variable.add_keys_for_bridge(map, () -> b2, set2) end b3 = VariableDummyBridge(3) -set3 = MOI.Zeros(0) +set3 = MOI.ZeroCone(0) v3, c3 = MOIB.Variable.add_keys_for_bridge(map, () -> b3, set3) @testset "Vector set of length 0" begin @test isempty(v3) diff --git a/test/Bridges/Variable/soc_to_rsoc.jl b/test/Bridges/Variable/soc_to_rsoc.jl index 248929a97e..0444235f33 100644 --- a/test/Bridges/Variable/soc_to_rsoc.jl +++ b/test/Bridges/Variable/soc_to_rsoc.jl @@ -18,7 +18,7 @@ bridged_mock = MOIB.Variable.SOCtoRSOC{Float64}(mock) (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1 / √2 + 1 / 2, 1 / √2 - 1 / 2, 1 / √2], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-√2]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-√2]], ) MOIT.soc1vtest(bridged_mock, config) @@ -26,7 +26,7 @@ bridged_mock = MOIB.Variable.SOCtoRSOC{Float64}(mock) mock, MOI.ListOfConstraintIndices{ MOI.VectorAffineFunction{Float64}, - MOI.Zeros, + MOI.ZeroCone, }(), ) @test length(ceqs) == 1 @@ -54,7 +54,7 @@ bridged_mock = MOIB.Variable.SOCtoRSOC{Float64}(mock) s = """ variables: a, b, c rsoc: [a, b, c] in MathOptInterface.RotatedSecondOrderCone(3) - ceq: [$invs2*a + $invs2*b + -1.0] in MathOptInterface.Zeros(1) + ceq: [$invs2*a + $invs2*b + -1.0] in MathOptInterface.ZeroCone(1) maxobjective: $invs2*a + -$invs2*b + c """ model = MOIU.Model{Float64}() @@ -83,7 +83,7 @@ bridged_mock = MOIB.Variable.SOCtoRSOC{Float64}(mock) s = """ variables: x, y, z soc: [x, y, z] in MathOptInterface.SecondOrderCone(3) - ceq: [x + -1.0] in MathOptInterface.Zeros(1) + ceq: [x + -1.0] in MathOptInterface.ZeroCone(1) maxobjective: y + z """ model = MOIU.Model{Float64}() diff --git a/test/Bridges/Variable/zeros.jl b/test/Bridges/Variable/zeros.jl index b6049968b2..c540d9ec13 100644 --- a/test/Bridges/Variable/zeros.jl +++ b/test/Bridges/Variable/zeros.jl @@ -11,11 +11,11 @@ include("../utilities.jl") mock = MOIU.MockOptimizer(MOIU.Model{Float64}()) config = MOIT.Config() -bridged_mock = MOIB.Variable.Zeros{Float64}(mock) +bridged_mock = MOIB.Variable.ZeroCone{Float64}(mock) x, cx = MOI.add_constrained_variable(bridged_mock, MOI.GreaterThan(0.0)) MOI.set(bridged_mock, MOI.VariableName(), x, "x") -yz, cyz = MOI.add_constrained_variables(bridged_mock, MOI.Zeros(2)) +yz, cyz = MOI.add_constrained_variables(bridged_mock, MOI.ZeroCone(2)) MOI.set(bridged_mock, MOI.VariableName(), yz, ["y", "z"]) MOI.set(bridged_mock, MOI.ConstraintName(), cyz, "cyz") y, z = yz @@ -35,7 +35,7 @@ end s = """ variables: x, y, z x >= 0.0 - cyz: [y, z] in MathOptInterface.Zeros(2) + cyz: [y, z] in MathOptInterface.ZeroCone(2) minobjective: x """ model = MOIU.Model{Float64}() @@ -139,15 +139,15 @@ end @test MOI.get(bridged_mock, MOI.ListOfVariableIndices()) == [x, y, z] @test MOI.get( mock, - MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.Zeros}(), + MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.ZeroCone}(), ) == 0 @test MOI.get( bridged_mock, - MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.Zeros}(), + MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.ZeroCone}(), ) == 1 @test MOI.get( bridged_mock, - MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.Zeros}(), + MOI.ListOfConstraintIndices{MOI.VectorOfVariables,MOI.ZeroCone}(), ) == [cyz] end @@ -174,7 +174,7 @@ end _test_delete_bridged_variables( bridged_mock, yz, - MOI.Zeros, + MOI.ZeroCone, 3, ((MOI.SingleVariable, MOI.GreaterThan{Float64}, 1),), ) diff --git a/test/Bridges/bridge_optimizer.jl b/test/Bridges/bridge_optimizer.jl index 51dc56304d..65ab65ab83 100644 --- a/test/Bridges/bridge_optimizer.jl +++ b/test/Bridges/bridge_optimizer.jl @@ -131,7 +131,7 @@ MOIU.@model( (), (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan, MOI.Interval), ( - MOI.Zeros, + MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.NormInfinityCone, diff --git a/test/Bridges/lazy_bridge_optimizer.jl b/test/Bridges/lazy_bridge_optimizer.jl index bb2d27f752..2f539e4b56 100644 --- a/test/Bridges/lazy_bridge_optimizer.jl +++ b/test/Bridges/lazy_bridge_optimizer.jl @@ -182,7 +182,7 @@ end Float64, Int, ] - set = MOI.Zeros(1) + set = MOI.ZeroCone(1) @testset "No constraint bridge" begin model = StandardLPModel{T}() bridged = MOIB.Variable.Vectorize{T}(model) @@ -472,26 +472,26 @@ end @test MOIB.bridge_type(bridged, MOI.NonpositiveCone) == MOIB.Variable.NonposToNonnegBridge{T} end - @testset "Zeros" begin + @testset "ZeroCone" begin @test !MOI.supports_constraint( model, MOI.VectorOfVariables, - MOI.Zeros, + MOI.ZeroCone, ) - @test !MOI.supports_add_constrained_variables(bridged, MOI.Zeros) + @test !MOI.supports_add_constrained_variables(bridged, MOI.ZeroCone) @test !MOI.supports_constraint( bridged, MOI.VectorOfVariables, - MOI.Zeros, + MOI.ZeroCone, ) MOIB.add_bridge(bridged, MOIB.Variable.ZerosBridge{T}) @test !MOI.supports_constraint( bridged, MOI.VectorOfVariables, - MOI.Zeros, + MOI.ZeroCone, ) - @test MOI.supports_add_constrained_variables(bridged, MOI.Zeros) - @test MOIB.bridge_type(bridged, MOI.Zeros) == + @test MOI.supports_add_constrained_variables(bridged, MOI.ZeroCone) + @test MOIB.bridge_type(bridged, MOI.ZeroCone) == MOIB.Variable.ZerosBridge{T} end @testset "Free" begin @@ -597,7 +597,7 @@ end ) @test MOI.supports_add_constrained_variable(bridged, MOI.EqualTo{T}) @test MOIB.bridge_type(bridged, MOI.EqualTo{T}) == - MOIB.Variable.VectorizeBridge{T,MOI.Zeros} + MOIB.Variable.VectorizeBridge{T,MOI.ZeroCone} end @testset "RSOCtoPSD" begin @test !MOI.supports_constraint( @@ -683,12 +683,12 @@ end @test MOI.supports_constraint( bridged, MOI.VectorAffineFunction{T}, - MOI.Zeros, + MOI.ZeroCone, ) @test MOIB.bridge_type( bridged, MOI.VectorAffineFunction{T}, - MOI.Zeros, + MOI.ZeroCone, ) == MOIB.Constraint.ScalarizeBridge{ T, MOI.ScalarAffineFunction{T}, @@ -747,7 +747,7 @@ Bridge graph with 1 variable nodes, 1 constraint nodes and 0 objective nodes. Bridge graph with 1 variable nodes, 3 constraint nodes and 0 objective nodes. [1] constrained variables in `MOI.PositiveSemidefiniteConeSquare` are supported (distance 6) by adding free variables and then constrain them, see (1). (1) `MOI.VectorAffineFunction{$T}`-in-`MOI.PositiveSemidefiniteConeSquare` constraints are bridged (distance 3) by $(MOIB.Constraint.SquareBridge{T,MOI.VectorAffineFunction{T},MOI.ScalarAffineFunction{T},MOI.PositiveSemidefiniteConeTriangle,MOI.PositiveSemidefiniteConeSquare}). - (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.Zeros` constraints are bridged (distance 1) by $(MOIB.Constraint.ScalarizeBridge{T,MOI.ScalarAffineFunction{T},MOI.EqualTo{T}}). + (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.ZeroCone` constraints are bridged (distance 1) by $(MOIB.Constraint.ScalarizeBridge{T,MOI.ScalarAffineFunction{T},MOI.EqualTo{T}}). (3) `MOI.VectorAffineFunction{$T}`-in-`MOI.PositiveSemidefiniteConeTriangle` constraints are bridged (distance 2) by $(MOIB.Constraint.VectorSlackBridge{T,MOI.VectorAffineFunction{T},MOI.PositiveSemidefiniteConeTriangle}). """, ) @@ -1052,8 +1052,8 @@ Objective function of type `MOI.ScalarQuadraticFunction{$T}` is not supported an (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.RotatedSecondOrderCone` constraints are not supported because: Cannot use `$(MOIB.Constraint.VectorSlackBridge{T,MOI.VectorAffineFunction{T},MOI.RotatedSecondOrderCone})` because: [1] constrained variables in `MOI.RotatedSecondOrderCone` are not supported - (3) `MOI.VectorAffineFunction{$T}`-in-`MOI.Zeros` constraints are not supported - (3) `MOI.VectorAffineFunction{$T}`-in-`MOI.Zeros` constraints are not supported because no added bridge supports bridging it. + (3) `MOI.VectorAffineFunction{$T}`-in-`MOI.ZeroCone` constraints are not supported + (3) `MOI.VectorAffineFunction{$T}`-in-`MOI.ZeroCone` constraints are not supported because no added bridge supports bridging it. (4) `MOI.ScalarQuadraticFunction{$T}`-in-`MOI.LessThan{$T}` constraints are not supported because: Cannot use `$(MOIB.Constraint.QuadtoSOCBridge{T})` because: (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.RotatedSecondOrderCone` constraints are not supported @@ -1074,8 +1074,8 @@ Objective function of type `MOI.ScalarQuadraticFunction{$T}` is not supported an (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.RotatedSecondOrderCone` constraints are not supported (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.RotatedSecondOrderCone` constraints are not supported because: Cannot use `$(MOIB.Constraint.VectorSlackBridge{T,MOI.VectorAffineFunction{T},MOI.RotatedSecondOrderCone})` because: - (4) `MOI.VectorAffineFunction{$T}`-in-`MOI.Zeros` constraints are not supported - (4) `MOI.VectorAffineFunction{$T}`-in-`MOI.Zeros` constraints are not supported because no added bridge supports bridging it. + (4) `MOI.VectorAffineFunction{$T}`-in-`MOI.ZeroCone` constraints are not supported + (4) `MOI.VectorAffineFunction{$T}`-in-`MOI.ZeroCone` constraints are not supported because no added bridge supports bridging it. (5) `MOI.ScalarQuadraticFunction{$T}`-in-`MOI.LessThan{$T}` constraints are not supported because: Cannot use `$(MOIB.Constraint.QuadtoSOCBridge{T})` because: (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.RotatedSecondOrderCone` constraints are not supported @@ -1096,7 +1096,7 @@ Bridge graph with 1 variable nodes, 5 constraint nodes and 2 objective nodes. (1) `MOI.ScalarQuadraticFunction{$T}`-in-`MOI.GreaterThan{$T}` constraints are bridged (distance 5) by $(MOIB.Constraint.QuadtoSOCBridge{T}). (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.RotatedSecondOrderCone` constraints are bridged (distance 4) by $(MOIB.Constraint.VectorSlackBridge{T,MOI.VectorAffineFunction{T},MOI.RotatedSecondOrderCone}). (3) `MOI.SingleVariable`-in-`MOI.EqualTo{$T}` constraints are bridged (distance 1) by $(MOIB.Constraint.ScalarFunctionizeBridge{T,MOI.EqualTo{T}}). - (4) `MOI.VectorAffineFunction{$T}`-in-`MOI.Zeros` constraints are bridged (distance 1) by $(MOIB.Constraint.ScalarizeBridge{T,MOI.ScalarAffineFunction{T},MOI.EqualTo{T}}). + (4) `MOI.VectorAffineFunction{$T}`-in-`MOI.ZeroCone` constraints are bridged (distance 1) by $(MOIB.Constraint.ScalarizeBridge{T,MOI.ScalarAffineFunction{T},MOI.EqualTo{T}}). (5) `MOI.ScalarQuadraticFunction{$T}`-in-`MOI.LessThan{$T}` constraints are bridged (distance 5) by $(MOIB.Constraint.QuadtoSOCBridge{T}). |1| objective function of type `MOI.ScalarQuadraticFunction{$T}` is bridged (distance 12) by $(MOIB.Objective.SlackBridge{T,MOI.ScalarQuadraticFunction{T},MOI.ScalarQuadraticFunction{T}}). |2| objective function of type `MOI.SingleVariable` is bridged (distance 1) by $(MOIB.Objective.FunctionizeBridge{T}). @@ -1121,8 +1121,8 @@ Bridge graph with 1 variable nodes, 5 constraint nodes and 2 objective nodes. (1) `MOI.VectorAffineFunction{$T}`-in-`MOI.ExponentialCone` constraints are not supported because: Cannot use `$(MOIB.Constraint.VectorSlackBridge{T,MOI.VectorAffineFunction{T},MOI.ExponentialCone})` because: [1] constrained variables in `MOI.ExponentialCone` are not supported - (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.Zeros` constraints are not supported - (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.Zeros` constraints are not supported because no added bridge supports bridging it. + (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.ZeroCone` constraints are not supported + (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.ZeroCone` constraints are not supported because no added bridge supports bridging it. """, ) MOIB.add_bridge(bridged, MOIB.Constraint.VectorFunctionizeBridge{T}) @@ -1136,8 +1136,8 @@ Bridge graph with 1 variable nodes, 5 constraint nodes and 2 objective nodes. (1) `MOI.VectorAffineFunction{$T}`-in-`MOI.ExponentialCone` constraints are not supported because: Cannot use `$(MOIB.Constraint.VectorSlackBridge{T,MOI.VectorAffineFunction{T},MOI.ExponentialCone})` because: [1] constrained variables in `MOI.ExponentialCone` are not supported - (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.Zeros` constraints are not supported - (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.Zeros` constraints are not supported because no added bridge supports bridging it. + (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.ZeroCone` constraints are not supported + (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.ZeroCone` constraints are not supported because no added bridge supports bridging it. """, ) end @@ -1200,7 +1200,7 @@ MOIU.@model( (), (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan), ( - MOI.Zeros, + MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.SecondOrderCone, @@ -1242,7 +1242,7 @@ MOIU.@model( NoVariableModel, (MOI.ZeroOne, MOI.Integer), (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan), - (MOI.Zeros, MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.SecondOrderCone), + (MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.SecondOrderCone), (), (), (MOI.ScalarAffineFunction,), @@ -1308,7 +1308,7 @@ Bridge graph with 5 variable nodes, 11 constraint nodes and 0 objective nodes. (8) `MOI.SingleVariable`-in-`MOI.Interval{$T}` constraints are bridged (distance 2) by $(MOIB.Constraint.ScalarFunctionizeBridge{T,MOI.Interval{T}}). (9) `MOI.ScalarAffineFunction{$T}`-in-`MOI.Interval{$T}` constraints are bridged (distance 1) by $(MOIB.Constraint.SplitIntervalBridge{T,MOI.ScalarAffineFunction{T},MOI.Interval{T},MOI.GreaterThan{T},MOI.LessThan{T}}). (10) `MOI.SingleVariable`-in-`MOI.LessThan{$T}` constraints are bridged (distance 1) by $(MOIB.Constraint.LessToGreaterBridge{T,MOI.ScalarAffineFunction{T},MOI.SingleVariable}). - (11) `MOI.SingleVariable`-in-`MOI.EqualTo{$T}` constraints are bridged (distance 1) by $(MOIB.Constraint.VectorizeBridge{T,MOI.VectorAffineFunction{T},MOI.Zeros,MOI.SingleVariable}). + (11) `MOI.SingleVariable`-in-`MOI.EqualTo{$T}` constraints are bridged (distance 1) by $(MOIB.Constraint.VectorizeBridge{T,MOI.VectorAffineFunction{T},MOI.ZeroCone,MOI.SingleVariable}). """, ) end @@ -1469,7 +1469,7 @@ MOIU.@model( (), (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan, MOI.Interval), ( - MOI.Zeros, + MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.SecondOrderCone, @@ -1553,7 +1553,7 @@ MOIU.@model( ), ( MOI.Reals, - MOI.Zeros, + MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.NormInfinityCone, @@ -1599,7 +1599,7 @@ MOIU.@model( ), ( MOI.Reals, - MOI.Zeros, + MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.NormInfinityCone, @@ -1734,7 +1734,7 @@ end @testset "Supports" begin full_bridged_mock = MOIB.full_bridge_optimizer(mock, Float64) @testset "Mismatch vector/scalar" begin - for S in [MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.Zeros] + for S in [MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.ZeroCone] @test !MOI.supports_constraint( full_bridged_mock, MOI.SingleVariable, @@ -1896,7 +1896,7 @@ end for S in [ MOI.NonpositiveCone, MOI.NonnegativeCone, - MOI.Zeros, + MOI.ZeroCone, MOI.SecondOrderCone, ] @test MOI.supports_constraint( @@ -1932,7 +1932,7 @@ struct CustomScalarSet <: MOI.AbstractScalarSet end @test !MOI.supports_constraint(bridged, typeof(func), typeof(set)) end _test(f_scalar, MOI.EqualTo(one(S))) - _test(f_vector, MOI.Zeros(1)) + _test(f_vector, MOI.ZeroCone(1)) _test(f_scalar, CustomScalarSet()) _test(f_vector, CustomVectorSet(1)) end diff --git a/test/DeprecatedTest/contconic.jl b/test/DeprecatedTest/contconic.jl index 6ae2cbdc61..d88682b5e2 100644 --- a/test/DeprecatedTest/contconic.jl +++ b/test/DeprecatedTest/contconic.jl @@ -12,7 +12,7 @@ config = MOIT.Config() (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1.0, 0.0, 2.0], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-3, -1]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-3, -1]], ) MOIT.lin1vtest(mock, config) mock.optimize! = @@ -21,14 +21,14 @@ config = MOIT.Config() [1.0, 0.0, 2.0], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0, 2, 0]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-3, -1]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-3, -1]], ) MOIT.lin1ftest(mock, config) mock.optimize! = (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [-4, -3, 16, 0], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[7, 2, -4]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[7, 2, -4]], ) MOIT.lin2vtest(mock, config) mock.optimize! = @@ -37,7 +37,7 @@ config = MOIT.Config() [-4, -3, 16, 0], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0]], (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[0]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[7, 2, -4], [7]], ) MOIT.lin2ftest(mock, config) @@ -77,7 +77,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 0.5, 1], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-1], [-1]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-1], [-1]], (MOI.VectorOfVariables, MOI.NormInfinityCone) => [[1, 0, -1]], ) MOIT.norminf1vtest(mock, config) @@ -85,7 +85,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 0.5, 1], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-1], [-1]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-1], [-1]], (MOI.VectorAffineFunction{Float64}, MOI.NormInfinityCone) => [[1, 0, -1]], ) @@ -114,7 +114,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 0.5, 0.5], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-1], [0]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-1], [0]], (MOI.VectorOfVariables, MOI.NormOneCone) => [[1, -1, -1]], ) MOIT.normone1vtest(mock, config) @@ -122,7 +122,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 0.5, 0.5], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-1], [0]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-1], [0]], (MOI.VectorAffineFunction{Float64}, MOI.NormOneCone) => [[1, -1, -1]], ) @@ -151,7 +151,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1.0, 1 / √2, 1 / √2], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-√2]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-√2]], ) MOIT.soc1vtest(mock, config) mock.optimize! = @@ -160,7 +160,7 @@ end [1.0, 1 / √2, 1 / √2], (MOI.VectorAffineFunction{Float64}, MOI.SecondOrderCone) => [[√2, -1, -1]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[-√2]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-√2]], ) MOIT.soc1ftest(mock, config) mock.optimize! = @@ -169,7 +169,7 @@ end [-1 / √2, 1 / √2, 1.0], (MOI.VectorAffineFunction{Float64}, MOI.SecondOrderCone) => [[√2, 1, -1]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[√2]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[√2]], (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[1.0]], ) @@ -180,7 +180,7 @@ end [-1 / √2, 1 / √2, 1.0], (MOI.VectorAffineFunction{Float64}, MOI.SecondOrderCone) => [[√2, 1, -1]], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[√2]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[√2]], (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[-1.0]], ) @@ -197,7 +197,7 @@ end (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1.0, 2 / √5, 1 / √5, 2 / √5, 1 / √5], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-√5, -2.0, -1.0]], ) MOIT.soc4test(mock, config) diff --git a/test/DeprecatedTest/contlinear.jl b/test/DeprecatedTest/contlinear.jl index eb5bfbfec1..ea61bf4108 100644 --- a/test/DeprecatedTest/contlinear.jl +++ b/test/DeprecatedTest/contlinear.jl @@ -304,7 +304,7 @@ MOIU.set_mock_optimize!( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [0.0], - (MOI.VectorAffineFunction{Float64}, MOI.Zeros) => [[0.0, 0.0]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[0.0, 0.0]], ), ) MOIT.linear15test(mock, config) diff --git a/test/FileFormats/CBF/CBF.jl b/test/FileFormats/CBF/CBF.jl index df12252e72..d9e7422d3a 100644 --- a/test/FileFormats/CBF/CBF.jl +++ b/test/FileFormats/CBF/CBF.jl @@ -30,7 +30,7 @@ function _set_var_and_con_names(model::MOI.ModelLike) end for S in [ MOI.Reals, - MOI.Zeros, + MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.SecondOrderCone, @@ -208,11 +208,11 @@ const _WRITE_READ_MODELS = [ """, ), ( - "VectorOfVariables in Zeros", + "VectorOfVariables in ZeroCone", """ variables: x, y minobjective: x - c1: [x, y] in Zeros(2) + c1: [x, y] in ZeroCone(2) """, ), ( @@ -240,11 +240,11 @@ const _WRITE_READ_MODELS = [ """, ), ( - "VectorAffineFunction in Zeros", + "VectorAffineFunction in ZeroCone", """ variables: x, y minobjective: 1.2x - c1: [x + 2y + -1.1, 0] in Zeros(2) + c1: [x + 2y + -1.1, 0] in ZeroCone(2) """, ), ( @@ -398,7 +398,7 @@ const _EXAMPLE_MODELS = [ variables: U, V, W, X, Y, Z, x, y, z minobjective: y + 2U + 2V + 2W + 2Y + 2Z c1: [U, V, W, X, Y, Z] in PositiveSemidefiniteConeTriangle(3) - c2: [y + U + W + Z + -1, x + z + U + 2V + W + 2X + 2Y + Z + -0.5] in Zeros(2) + c2: [y + U + W + Z + -1, x + z + U + 2V + W + 2X + 2Y + Z + -0.5] in ZeroCone(2) c3: [y, x, z] in SecondOrderCone(3) """, ), @@ -417,7 +417,7 @@ const _EXAMPLE_MODELS = [ """ variables: a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p maxobjective: a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + -1 - c1: [b] in Zeros(1) + c1: [b] in ZeroCone(1) c2: [c] in NonnegativeCone(1) c3: [d] in NonpositiveCone(1) c4: [e, f, g] in SecondOrderCone(3) diff --git a/test/FileFormats/MOF/MOF.jl b/test/FileFormats/MOF/MOF.jl index e0e39526e9..fa07946087 100644 --- a/test/FileFormats/MOF/MOF.jl +++ b/test/FileFormats/MOF/MOF.jl @@ -544,7 +544,7 @@ function test_Zeros() """ variables: x, y, z minobjective: x -c1: [x, y, z] in Zeros(3) +c1: [x, y, z] in ZeroCone(3) """, ["x", "y", "z"], ["c1"], @@ -624,7 +624,7 @@ function test_vectoraffine_in_zeros() """ variables: x, y minobjective: x -c1: [1.0x + -3.0, 2.0y + -4.0] in Zeros(2) +c1: [1.0x + -3.0, 2.0y + -4.0] in ZeroCone(2) """, ["x", "y"], ["c1"], diff --git a/test/Utilities/copy.jl b/test/Utilities/copy.jl index b4f8958d73..630d28db37 100644 --- a/test/Utilities/copy.jl +++ b/test/Utilities/copy.jl @@ -56,7 +56,7 @@ end function MOI.supports_constraint( ::AbstractDummyModel, ::Type{MOI.VectorOfVariables}, - ::Type{MOI.Zeros}, + ::Type{MOI.ZeroCone}, ) return true end @@ -517,15 +517,15 @@ function test_create_variables_using_supports_add_constrained_variable() @test typeof(c2) == typeof(dest.constraintIndices[2]) b, cb = MOI.add_constrained_variables(src, MOI.NonnegativeCone(2)) - c3 = MOI.add_constraint(src, b, MOI.Zeros(2)) + c3 = MOI.add_constraint(src, b, MOI.ZeroCone(2)) - d, cd = MOI.add_constrained_variables(src, MOI.Zeros(2)) + d, cd = MOI.add_constrained_variables(src, MOI.ZeroCone(2)) c4 = MOI.add_constraint(src, d, MOI.NonpositiveCone(2)) dest = OrderConstrainedVariablesModel() bridged_dest = MOI.Bridges.full_bridge_optimizer(dest, Float64) @test MOIU.sorted_variable_sets_by_cost(bridged_dest, src) == [ - (MOI.VectorOfVariables, MOI.Zeros), + (MOI.VectorOfVariables, MOI.ZeroCone), (MOI.VectorOfVariables, MOI.NonnegativeCone), (MOI.VectorOfVariables, MOI.NonpositiveCone), ] @@ -553,16 +553,16 @@ function test_create_variables_using_supports_add_constrained_variable() bridged_dest, MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) == 1.0 - @test MOI.supports_add_constrained_variables(bridged_dest, MOI.Zeros) - @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.Zeros}()) == 1.0 + @test MOI.supports_add_constrained_variables(bridged_dest, MOI.ZeroCone) + @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.ZeroCone}()) == 1.0 @test MOI.supports_constraint( bridged_dest, MOI.VectorOfVariables, - MOI.Zeros, + MOI.ZeroCone, ) @test MOI.get( bridged_dest, - MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.Zeros}(), + MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.ZeroCone}(), ) == 2.0 index_map = MOI.copy_to(bridged_dest, src) @test length(dest.constraintIndices) == 4 @@ -570,7 +570,7 @@ function test_create_variables_using_supports_add_constrained_variable() dest = ReverseOrderConstrainedVariablesModel() bridged_dest = MOI.Bridges.full_bridge_optimizer(dest, Float64) @test MOIU.sorted_variable_sets_by_cost(bridged_dest, src) == [ - (MOI.VectorOfVariables, MOI.Zeros), + (MOI.VectorOfVariables, MOI.ZeroCone), (MOI.VectorOfVariables, MOI.NonpositiveCone), (MOI.VectorOfVariables, MOI.NonnegativeCone), ] @@ -598,16 +598,16 @@ function test_create_variables_using_supports_add_constrained_variable() bridged_dest, MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.NonpositiveCone}(), ) == 1.0 - @test MOI.supports_add_constrained_variables(bridged_dest, MOI.Zeros) - @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.Zeros}()) == 1.0 + @test MOI.supports_add_constrained_variables(bridged_dest, MOI.ZeroCone) + @test MOI.get(bridged_dest, MOI.VariableBridgingCost{MOI.ZeroCone}()) == 1.0 @test MOI.supports_constraint( bridged_dest, MOI.VectorOfVariables, - MOI.Zeros, + MOI.ZeroCone, ) @test MOI.get( bridged_dest, - MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.Zeros}(), + MOI.ConstraintBridgingCost{MOI.VectorOfVariables,MOI.ZeroCone}(), ) == 3.0 index_map = MOI.copy_to(bridged_dest, src) @test length(dest.constraintIndices) == 4 diff --git a/test/Utilities/matrix_of_constraints.jl b/test/Utilities/matrix_of_constraints.jl index e873e05d80..e75490411a 100644 --- a/test/Utilities/matrix_of_constraints.jl +++ b/test/Utilities/matrix_of_constraints.jl @@ -420,7 +420,7 @@ MOIU.@struct_of_constraints_by_function_types( MOI.VectorAffineFunction{T}, ) -MOIU.@product_of_sets(Zeros, MOI.Zeros) +MOIU.@product_of_sets(ZeroCone, MOI.ZeroCone) function test_empty() T = Float64 @@ -433,7 +433,7 @@ function test_empty() T, MOIU.MutableSparseMatrixCSC{T,Int,Indexing}, Vector{T}, - Zeros{Float64}, + ZeroCone{Float64}, }, }, }() @@ -457,7 +457,7 @@ function test_supports_constraint(T::Type = Float64, BadT::Type = Float32) model = MOIU.GenericOptimizer{ T, VoVorSAff{T}{ - MOIU.VectorOfConstraints{MOI.VectorOfVariables,MOI.Zeros}, + MOIU.VectorOfConstraints{MOI.VectorOfVariables,MOI.ZeroCone}, MOIU.MatrixOfConstraints{ T, MOIU.MutableSparseMatrixCSC{T,Int,Indexing}, @@ -497,7 +497,7 @@ function test_copy(Indexing) T, MOIU.MutableSparseMatrixCSC{T,Int,Indexing}, Vector{T}, - Zeros{T}, + ZeroCone{T}, }, }, }() @@ -528,7 +528,7 @@ end MOIU.@struct_of_constraints_by_set_types( ZerosOrNot, - MOI.Zeros, + MOI.ZeroCone, Union{MOI.NonnegativeCone,MOI.NonpositiveCone}, ) @@ -542,7 +542,7 @@ function test_multicone() T, MOIU.MutableSparseMatrixCSC{T,Int,Indexing}, Vector{T}, - Zeros{T}, + ZeroCone{T}, }, MOIU.MatrixOfConstraints{ T, @@ -557,7 +557,7 @@ function test_multicone() fx = MOI.SingleVariable(x) y = MOI.add_variable(model) fy = MOI.SingleVariable(y) - MOI.add_constraint(model, MOIU.vectorize([T(5) * fx + T(2)]), MOI.Zeros(1)) + MOI.add_constraint(model, MOIU.vectorize([T(5) * fx + T(2)]), MOI.ZeroCone(1)) MOI.add_constraint( model, MOIU.vectorize([T(3) * fy + T(1)]), diff --git a/test/Utilities/product_of_sets.jl b/test/Utilities/product_of_sets.jl index 46eb467abd..7716eebf72 100644 --- a/test/Utilities/product_of_sets.jl +++ b/test/Utilities/product_of_sets.jl @@ -234,7 +234,7 @@ function test_vector_NumberOfConstraints() MOI.Utilities.final_touch(sets) @test MOI.get( sets, - MOI.NumberOfConstraints{MOI.VectorAffineFunction{Float64},MOI.Zeros}(), + MOI.NumberOfConstraints{MOI.VectorAffineFunction{Float64},MOI.ZeroCone}(), ) == 0 for (x, S) in zip([2, 1], MOI.Utilities.set_types(sets)[1:2]) @test MOI.get( @@ -260,8 +260,8 @@ function test_vector_ListOfConstraintIndices() MOI.Utilities.add_set(sets, 3) MOI.Utilities.final_touch(sets) VAF = MOI.VectorAffineFunction{Float64} - @test MOI.get(sets, MOI.ListOfConstraintIndices{VAF,MOI.Zeros}()) == - MOI.ConstraintIndex{VAF,MOI.Zeros}[] + @test MOI.get(sets, MOI.ListOfConstraintIndices{VAF,MOI.ZeroCone}()) == + MOI.ConstraintIndex{VAF,MOI.ZeroCone}[] for (x, S) in zip([[1], [1, 3]], MOI.Utilities.set_types(sets)[1:2]) ci = MOI.get(sets, MOI.ListOfConstraintIndices{VAF,S}()) @test ci == MOI.ConstraintIndex{VAF,S}.(x) diff --git a/test/constraints.jl b/test/constraints.jl index a06718f028..60569c277e 100644 --- a/test/constraints.jl +++ b/test/constraints.jl @@ -16,7 +16,7 @@ function _constant_not_zero_test(::Type{T}) where {T} func2 = one(T) * fx @test nothing === MOI.throw_if_scalar_and_constant_not_zero(func2, S) func = MOI.Utilities.operate(vcat, T, func1, func2) - @test nothing === MOI.throw_if_scalar_and_constant_not_zero(func, MOI.Zeros) + @test nothing === MOI.throw_if_scalar_and_constant_not_zero(func, MOI.ZeroCone) end function test_constraints_ConstantNotZero() diff --git a/test/dummy.jl b/test/dummy.jl index 7a5bc8ff04..62656fa3cb 100644 --- a/test/dummy.jl +++ b/test/dummy.jl @@ -30,7 +30,7 @@ end function MOI.supports_constraint( ::AbstractDummyModel, ::Type{MOI.VectorOfVariables}, - ::Type{MOI.Zeros}, + ::Type{MOI.ZeroCone}, ) return true end diff --git a/test/errors.jl b/test/errors.jl index 345626f673..6b124ed752 100644 --- a/test/errors.jl +++ b/test/errors.jl @@ -111,7 +111,7 @@ function test_errors_add_constraint() ) @test_throws( MOI.AddConstraintNotAllowed, - MOI.add_constraint(model, [vi, vi], MOI.Zeros(2)), + MOI.add_constraint(model, [vi, vi], MOI.ZeroCone(2)), ) @test_throws( MOI.AddConstraintNotAllowed, diff --git a/test/hygiene.jl b/test/hygiene.jl index b776bb145d..0359ac2166 100644 --- a/test/hygiene.jl +++ b/test/hygiene.jl @@ -13,7 +13,7 @@ MathOptInterface.Utilities.@model( LPModel, # Name of model (), # untyped scalar sets (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan, MOI.Interval), # typed scalar sets - (MOI.Zeros, MOI.NonnegativeCone, MOI.NonpositiveCone), # untyped vector sets + (MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone), # untyped vector sets (), # typed vector sets (), # untyped scalar functions (MOI.ScalarAffineFunction,), # typed scalar functions diff --git a/test/sets.jl b/test/sets.jl index 8876626287..4432def9c3 100644 --- a/test/sets.jl +++ b/test/sets.jl @@ -117,7 +117,7 @@ end function test_sets_DimensionMismatch() for (S, min_dimension) in ( (MOI.Reals, 0), - (MOI.Zeros, 0), + (MOI.ZeroCone, 0), (MOI.NonnegativeCone, 0), (MOI.NonpositiveCone, 0), (MOI.NormInfinityCone, 1), @@ -181,8 +181,8 @@ function test_sets_dual_nonnegatives() end function test_sets_dual_zeroreal() - zeros3 = MOI.Zeros(3) - zeros4 = MOI.Zeros(4) + zeros3 = MOI.ZeroCone(3) + zeros4 = MOI.ZeroCone(4) reals3 = MOI.Reals(3) reals4 = MOI.Reals(4) _dual_set_test(zeros3, reals3) From 29ad0d280dfef3aac55fa053d589c213c8be1633 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 18 Jul 2021 05:37:23 +0200 Subject: [PATCH 4/5] Rename Reals to RealCone. --- docs/src/manual/standard_form.md | 2 +- docs/src/reference/standard_form.md | 2 +- docs/src/tutorials/implementing.md | 2 +- perf/bellman_ford.jl | 2 +- .../Constraint/single_bridge_optimizer.jl | 6 ++-- src/Bridges/Variable/free.jl | 6 ++-- src/Bridges/Variable/map.jl | 2 +- src/Bridges/bridge_optimizer.jl | 18 ++++++------ src/Bridges/lazy_bridge_optimizer.jl | 4 +-- src/FileFormats/CBF/CBF.jl | 2 +- src/FileFormats/CBF/read.jl | 2 +- src/FileFormats/CBF/write.jl | 4 +-- src/FileFormats/MOF/MOF.jl | 2 +- src/FileFormats/MOF/mof.0.6.schema.json | 4 +-- src/FileFormats/MOF/read.jl | 6 ++-- src/FileFormats/MOF/write.jl | 2 +- src/Utilities/cachingoptimizer.jl | 4 +-- src/Utilities/mockoptimizer.jl | 4 +-- src/Utilities/model.jl | 2 +- src/Utilities/precompile.jl | 2 +- src/constraints.jl | 12 ++++---- src/precompile.jl | 4 +-- src/sets.jl | 28 +++++++++---------- src/variables.jl | 16 +++++------ test/Bridges/Variable/free.jl | 18 ++++++------ test/Bridges/lazy_bridge_optimizer.jl | 26 ++++++++--------- test/Bridges/utilities.jl | 8 +++--- test/FileFormats/CBF/CBF.jl | 10 +++---- test/FileFormats/MOF/MOF.jl | 2 +- test/Utilities/cachingoptimizer.jl | 4 +-- test/Utilities/mockoptimizer.jl | 4 +-- test/sets.jl | 6 ++-- 32 files changed, 108 insertions(+), 108 deletions(-) diff --git a/docs/src/manual/standard_form.md b/docs/src/manual/standard_form.md index 6ee0902405..e69b8e0042 100644 --- a/docs/src/manual/standard_form.md +++ b/docs/src/manual/standard_form.md @@ -71,7 +71,7 @@ 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}`` * [`ZeroCone(dimension)`](@ref MathOptInterface.ZeroCone): ``0^\mbox{dimension}`` * [`NonnegativeCone(dimension)`](@ref MathOptInterface.NonnegativeCone): diff --git a/docs/src/reference/standard_form.md b/docs/src/reference/standard_form.md index af687494d0..5adec85f25 100644 --- a/docs/src/reference/standard_form.md +++ b/docs/src/reference/standard_form.md @@ -73,7 +73,7 @@ Semiinteger List of recognized vector sets. ```@docs -Reals +RealCone Zeros NonnegativeCone NonpositiveCone diff --git a/docs/src/tutorials/implementing.md b/docs/src/tutorials/implementing.md index 293180e478..02e1e639f1 100644 --- a/docs/src/tutorials/implementing.md +++ b/docs/src/tutorials/implementing.md @@ -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` diff --git a/perf/bellman_ford.jl b/perf/bellman_ford.jl index 33dbca162b..72ac42b8d4 100644 --- a/perf/bellman_ford.jl +++ b/perf/bellman_ford.jl @@ -13,7 +13,7 @@ MOI.supports_constraint(::SDPAModel{T}, ::Type{MOI.SingleVariable}, ::Type{MOI.G 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 diff --git a/src/Bridges/Constraint/single_bridge_optimizer.jl b/src/Bridges/Constraint/single_bridge_optimizer.jl index 290144961b..3b2aff6061 100644 --- a/src/Bridges/Constraint/single_bridge_optimizer.jl +++ b/src/Bridges/Constraint/single_bridge_optimizer.jl @@ -34,11 +34,11 @@ end MOIB.supports_constraint_bridges(::SingleBridgeOptimizer) = true -# If `BT` bridges `MOI.Reals` (such as `Constraint.FunctionizeBridge` bridge, +# If `BT` bridges `MOI.RealCone` (such as `Constraint.FunctionizeBridge` bridge, # without this method, it creates a `StackOverflow` with # `is_bridged`, `supports_bridging_constrained_variable` # and `supports_add_constrained_variables`. -MOIB.is_bridged(::SingleBridgeOptimizer, ::Type{MOI.Reals}) = false +MOIB.is_bridged(::SingleBridgeOptimizer, ::Type{MOI.RealCone}) = false function MOIB.is_bridged(b::SingleBridgeOptimizer, S::Type{<:MOI.AbstractSet}) return MOIB.supports_bridging_constrained_variable(b, S) @@ -52,7 +52,7 @@ function MOIB.supports_bridging_constrained_variable( b, MOIU.variable_function_type(S), S, - ) && MOI.supports_add_constrained_variables(b, MOI.Reals) + ) && MOI.supports_add_constrained_variables(b, MOI.RealCone) end function MOIB.supports_bridging_constraint( diff --git a/src/Bridges/Variable/free.jl b/src/Bridges/Variable/free.jl index f9b1e24e9b..3c5a09a805 100644 --- a/src/Bridges/Variable/free.jl +++ b/src/Bridges/Variable/free.jl @@ -1,7 +1,7 @@ """ FreeBridge{T} <: Bridges.Variable.AbstractBridge -Transforms constrained variables in [`MOI.Reals`](@ref) to the difference of +Transforms constrained variables in [`MOI.RealCone`](@ref) to the difference of constrained variables in [`MOI.NonnegativeCone`](@ref). """ struct FreeBridge{T} <: AbstractBridge @@ -12,7 +12,7 @@ end function bridge_constrained_variable( ::Type{FreeBridge{T}}, model::MOI.ModelLike, - set::MOI.Reals, + set::MOI.RealCone, ) where {T} variables, constraint = MOI.add_constrained_variables( model, @@ -21,7 +21,7 @@ function bridge_constrained_variable( return FreeBridge{T}(variables, constraint) end -function supports_constrained_variable(::Type{<:FreeBridge}, ::Type{MOI.Reals}) +function supports_constrained_variable(::Type{<:FreeBridge}, ::Type{MOI.RealCone}) return true end diff --git a/src/Bridges/Variable/map.jl b/src/Bridges/Variable/map.jl index e9919338b9..624ba6b675 100644 --- a/src/Bridges/Variable/map.jl +++ b/src/Bridges/Variable/map.jl @@ -223,7 +223,7 @@ function list_of_constraint_types(map::Map) for i in eachindex(map.bridges) if map.bridges[i] !== nothing S = map.sets[i] - if S != MOI.Reals + if S != MOI.RealCone F = MOIU.variable_function_type(S) push!(list, (F, S)) end diff --git a/src/Bridges/bridge_optimizer.jl b/src/Bridges/bridge_optimizer.jl index 11e5c0e7ed..c0cc1f3b0f 100644 --- a/src/Bridges/bridge_optimizer.jl +++ b/src/Bridges/bridge_optimizer.jl @@ -1617,8 +1617,8 @@ end # Variables function MOI.add_variable(b::AbstractBridgeOptimizer) - if is_bridged(b, MOI.Reals) - variables, constraint = MOI.add_constrained_variables(b, MOI.Reals(1)) + if is_bridged(b, MOI.RealCone) + variables, constraint = MOI.add_constrained_variables(b, MOI.RealCone(1)) @assert isone(length(variables)) return first(variables) else @@ -1627,8 +1627,8 @@ function MOI.add_variable(b::AbstractBridgeOptimizer) end function MOI.add_variables(b::AbstractBridgeOptimizer, n) - if is_bridged(b, MOI.Reals) - variables, constraint = MOI.add_constrained_variables(b, MOI.Reals(n)) + if is_bridged(b, MOI.RealCone) + variables, constraint = MOI.add_constrained_variables(b, MOI.RealCone(n)) return variables else return MOI.add_variables(b.model, n) @@ -1638,12 +1638,12 @@ end # Split in two to avoid ambiguity function MOI.supports_add_constrained_variables( b::AbstractBridgeOptimizer, - ::Type{MOI.Reals}, + ::Type{MOI.RealCone}, ) - if is_bridged(b, MOI.Reals) - return supports_bridging_constrained_variable(b, MOI.Reals) + if is_bridged(b, MOI.RealCone) + return supports_bridging_constrained_variable(b, MOI.RealCone) else - return MOI.supports_add_constrained_variables(b.model, MOI.Reals) + return MOI.supports_add_constrained_variables(b.model, MOI.RealCone) end end @@ -1665,7 +1665,7 @@ function MOI.add_constrained_variables( if !is_bridged(b, typeof(set)) return MOI.add_constrained_variables(b.model, set) end - if set isa MOI.Reals || is_variable_bridged(b, typeof(set)) + if set isa MOI.RealCone || is_variable_bridged(b, typeof(set)) BridgeType = Variable.concrete_bridge_type(b, typeof(set)) return Variable.add_keys_for_bridge( Variable.bridges(b), diff --git a/src/Bridges/lazy_bridge_optimizer.jl b/src/Bridges/lazy_bridge_optimizer.jl index 20b6e14821..0bb09484bc 100644 --- a/src/Bridges/lazy_bridge_optimizer.jl +++ b/src/Bridges/lazy_bridge_optimizer.jl @@ -189,10 +189,10 @@ function node(b::LazyBridgeOptimizer, S::Type{<:MOI.AbstractSet}) variable_node = add_variable_node(b.graph) b.variable_node[(S,)] = variable_node push!(b.variable_types, (S,)) - if is_bridged(b, MOI.Reals) + if is_bridged(b, MOI.RealCone) FF = functionized_type(b, F) if FF !== nothing - # We assume the distance of the variable node `MOI.Reals` is `1`, + # We assume the distance of the variable node `MOI.RealCone` is `1`, # i.e. it is bridged by `Variable.FreeBridge` and then # the distance of `MOI.NonnegativeCone` is zero. # We also use the functionize bridge which has cost 1. diff --git a/src/FileFormats/CBF/CBF.jl b/src/FileFormats/CBF/CBF.jl index d8d70b5aec..d26165c4c6 100644 --- a/src/FileFormats/CBF/CBF.jl +++ b/src/FileFormats/CBF/CBF.jl @@ -10,7 +10,7 @@ MOI.Utilities.@model( (MOI.Integer,), (), ( - MOI.Reals, + MOI.RealCone, MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, diff --git a/src/FileFormats/CBF/read.jl b/src/FileFormats/CBF/read.jl index 5d09142e34..edb8c292f9 100644 --- a/src/FileFormats/CBF/read.jl +++ b/src/FileFormats/CBF/read.jl @@ -59,7 +59,7 @@ function _cbf_to_moi_cone( cone_dim::Int, ) if cone_str == "F" - return MOI.Reals(cone_dim) + return MOI.RealCone(cone_dim) elseif cone_str == "L=" return MOI.ZeroCone(cone_dim) elseif cone_str == "L-" diff --git a/src/FileFormats/CBF/write.jl b/src/FileFormats/CBF/write.jl index dfc8012ea8..d21546e30c 100644 --- a/src/FileFormats/CBF/write.jl +++ b/src/FileFormats/CBF/write.jl @@ -29,7 +29,7 @@ mutable struct _CBFDataStructure end _cone_string(::Any, ::Type{MOI.ZeroCone}) = "L=" -_cone_string(::Any, ::Type{MOI.Reals}) = "F" +_cone_string(::Any, ::Type{MOI.RealCone}) = "F" _cone_string(::Any, ::Type{MOI.NonnegativeCone}) = "L+" _cone_string(::Any, ::Type{MOI.NonpositiveCone}) = "L-" _cone_string(::Any, ::Type{MOI.SecondOrderCone}) = "Q" @@ -181,7 +181,7 @@ function _CBFDataStructure(model::Model) data = _CBFDataStructure() for S in ( MOI.ZeroCone, - MOI.Reals, + MOI.RealCone, MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.SecondOrderCone, diff --git a/src/FileFormats/MOF/MOF.jl b/src/FileFormats/MOF/MOF.jl index bbffc0f724..30f1a9b928 100644 --- a/src/FileFormats/MOF/MOF.jl +++ b/src/FileFormats/MOF/MOF.jl @@ -36,7 +36,7 @@ MOI.Utilities.@model( MOI.Semiinteger, ), ( - MOI.Reals, + MOI.RealCone, MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, diff --git a/src/FileFormats/MOF/mof.0.6.schema.json b/src/FileFormats/MOF/mof.0.6.schema.json index ef292838b8..1afc0ff2c1 100644 --- a/src/FileFormats/MOF/mof.0.6.schema.json +++ b/src/FileFormats/MOF/mof.0.6.schema.json @@ -628,11 +628,11 @@ } }, { "description": "R^{dimension}", - "examples": ["{\"type\": \"Reals\", \"dimension\": 3}"], + "examples": ["{\"type\": \"RealCone\", \"dimension\": 3}"], "required": ["dimension"], "properties": { "type": { - "const": "Reals" + "const": "RealCone" }, "dimension": { "type": "integer", diff --git a/src/FileFormats/MOF/read.jl b/src/FileFormats/MOF/read.jl index 6bf39a9f79..ffe6bb291c 100644 --- a/src/FileFormats/MOF/read.jl +++ b/src/FileFormats/MOF/read.jl @@ -288,7 +288,7 @@ end Semiinteger, Semicontinuous, ZeroCone, - Reals, + RealCone, NonnegativeCone, NonpositiveCone, SecondOrderCone, @@ -371,8 +371,8 @@ function set_to_moi(::Val{:ZeroCone}, object::Object) return MOI.ZeroCone(object["dimension"]) end -function set_to_moi(::Val{:Reals}, object::Object) - return MOI.Reals(object["dimension"]) +function set_to_moi(::Val{:RealCone}, object::Object) + return MOI.RealCone(object["dimension"]) end function set_to_moi(::Val{:NonnegativeCone}, object::Object) diff --git a/src/FileFormats/MOF/write.jl b/src/FileFormats/MOF/write.jl index 762ec5cb7b..27436486b7 100644 --- a/src/FileFormats/MOF/write.jl +++ b/src/FileFormats/MOF/write.jl @@ -263,7 +263,7 @@ head_name(::Type{<:MOI.Semicontinuous}) = "Semicontinuous" # ========== Non-typed vector sets ========== head_name(::Type{MOI.ZeroCone}) = "ZeroCone" -head_name(::Type{MOI.Reals}) = "Reals" +head_name(::Type{MOI.RealCone}) = "RealCone" head_name(::Type{MOI.NonnegativeCone}) = "NonnegativeCone" head_name(::Type{MOI.NonpositiveCone}) = "NonpositiveCone" head_name(::Type{MOI.SecondOrderCone}) = "SecondOrderCone" diff --git a/src/Utilities/cachingoptimizer.jl b/src/Utilities/cachingoptimizer.jl index d7a26c01f3..8c97ec66bf 100644 --- a/src/Utilities/cachingoptimizer.jl +++ b/src/Utilities/cachingoptimizer.jl @@ -408,9 +408,9 @@ end # Split in two to solve ambiguity function MOI.supports_add_constrained_variables( m::CachingOptimizer, - ::Type{MOI.Reals}, + ::Type{MOI.RealCone}, ) - return _supports_add_constrained_variables(m, MOI.Reals) + return _supports_add_constrained_variables(m, MOI.RealCone) end function MOI.supports_add_constrained_variables( diff --git a/src/Utilities/mockoptimizer.jl b/src/Utilities/mockoptimizer.jl index 876bdb7d0e..8fb64f4e33 100644 --- a/src/Utilities/mockoptimizer.jl +++ b/src/Utilities/mockoptimizer.jl @@ -833,9 +833,9 @@ end # Add this method to avoid ambiguity function MOI.supports_add_constrained_variables( mock::MockOptimizer, - ::Type{MOI.Reals}, + ::Type{MOI.RealCone}, ) - return MOI.supports_add_constrained_variables(mock.inner_model, MOI.Reals) + return MOI.supports_add_constrained_variables(mock.inner_model, MOI.RealCone) end function MOI.copy_to(mock::MockOptimizer, src::MOI.ModelLike; kws...) diff --git a/src/Utilities/model.jl b/src/Utilities/model.jl index ec19b327f4..2bbcd2dee3 100644 --- a/src/Utilities/model.jl +++ b/src/Utilities/model.jl @@ -1048,7 +1048,7 @@ const LessThanIndicatorSetZero{T} = MOI.Semiinteger, ), ( - MOI.Reals, + MOI.RealCone, MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, diff --git a/src/Utilities/precompile.jl b/src/Utilities/precompile.jl index 6737a01040..819231d2a5 100644 --- a/src/Utilities/precompile.jl +++ b/src/Utilities/precompile.jl @@ -20,7 +20,7 @@ function _precompile_() MOI.NonnegativeCone, MOI.NonpositiveCone, MOI.ZeroCone, - MOI.Reals, + MOI.RealCone, MOI.SecondOrderCone, MOI.RotatedSecondOrderCone, MOI.PositiveSemidefiniteConeSquare, diff --git a/src/constraints.jl b/src/constraints.jl index 47099cff76..730df51b81 100644 --- a/src/constraints.jl +++ b/src/constraints.jl @@ -9,7 +9,7 @@ is, `copy_to(model, src)` does not throw [`UnsupportedConstraint`](@ref) when supported in specific circumstances, e.g. `F`-in-`S` constraints cannot be combined with another type of constraint, it should still return `true`. - supports_constraint(model::ModelLike, ::Type{VectorOfVariables}, ::Type{Reals})::Bool + supports_constraint(model::ModelLike, ::Type{VectorOfVariables}, ::Type{RealCone})::Bool Return a `Bool` indicating whether `model` supports free variables. That is, `copy_to(model, src)` does not error when `src` contains variables that are not @@ -20,7 +20,7 @@ solver requires all variables to be nonnegative, it should implement this method and return `false` because free variables cannot be copied to the solver. Note that free variables are not explicitly set to be free by calling -[`add_constraint`](@ref) with the set [`Reals`](@ref), instead, free variables +[`add_constraint`](@ref) with the set [`RealCone`](@ref), instead, free variables are created with [`add_variable`](@ref) and [`add_variables`](@ref). If `model` does not support free variables, it should not implement [`add_variable`](@ref) nor [`add_variables`](@ref) but should implement @@ -32,11 +32,11 @@ function supports_constraint( F::Type{<:AbstractFunction}, S::Type{<:AbstractSet}, ) - # TODO remove this condition, as `supports_add_constrained_variables(model, Reals)` + # TODO remove this condition, as `supports_add_constrained_variables(model, RealCone)` # should be called instead of - # `supports_constraint(model, ::VectorOfVariables, ::Reals) - if F === VectorOfVariables && S === Reals - return supports_add_constrained_variables(model, Reals) + # `supports_constraint(model, ::VectorOfVariables, ::RealCone) + if F === VectorOfVariables && S === RealCone + return supports_add_constrained_variables(model, RealCone) else return false end diff --git a/src/precompile.jl b/src/precompile.jl index 23cdbaffe5..a04e1603dd 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -54,7 +54,7 @@ function precompile_variables(model) ) Base.precompile(get, (model, VariablePrimal, VariableIndex)) Base.precompile(get, (model, VariablePrimal, Vector{VariableIndex})) - return Base.precompile(add_constrained_variables, (model, Reals)) + return Base.precompile(add_constrained_variables, (model, RealCone)) end function precompile_model(model, constraints) @@ -82,5 +82,5 @@ function precompile_model(model, constraints) for (F, S) in constraints precompile_constraint(model, F, S) end - return Base.precompile(Tuple{typeof(add_constrained_variables),model,Reals}) + return Base.precompile(Tuple{typeof(add_constrained_variables),model,RealCone}) end diff --git a/src/sets.jl b/src/sets.jl index c67f98e449..1573e1424d 100644 --- a/src/sets.jl +++ b/src/sets.jl @@ -19,7 +19,7 @@ Return the [`output_dimension`](@ref) that an [`AbstractFunction`](@ref) should ### Examples ```julia-repl -julia> dimension(Reals(4)) +julia> dimension(RealCone(4)) 4 julia> dimension(LessThan(3.0)) @@ -46,7 +46,7 @@ If the dual cone is not defined it returns an error. ### Examples ```jldocstest -julia> dual_set(Reals(4)) +julia> dual_set(RealCone(4)) ZeroCone(4) julia> dual_set(SecondOrderCone(5)) @@ -69,7 +69,7 @@ Return the type of dual set of sets of type `S`, as returned by ### Examples ```jldocstest -julia> dual_set_type(Reals) +julia> dual_set_type(RealCone) ZeroCone julia> dual_set_type(SecondOrderCone) @@ -106,18 +106,18 @@ abstract type AbstractVectorSet <: AbstractSet end dimension(s::AbstractVectorSet) = s.dimension # .dimension field is conventional, overwrite this method if not applicable """ - Reals(dimension) + RealCone(dimension) The set ``\\mathbb{R}^{dimension}`` (containing all points) of dimension `dimension`. """ -struct Reals <: AbstractVectorSet +struct RealCone <: AbstractVectorSet dimension::Int - function Reals(dimension::Base.Integer) + function RealCone(dimension::Base.Integer) if !(dimension >= 0) throw( DimensionMismatch( - "Dimension of Reals must be >= 0, not $(dimension).", + "Dimension of RealCone must be >= 0, not $(dimension).", ), ) end @@ -125,8 +125,8 @@ struct Reals <: AbstractVectorSet end end -dual_set(s::Reals) = ZeroCone(dimension(s)) -dual_set_type(::Type{Reals}) = ZeroCone +dual_set(s::RealCone) = ZeroCone(dimension(s)) +dual_set_type(::Type{RealCone}) = ZeroCone """ ZeroCone(dimension) @@ -148,8 +148,8 @@ struct ZeroCone <: AbstractVectorSet end end -dual_set(s::ZeroCone) = Reals(dimension(s)) -dual_set_type(::Type{ZeroCone}) = Reals +dual_set(s::ZeroCone) = RealCone(dimension(s)) +dual_set_type(::Type{ZeroCone}) = RealCone """ NonnegativeCone(dimension) @@ -1112,7 +1112,7 @@ end # isbits types, nothing to copy function Base.copy( set::Union{ - Reals, + RealCone, ZeroCone, NonnegativeCone, NonpositiveCone, @@ -1166,7 +1166,7 @@ function supports_dimension_update(::Type{<:AbstractVectorSet}) return false end function supports_dimension_update( - ::Type{<:Union{Reals,ZeroCone,NonnegativeCone,NonpositiveCone}}, + ::Type{<:Union{RealCone,ZeroCone,NonnegativeCone,NonpositiveCone}}, ) return true end @@ -1178,7 +1178,7 @@ Returns a set with the dimension modified to `new_dim`. """ function update_dimension end function update_dimension( - set::Union{Reals,ZeroCone,NonnegativeCone,NonpositiveCone}, + set::Union{RealCone,ZeroCone,NonnegativeCone,NonpositiveCone}, new_dim, ) return typeof(set)(new_dim) diff --git a/src/variables.jl b/src/variables.jl index 44795e518d..f9ac2778b7 100644 --- a/src/variables.jl +++ b/src/variables.jl @@ -48,7 +48,7 @@ to belong to a set of type `S` either on creation of the variable with [`add_constraint`](@ref). By default, this function falls back to -`supports_add_constrained_variables(model, Reals) && +`supports_add_constrained_variables(model, RealCone) && supports_constraint(model, MOI.SingleVariable, S)` which is the correct definition for most models. @@ -68,7 +68,7 @@ function supports_add_constrained_variable( model::ModelLike, S::Type{<:AbstractScalarSet}, ) - return supports_add_constrained_variables(model, Reals) && + return supports_add_constrained_variables(model, RealCone) && supports_constraint(model, SingleVariable, S) end @@ -104,8 +104,8 @@ variables to belong to a set of type `S` either on creation of the vector of variables with [`add_constrained_variables`](@ref) or after the variable is created with [`add_constraint`](@ref). -By default, if `S` is `Reals` then this function returns `true` and otherwise, -it falls back to `supports_add_constrained_variables(model, Reals) && +By default, if `S` is `RealCone` then this function returns `true` and otherwise, +it falls back to `supports_add_constrained_variables(model, RealCone) && supports_constraint(model, MOI.VectorOfVariables, S)` which is the correct definition for most models. @@ -113,8 +113,8 @@ definition for most models. In the standard conic form (see [Duality](@ref)), the variables are grouped into several cones and the constraints are affine equality constraints. -If `Reals` is not one of the cones supported by the solvers then it needs -to implement `supports_add_constrained_variables(::Optimizer, ::Type{Reals}) = false` +If `RealCone` is not one of the cones supported by the solvers then it needs +to implement `supports_add_constrained_variables(::Optimizer, ::Type{RealCone}) = false` as free variables are not supported. The solvers should then implement `supports_add_constrained_variables(::Optimizer, ::Type{<:SupportedCones}) = true` @@ -145,10 +145,10 @@ function supports_add_constrained_variables( model::ModelLike, S::Type{<:AbstractVectorSet}, ) - return supports_add_constrained_variables(model, Reals) && + return supports_add_constrained_variables(model, RealCone) && supports_constraint(model, VectorOfVariables, S) end -supports_add_constrained_variables(::ModelLike, ::Type{Reals}) = true +supports_add_constrained_variables(::ModelLike, ::Type{RealCone}) = true """ add_constrained_variables( diff --git a/test/Bridges/Variable/free.jl b/test/Bridges/Variable/free.jl index 304db6294e..f281b7b40e 100644 --- a/test/Bridges/Variable/free.jl +++ b/test/Bridges/Variable/free.jl @@ -102,7 +102,7 @@ end loc = MOI.get(bridged_mock, MOI.ListOfConstraintTypesPresent()) @test length(loc) == 2 - @test !((MOI.VectorOfVariables, MOI.Reals) in loc) + @test !((MOI.VectorOfVariables, MOI.RealCone) in loc) @test (MOI.ScalarAffineFunction{Float64}, MOI.GreaterThan{Float64}) in loc @test (MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64}) in loc @test MOI.get(mock, MOI.NumberOfVariables()) == 4 @@ -110,17 +110,17 @@ end vis = MOI.get(bridged_mock, MOI.ListOfVariableIndices()) @test vis == MOI.VariableIndex.([-1, -2]) - cx = MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.Reals}(vis[1].value) + cx = MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.RealCone}(vis[1].value) @test MOI.get(bridged_mock, MOI.ConstraintPrimal(), cx) == [100.0] @test MOI.get(bridged_mock, MOI.ConstraintDual(), cx) == [0.0] - cy = MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.Reals}(vis[2].value) + cy = MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.RealCone}(vis[2].value) @test MOI.get(bridged_mock, MOI.ConstraintPrimal(), cy) == [-100.0] @test MOI.get(bridged_mock, MOI.ConstraintDual(), cy) == [0.0] _test_delete_bridged_variable( bridged_mock, vis[1], - MOI.Reals, + MOI.RealCone, 2, ( (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), @@ -130,7 +130,7 @@ end _test_delete_bridged_variable( bridged_mock, vis[2], - MOI.Reals, + MOI.RealCone, 1, ( (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), @@ -162,10 +162,10 @@ end x, y = MOI.get(bridged_mock, MOI.ListOfVariableIndices()) - cx = MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.Reals}(x.value) + cx = MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.RealCone}(x.value) @test MOI.get(bridged_mock, MOI.ConstraintPrimal(), cx) == [100.0] @test MOI.get(bridged_mock, MOI.ConstraintDual(), cx) == [0.0] - cy = MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.Reals}(y.value) + cy = MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.RealCone}(y.value) @test MOI.get(bridged_mock, MOI.ConstraintPrimal(), cy) == [-100.0] @test MOI.get(bridged_mock, MOI.ConstraintDual(), cy) == [0.0] @@ -273,7 +273,7 @@ end _test_delete_bridged_variable( bridged_mock, vis[1], - MOI.Reals, + MOI.RealCone, 2, ( (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), @@ -285,7 +285,7 @@ end _test_delete_bridged_variable( bridged_mock, vis[2], - MOI.Reals, + MOI.RealCone, 1, ( (MOI.VectorOfVariables, MOI.NonnegativeCone, 0), diff --git a/test/Bridges/lazy_bridge_optimizer.jl b/test/Bridges/lazy_bridge_optimizer.jl index 2f539e4b56..7a9386f97a 100644 --- a/test/Bridges/lazy_bridge_optimizer.jl +++ b/test/Bridges/lazy_bridge_optimizer.jl @@ -91,7 +91,7 @@ end function MOI.supports_constraint( ::StandardLPModel, ::Type{MOI.VectorOfVariables}, - ::Type{MOI.Reals}, + ::Type{MOI.RealCone}, ) return false end @@ -387,7 +387,7 @@ end function MOI.supports_constraint( ::SDPAModel{T}, ::Type{MOI.VectorOfVariables}, - ::Type{MOI.Reals}, + ::Type{MOI.RealCone}, ) where {T} return false end @@ -403,7 +403,7 @@ function MOI.supports_add_constrained_variables( ) return true end -MOI.supports_add_constrained_variables(::SDPAModel, ::Type{MOI.Reals}) = false +MOI.supports_add_constrained_variables(::SDPAModel, ::Type{MOI.RealCone}) = false function MOI.supports( ::SDPAModel{T}, ::MOI.ObjectiveFunction{MOI.ScalarQuadraticFunction{T}}, @@ -498,30 +498,30 @@ end @test !MOI.supports_constraint( model, MOI.VectorOfVariables, - MOI.Reals, + MOI.RealCone, ) @test !MOI.supports_constraint( bridged, MOI.VectorOfVariables, - MOI.Reals, + MOI.RealCone, ) - @test !MOI.supports_add_constrained_variables(bridged, MOI.Reals) + @test !MOI.supports_add_constrained_variables(bridged, MOI.RealCone) @test_throws MOI.UnsupportedConstraint{ MOI.VectorOfVariables, - MOI.Reals, + MOI.RealCone, } MOI.add_variable(bridged) @test_throws MOI.UnsupportedConstraint{ MOI.VectorOfVariables, - MOI.Reals, + MOI.RealCone, } MOI.add_variables(bridged, 2) MOIB.add_bridge(bridged, MOIB.Variable.FreeBridge{T}) @test !MOI.supports_constraint( bridged, MOI.VectorOfVariables, - MOI.Reals, + MOI.RealCone, ) - @test MOI.supports_add_constrained_variables(bridged, MOI.Reals) - @test MOIB.bridge_type(bridged, MOI.Reals) == + @test MOI.supports_add_constrained_variables(bridged, MOI.RealCone) + @test MOIB.bridge_type(bridged, MOI.RealCone) == MOIB.Variable.FreeBridge{T} end @testset "Vectorize" begin @@ -1552,7 +1552,7 @@ MOIU.@model( MOI.Semiinteger, ), ( - MOI.Reals, + MOI.RealCone, MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, @@ -1598,7 +1598,7 @@ MOIU.@model( MOI.Semiinteger, ), ( - MOI.Reals, + MOI.RealCone, MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, diff --git a/test/Bridges/utilities.jl b/test/Bridges/utilities.jl index c05c00c552..6cffdf2c42 100644 --- a/test/Bridges/utilities.jl +++ b/test/Bridges/utilities.jl @@ -109,7 +109,7 @@ function _test_delete_bridged_variable( start_num_bridges = num_bridges() @test MOI.get(m, MOI.NumberOfVariables()) == nvars @test length(MOI.get(m, MOI.ListOfVariableIndices())) == nvars - if S != MOI.Reals + if S != MOI.RealCone F = S <: MOI.AbstractScalarSet ? MOI.SingleVariable : MOI.VectorOfVariables @@ -123,7 +123,7 @@ function _test_delete_bridged_variable( @test_throws MOI.InvalidIndex(vi) MOI.delete(m, vi) @test !MOI.is_valid(m, vi) @test num_bridges() == start_num_bridges - used_bridges - if S != MOI.Reals + if S != MOI.RealCone _test_num_constraints(m, F, S, num_bridged - used_constraints) end @test MOI.get(m, MOI.NumberOfVariables()) == nvars - 1 @@ -154,7 +154,7 @@ function _test_delete_bridged_variables( start_num_bridges = num_bridges() @test MOI.get(m, MOI.NumberOfVariables()) == nvars @test length(MOI.get(m, MOI.ListOfVariableIndices())) == nvars - if S != MOI.Reals + if S != MOI.RealCone F = S <: MOI.AbstractScalarSet ? MOI.SingleVariable : MOI.VectorOfVariables @@ -168,7 +168,7 @@ function _test_delete_bridged_variables( @test_throws MOI.InvalidIndex(vis[1]) MOI.delete(m, vis) @test all(vi -> !MOI.is_valid(m, vi), vis) @test num_bridges() == start_num_bridges - used_bridges - if S != MOI.Reals + if S != MOI.RealCone _test_num_constraints(m, F, S, num_bridged - 1) end @test MOI.get(m, MOI.NumberOfVariables()) == nvars - length(vis) diff --git a/test/FileFormats/CBF/CBF.jl b/test/FileFormats/CBF/CBF.jl index d9e7422d3a..5689fd4160 100644 --- a/test/FileFormats/CBF/CBF.jl +++ b/test/FileFormats/CBF/CBF.jl @@ -29,7 +29,7 @@ function _set_var_and_con_names(model::MOI.ModelLike) push!(single_variable_constraints, (x, MOI.Integer())) end for S in [ - MOI.Reals, + MOI.RealCone, MOI.ZeroCone, MOI.NonnegativeCone, MOI.NonpositiveCone, @@ -216,11 +216,11 @@ const _WRITE_READ_MODELS = [ """, ), ( - "VectorOfVariables in Reals", + "VectorOfVariables in RealCone", """ variables: x, y minobjective: x - c1: [x, y] in Reals(2) + c1: [x, y] in RealCone(2) """, ), ( @@ -248,11 +248,11 @@ const _WRITE_READ_MODELS = [ """, ), ( - "VectorAffineFunction in Reals", + "VectorAffineFunction in RealCone", """ variables: x, y minobjective: 1.2x - c1: [1x, 2y] in Reals(2) + c1: [1x, 2y] in RealCone(2) """, ), ( diff --git a/test/FileFormats/MOF/MOF.jl b/test/FileFormats/MOF/MOF.jl index fa07946087..d06e4f67c2 100644 --- a/test/FileFormats/MOF/MOF.jl +++ b/test/FileFormats/MOF/MOF.jl @@ -532,7 +532,7 @@ function test_Reals() """ variables: x, y, z minobjective: x -c1: [x, y, z] in Reals(3) +c1: [x, y, z] in RealCone(3) """, ["x", "y", "z"], ["c1"], diff --git a/test/Utilities/cachingoptimizer.jl b/test/Utilities/cachingoptimizer.jl index 87911920e8..9f46ac2555 100644 --- a/test/Utilities/cachingoptimizer.jl +++ b/test/Utilities/cachingoptimizer.jl @@ -49,7 +49,7 @@ end function MOI.supports_add_constrained_variables( ::NoFreeVariables, - ::Type{MOI.Reals}, + ::Type{MOI.RealCone}, ) return false end @@ -639,7 +639,7 @@ function test_nonempty_model() end function _constrained_variables_test(model) - @test !MOI.supports_add_constrained_variables(model, MOI.Reals) + @test !MOI.supports_add_constrained_variables(model, MOI.RealCone) @test MOI.supports_add_constrained_variable(model, MOI.ZeroOne) @test !MOI.supports_constraint(model, MOI.SingleVariable, MOI.ZeroOne) @test MOI.supports_add_constrained_variables(model, MOI.NonnegativeCone) diff --git a/test/Utilities/mockoptimizer.jl b/test/Utilities/mockoptimizer.jl index a4b944aadd..af4261eab3 100644 --- a/test/Utilities/mockoptimizer.jl +++ b/test/Utilities/mockoptimizer.jl @@ -20,7 +20,7 @@ end end struct NoFreeModel <: MOI.ModelLike end -MOI.supports_add_constrained_variables(::NoFreeModel, ::Type{MOI.Reals}) = false +MOI.supports_add_constrained_variables(::NoFreeModel, ::Type{MOI.RealCone}) = false @testset "supports_add_constrained_variable" begin optimizer = MOIU.MockOptimizer(MOIU.Model{Float64}()) @@ -47,7 +47,7 @@ MOI.supports_add_constrained_variables(::NoFreeModel, ::Type{MOI.Reals}) = false nofree_optimizer, MOI.NonnegativeCone, ) - @test !MOI.supports_add_constrained_variables(nofree_optimizer, MOI.Reals) + @test !MOI.supports_add_constrained_variables(nofree_optimizer, MOI.RealCone) end @testset "Optimizer attributes" begin diff --git a/test/sets.jl b/test/sets.jl index 4432def9c3..409a9493f9 100644 --- a/test/sets.jl +++ b/test/sets.jl @@ -116,7 +116,7 @@ end function test_sets_DimensionMismatch() for (S, min_dimension) in ( - (MOI.Reals, 0), + (MOI.RealCone, 0), (MOI.ZeroCone, 0), (MOI.NonnegativeCone, 0), (MOI.NonpositiveCone, 0), @@ -183,8 +183,8 @@ end function test_sets_dual_zeroreal() zeros3 = MOI.ZeroCone(3) zeros4 = MOI.ZeroCone(4) - reals3 = MOI.Reals(3) - reals4 = MOI.Reals(4) + reals3 = MOI.RealCone(3) + reals4 = MOI.RealCone(4) _dual_set_test(zeros3, reals3) @test MOI.dual_set(reals3) != zeros4 _dual_set_test(zeros4, reals4) From 1ddbe1db2f82bcd2ea9c7ab1e98923f23d90e54a Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 18 Jul 2021 05:38:04 +0200 Subject: [PATCH 5/5] JuliaFormatter. --- src/Bridges/Constraint/interval.jl | 8 +++++++- src/Bridges/Variable/free.jl | 9 ++++++--- src/Bridges/Variable/zeros.jl | 5 ++++- src/Bridges/bridge_optimizer.jl | 6 ++++-- src/DeprecatedTest/contconic.jl | 18 ++++++++++++++--- src/DeprecatedTest/contlinear.jl | 6 +++++- src/DeprecatedTest/modellike.jl | 32 +++++++++++++++++++++++------- src/FileFormats/CBF/read.jl | 3 ++- src/Test/test_conic.jl | 27 +++++++++++++++++-------- src/Test/test_linear.jl | 3 ++- src/Utilities/DoubleDicts.jl | 8 ++++---- src/Utilities/mockoptimizer.jl | 5 ++++- src/Utilities/sets.jl | 3 ++- src/precompile.jl | 4 +++- 14 files changed, 102 insertions(+), 35 deletions(-) diff --git a/src/Bridges/Constraint/interval.jl b/src/Bridges/Constraint/interval.jl index 54eba8a152..f4a424cdee 100644 --- a/src/Bridges/Constraint/interval.jl +++ b/src/Bridges/Constraint/interval.jl @@ -79,7 +79,13 @@ function concrete_bridge_type( F::Type{<:MOI.AbstractVectorFunction}, ::Type{MOI.ZeroCone}, ) where {T} - return SplitIntervalBridge{T,F,MOI.ZeroCone,MOI.NonnegativeCone,MOI.NonpositiveCone} + return SplitIntervalBridge{ + T, + F, + MOI.ZeroCone, + MOI.NonnegativeCone, + MOI.NonpositiveCone, + } end # Attributes, Bridge acting as a model diff --git a/src/Bridges/Variable/free.jl b/src/Bridges/Variable/free.jl index 3c5a09a805..61a867e47f 100644 --- a/src/Bridges/Variable/free.jl +++ b/src/Bridges/Variable/free.jl @@ -21,7 +21,10 @@ function bridge_constrained_variable( return FreeBridge{T}(variables, constraint) end -function supports_constrained_variable(::Type{<:FreeBridge}, ::Type{MOI.RealCone}) +function supports_constrained_variable( + ::Type{<:FreeBridge}, + ::Type{MOI.RealCone}, +) return true end @@ -136,8 +139,8 @@ function unbridged_map( # `unbridged_map` is required to return a `MOI.ScalarAffineFunction`. func = convert(MOI.ScalarAffineFunction{T}, sv) n = div(length(bridge.variables), 2) - return bridge.variables[i.value] => func, - bridge.variables[n+i.value] => zero(MOI.ScalarAffineFunction{T}) + return bridge.variables[i.value] => + func, bridge.variables[n+i.value] => zero(MOI.ScalarAffineFunction{T}) end function MOI.supports( diff --git a/src/Bridges/Variable/zeros.jl b/src/Bridges/Variable/zeros.jl index 2f965eed73..803c4c60d4 100644 --- a/src/Bridges/Variable/zeros.jl +++ b/src/Bridges/Variable/zeros.jl @@ -27,7 +27,10 @@ function bridge_constrained_variable( return ZerosBridge{T}(MOI.dimension(set)) end -function supports_constrained_variable(::Type{<:ZerosBridge}, ::Type{MOI.ZeroCone}) +function supports_constrained_variable( + ::Type{<:ZerosBridge}, + ::Type{MOI.ZeroCone}, +) return true end diff --git a/src/Bridges/bridge_optimizer.jl b/src/Bridges/bridge_optimizer.jl index c0cc1f3b0f..060ec6a606 100644 --- a/src/Bridges/bridge_optimizer.jl +++ b/src/Bridges/bridge_optimizer.jl @@ -1618,7 +1618,8 @@ end # Variables function MOI.add_variable(b::AbstractBridgeOptimizer) if is_bridged(b, MOI.RealCone) - variables, constraint = MOI.add_constrained_variables(b, MOI.RealCone(1)) + variables, constraint = + MOI.add_constrained_variables(b, MOI.RealCone(1)) @assert isone(length(variables)) return first(variables) else @@ -1628,7 +1629,8 @@ end function MOI.add_variables(b::AbstractBridgeOptimizer, n) if is_bridged(b, MOI.RealCone) - variables, constraint = MOI.add_constrained_variables(b, MOI.RealCone(n)) + variables, constraint = + MOI.add_constrained_variables(b, MOI.RealCone(n)) return variables else return MOI.add_variables(b.model, n) diff --git a/src/DeprecatedTest/contconic.jl b/src/DeprecatedTest/contconic.jl index f6001491aa..d93587c1d7 100644 --- a/src/DeprecatedTest/contconic.jl +++ b/src/DeprecatedTest/contconic.jl @@ -160,7 +160,11 @@ function _lin2test(model::MOI.ModelLike, config::Config, vecofvars::Bool) MOI.NonnegativeCone, ) @test MOI.supports_add_constrained_variables(model, MOI.NonpositiveCone) - @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.ZeroCone) + @test MOI.supports_constraint( + model, + MOI.VectorOfVariables, + MOI.ZeroCone, + ) else @test MOI.supports_constraint( model, @@ -493,7 +497,11 @@ function _norminf1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) ) @test MOI.supports(model, MOI.ObjectiveSense()) if vecofvars - @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.ZeroCone) + @test MOI.supports_constraint( + model, + MOI.VectorOfVariables, + MOI.ZeroCone, + ) else @test MOI.supports_constraint( model, @@ -820,7 +828,11 @@ function _normone1test(model::MOI.ModelLike, config::Config, vecofvars::Bool) ) @test MOI.supports(model, MOI.ObjectiveSense()) if vecofvars - @test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.ZeroCone) + @test MOI.supports_constraint( + model, + MOI.VectorOfVariables, + MOI.ZeroCone, + ) else @test MOI.supports_constraint( model, diff --git a/src/DeprecatedTest/contlinear.jl b/src/DeprecatedTest/contlinear.jl index 45be8bab0d..b85e01f2fa 100644 --- a/src/DeprecatedTest/contlinear.jl +++ b/src/DeprecatedTest/contlinear.jl @@ -2181,7 +2181,11 @@ function linear15test(model::MOI.ModelLike, config::Config{T}) where {T} MOI.ObjectiveFunction{MOI.ScalarAffineFunction{T}}(), ) @test MOI.supports(model, MOI.ObjectiveSense()) - @test MOI.supports_constraint(model, MOI.VectorAffineFunction{T}, MOI.ZeroCone) + @test MOI.supports_constraint( + model, + MOI.VectorAffineFunction{T}, + MOI.ZeroCone, + ) MOI.empty!(model) @test MOI.is_empty(model) x = MOI.add_variables(model, 1) diff --git a/src/DeprecatedTest/modellike.jl b/src/DeprecatedTest/modellike.jl index 8bc069d645..b79d248e32 100644 --- a/src/DeprecatedTest/modellike.jl +++ b/src/DeprecatedTest/modellike.jl @@ -352,8 +352,11 @@ function emptytest(model::MOI.ModelLike) MOI.VectorOfVariables, MOI.NonnegativeCone, ) - vc = - MOI.add_constraint(model, MOI.VectorOfVariables(v), MOI.NonnegativeCone(3)) + vc = MOI.add_constraint( + model, + MOI.VectorOfVariables(v), + MOI.NonnegativeCone(3), + ) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, @@ -389,7 +392,10 @@ function emptytest(model::MOI.ModelLike) ) == 0 @test MOI.get( model, - MOI.NumberOfConstraints{MOI.VectorAffineFunction{Float64},MOI.ZeroCone}(), + MOI.NumberOfConstraints{ + MOI.VectorAffineFunction{Float64}, + MOI.ZeroCone, + }(), ) == 0 @test isempty(MOI.get(model, MOI.ListOfConstraintTypesPresent())) @test !MOI.is_valid(model, v[1]) @@ -711,7 +717,11 @@ function copytest(dest::MOI.ModelLike, src::MOI.ModelLike; copy_names = false) # We test this after the creation of every `SingleVariable` constraint # to ensure a good coverage of corner cases. @test csv.value == w.value - cvv = MOI.add_constraint(src, MOI.VectorOfVariables(v), MOI.NonnegativeCone(3)) + cvv = MOI.add_constraint( + src, + MOI.VectorOfVariables(v), + MOI.NonnegativeCone(3), + ) MOI.set(src, MOI.ConstraintName(), cvv, "cvv") csa = MOI.add_constraint( src, @@ -752,7 +762,11 @@ function copytest(dest::MOI.ModelLike, src::MOI.ModelLike; copy_names = false) MOI.SingleVariable, MOI.EqualTo{Float64}, ) - @test MOI.supports_constraint(dest, MOI.VectorOfVariables, MOI.NonnegativeCone) + @test MOI.supports_constraint( + dest, + MOI.VectorOfVariables, + MOI.NonnegativeCone, + ) @test MOI.supports_constraint( dest, MOI.ScalarAffineFunction{Float64}, @@ -805,7 +819,10 @@ function copytest(dest::MOI.ModelLike, src::MOI.ModelLike; copy_names = false) ) == [dict[csa]] @test MOI.get( dest, - MOI.NumberOfConstraints{MOI.VectorAffineFunction{Float64},MOI.ZeroCone}(), + MOI.NumberOfConstraints{ + MOI.VectorAffineFunction{Float64}, + MOI.ZeroCone, + }(), ) == 1 @test MOI.get( dest, @@ -827,7 +844,8 @@ function copytest(dest::MOI.ModelLike, src::MOI.ModelLike; copy_names = false) MOI.get(dest, MOI.ConstraintName(), dict[cvv]) == dest_name("cvv") @test MOI.get(dest, MOI.ConstraintFunction(), dict[cvv]) == MOI.VectorOfVariables(getindex.(Ref(dict), v)) - @test MOI.get(dest, MOI.ConstraintSet(), dict[cvv]) == MOI.NonnegativeCone(3) + @test MOI.get(dest, MOI.ConstraintSet(), dict[cvv]) == + MOI.NonnegativeCone(3) @test !MOI.supports(dest, MOI.ConstraintName(), typeof(csa)) || MOI.get(dest, MOI.ConstraintName(), dict[csa]) == dest_name("csa") @test MOI.get(dest, MOI.ConstraintFunction(), dict[csa]) ≈ diff --git a/src/FileFormats/CBF/read.jl b/src/FileFormats/CBF/read.jl index edb8c292f9..74dfe8031a 100644 --- a/src/FileFormats/CBF/read.jl +++ b/src/FileFormats/CBF/read.jl @@ -360,7 +360,8 @@ function Base.read!(io::IO, model::Model) # Reverse order of indices. MOI.VectorAffineFunction( [ - MOI.VectorAffineTerm{Float64}(4 - l, t) for l in 1:cone_dim for t in data.row_terms[row_idx+l] + MOI.VectorAffineTerm{Float64}(4 - l, t) for + l in 1:cone_dim for t in data.row_terms[row_idx+l] ], data.row_constants[row_idx.+(3:-1:1)], ) diff --git a/src/Test/test_conic.jl b/src/Test/test_conic.jl index 8cfaf70ead..e50b68b4c2 100644 --- a/src/Test/test_conic.jl +++ b/src/Test/test_conic.jl @@ -414,7 +414,8 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [-4, -3, 16, 0], - (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[7, 2, -4]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => + [[7, 2, -4]], ), ) return @@ -446,8 +447,10 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [-4, -3, 16, 0], - (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => [[0]], - (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => [[0]], + (MOI.VectorAffineFunction{Float64}, MOI.NonnegativeCone) => + [[0]], + (MOI.VectorAffineFunction{Float64}, MOI.NonpositiveCone) => + [[0]], (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[7, 2, -4], [7]], ), @@ -796,7 +799,8 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 0.5, 1], - (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-1], [-1]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => + [[-1], [-1]], (MOI.VectorOfVariables, MOI.NormInfinityCone) => [[1, 0, -1]], ), ) @@ -829,7 +833,8 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 0.5, 1], - (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-1], [-1]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => + [[-1], [-1]], (MOI.VectorAffineFunction{Float64}, MOI.NormInfinityCone) => [[1, 0, -1]], ), @@ -1225,7 +1230,8 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 0.5, 0.5], - (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-1], [0]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => + [[-1], [0]], (MOI.VectorOfVariables, MOI.NormOneCone) => [[1, -1, -1]], ), ) @@ -1257,7 +1263,8 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [1, 0.5, 0.5], - (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[-1], [0]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => + [[-1], [0]], (MOI.VectorAffineFunction{Float64}, MOI.NormOneCone) => [[1, -1, -1]], ), @@ -1532,7 +1539,11 @@ function _test_conic_SecondOrderCone_helper( MOI.SecondOrderCone, ) end - @requires MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.ZeroCone) + @requires MOI.supports_constraint( + model, + MOI.VectorOfVariables, + MOI.ZeroCone, + ) if use_VectorOfVariables xyz, csoc = MOI.add_constrained_variables(model, MOI.SecondOrderCone(3)) diff --git a/src/Test/test_linear.jl b/src/Test/test_linear.jl index c6cfb188b5..4b0e35e687 100644 --- a/src/Test/test_linear.jl +++ b/src/Test/test_linear.jl @@ -2807,7 +2807,8 @@ function setup_test( (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, [0.0], - (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => [[0.0, 0.0]], + (MOI.VectorAffineFunction{Float64}, MOI.ZeroCone) => + [[0.0, 0.0]], ), ) return diff --git a/src/Utilities/DoubleDicts.jl b/src/Utilities/DoubleDicts.jl index a1aec7946e..2bc681f905 100644 --- a/src/Utilities/DoubleDicts.jl +++ b/src/Utilities/DoubleDicts.jl @@ -285,8 +285,8 @@ function Base.iterate(d::AbstractDoubleDict) i_next = iterate(inner) end (i_i, i_state) = i_next - return CI{F,S}(i_i[1]) => typed_value(d, i_i[2], F, S), - (i_state, (o_i, o_state)) + return CI{F,S}(i_i[1]) => + typed_value(d, i_i[2], F, S), (i_state, (o_i, o_state)) end function Base.iterate(d::AbstractDoubleDict, state) (i_state, (o_i, o_state)) = state @@ -302,8 +302,8 @@ function Base.iterate(d::AbstractDoubleDict, state) i_next = iterate(inner) end (i_i, i_state) = i_next - return CI{F,S}(i_i[1]) => typed_value(d, i_i[2], F, S), - (i_state, (o_i, o_state)) + return CI{F,S}(i_i[1]) => + typed_value(d, i_i[2], F, S), (i_state, (o_i, o_state)) end abstract type AbstractWithType{F,S,V,DI,DD} <: AD{CI{F,S},V} end diff --git a/src/Utilities/mockoptimizer.jl b/src/Utilities/mockoptimizer.jl index 8fb64f4e33..c477da2af0 100644 --- a/src/Utilities/mockoptimizer.jl +++ b/src/Utilities/mockoptimizer.jl @@ -835,7 +835,10 @@ function MOI.supports_add_constrained_variables( mock::MockOptimizer, ::Type{MOI.RealCone}, ) - return MOI.supports_add_constrained_variables(mock.inner_model, MOI.RealCone) + return MOI.supports_add_constrained_variables( + mock.inner_model, + MOI.RealCone, + ) end function MOI.copy_to(mock::MockOptimizer, src::MOI.ModelLike; kws...) diff --git a/src/Utilities/sets.jl b/src/Utilities/sets.jl index b876fe8498..3765ede6db 100644 --- a/src/Utilities/sets.jl +++ b/src/Utilities/sets.jl @@ -72,7 +72,8 @@ This is used in the vectorize and scalarize bridges. See also: [`ScalarLinearSet`](@ref). """ -const VectorLinearSet = Union{MOI.ZeroCone,MOI.NonnegativeCone,MOI.NonpositiveCone} +const VectorLinearSet = + Union{MOI.ZeroCone,MOI.NonnegativeCone,MOI.NonpositiveCone} """ vector_set_type(::Type{S}) where {S} diff --git a/src/precompile.jl b/src/precompile.jl index a04e1603dd..a15d33ab32 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -82,5 +82,7 @@ function precompile_model(model, constraints) for (F, S) in constraints precompile_constraint(model, F, S) end - return Base.precompile(Tuple{typeof(add_constrained_variables),model,RealCone}) + return Base.precompile( + Tuple{typeof(add_constrained_variables),model,RealCone}, + ) end