diff --git a/NEWS.md b/NEWS.md index b941676ecf..39f73214e3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,7 +18,8 @@ Breaking renames and type changes: - `Constraint.SOCRBridge` has been renamed to `Constraint.SOCtoRSOCBridge` - `RawParameter` has been renamed to `RawOptimizerAttribute` and now takes `String` instead of `Any` as the only argument -- `Test.TestConfig` has been renamed to `Test.Config` +- `Test.TestConfig` has been renamed to `Test.Config` +- `IndicatorSet` has been renamed to `Indicator` Breaking behavior changes: diff --git a/docs/src/manual/constraints.md b/docs/src/manual/constraints.md index b7a3df04e2..64bc478bda 100644 --- a/docs/src/manual/constraints.md +++ b/docs/src/manual/constraints.md @@ -172,7 +172,7 @@ where ``\mathcal{E}`` is the exponential cone (see [`ExponentialCone`](@ref)), | ``x_i \in \{0\} \cup \{l,l+1,\ldots,u-1,u\}`` | `SingleVariable` | `Semiinteger` | | At most one component of ``x`` can be nonzero | `VectorOfVariables` | `SOS1` | | At most two components of ``x`` can be nonzero, and if so they must be adjacent components | `VectorOfVariables` | `SOS2` | -| ``y = 1 \implies a^T x \in S`` | `VectorAffineFunction` | `IndicatorSet` | +| ``y = 1 \implies a^T x \in S`` | `VectorAffineFunction` | `Indicator` | ## JuMP mapping diff --git a/docs/src/manual/standard_form.md b/docs/src/manual/standard_form.md index e4600da18f..4a0fcc9343 100644 --- a/docs/src/manual/standard_form.md +++ b/docs/src/manual/standard_form.md @@ -149,7 +149,7 @@ or solver developers. A special ordered set of Type I. * [`SOS2(weights)`](@ref MathOptInterface.SOS2): A special ordered set of Type II. -* [`IndicatorSet(set)`](@ref MathOptInterface.IndicatorSet): +* [`Indicator(set)`](@ref MathOptInterface.Indicator): A set to specify indicator constraints. * [`Complements`](@ref MathOptInterface.Complements): A set for mixed complementarity constraints. diff --git a/docs/src/reference/standard_form.md b/docs/src/reference/standard_form.md index d3ad803b4f..c0b33bfad3 100644 --- a/docs/src/reference/standard_form.md +++ b/docs/src/reference/standard_form.md @@ -91,7 +91,7 @@ NormSpectralCone NormNuclearCone SOS1 SOS2 -IndicatorSet +Indicator Complements ``` diff --git a/src/Bridges/Constraint/indicator_activate_on_zero.jl b/src/Bridges/Constraint/indicator_activate_on_zero.jl index f787e1f86b..44d3081bbb 100644 --- a/src/Bridges/Constraint/indicator_activate_on_zero.jl +++ b/src/Bridges/Constraint/indicator_activate_on_zero.jl @@ -21,7 +21,7 @@ struct IndicatorActiveOnFalseBridge{ } indicator_cons_index::MOI.ConstraintIndex{ F, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,S}, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,S}, } end @@ -34,7 +34,7 @@ function bridge_constraint( S<:MOI.AbstractScalarSet, T<:Real, F, - IS<:MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO,S}, + IS<:MOI.Indicator{MOI.ACTIVATE_ON_ZERO,S}, } f_scalars = MOIU.eachscalar(f) z2, zo_cons = MOI.add_constrained_variable(model, MOI.ZeroOne()) @@ -42,18 +42,15 @@ function bridge_constraint( z1_z2 = MOIU.operate(+, T, f_scalars[1], MOI.SingleVariable(z2)) dcons = MOIU.normalize_and_add_constraint(model, z1_z2, MOI.EqualTo(one(T))) f2 = MOIU.operate(vcat, T, MOI.SingleVariable(z2), f_scalars[2]) - ci = MOI.add_constraint( - model, - f2, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(s.set), - ) + ci = + MOI.add_constraint(model, f2, MOI.Indicator{MOI.ACTIVATE_ON_ONE}(s.set)) return IndicatorActiveOnFalseBridge{T,F,S}(z2, zo_cons, dcons, ci) end function MOI.supports_constraint( ::Type{<:IndicatorActiveOnFalseBridge{T}}, ::Type{<:MOI.VectorAffineFunction}, - ::Type{<:MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO}}, + ::Type{<:MOI.Indicator{MOI.ACTIVATE_ON_ZERO}}, ) where {T} return true end @@ -69,14 +66,14 @@ function MOIB.added_constraint_types( ) where {T,F,S} return [ (MOI.ScalarAffineFunction{T}, MOI.EqualTo{T}), - (F, MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,S}), + (F, MOI.Indicator{MOI.ACTIVATE_ON_ONE,S}), ] end function concrete_bridge_type( ::Type{<:IndicatorActiveOnFalseBridge{T}}, ::Type{F}, - ::Type{MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO,S}}, + ::Type{MOI.Indicator{MOI.ACTIVATE_ON_ZERO,S}}, ) where {T,F<:MOI.VectorAffineFunction,S<:MOI.AbstractScalarSet} return IndicatorActiveOnFalseBridge{T,F,S} end @@ -84,7 +81,7 @@ end function concrete_bridge_type( ::Type{<:IndicatorActiveOnFalseBridge}, ::Type{F}, - ::Type{MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO,S}}, + ::Type{MOI.Indicator{MOI.ACTIVATE_ON_ZERO,S}}, ) where {F<:MOI.VectorAffineFunction,S<:MOI.AbstractScalarSet} return IndicatorActiveOnFalseBridge{Float64,F,S} end diff --git a/src/Bridges/Constraint/indicator_sos.jl b/src/Bridges/Constraint/indicator_sos.jl index 2f74789e7a..266263e821 100644 --- a/src/Bridges/Constraint/indicator_sos.jl +++ b/src/Bridges/Constraint/indicator_sos.jl @@ -30,7 +30,7 @@ function bridge_constraint( ::Type{IndicatorSOS1Bridge{T,BC,MaybeBC}}, model::MOI.ModelLike, f::MOI.VectorAffineFunction{T}, - s::MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,BC}, + s::MOI.Indicator{MOI.ACTIVATE_ON_ONE,BC}, ) where {T<:Real,BC,MaybeBC} f_scalars = MOIU.eachscalar(f) (w, bound_constraint) = _add_bound_constraint!(model, BC) @@ -68,7 +68,7 @@ end function MOI.supports_constraint( ::Type{<:IndicatorSOS1Bridge}, ::Type{<:MOI.AbstractVectorFunction}, - ::Type{<:MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,<:MOI.AbstractScalarSet}}, + ::Type{<:MOI.Indicator{MOI.ACTIVATE_ON_ONE,<:MOI.AbstractScalarSet}}, ) return true end @@ -78,7 +78,7 @@ function MOI.get( attr::MOI.ConstraintSet, b::IndicatorSOS1Bridge, ) - return MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}( + return MOI.Indicator{MOI.ACTIVATE_ON_ONE}( MOI.get(model, attr, b.linear_constraint_index), ) end @@ -139,7 +139,7 @@ end function concrete_bridge_type( ::Type{<:IndicatorSOS1Bridge{T}}, ::Type{<:MOI.AbstractVectorFunction}, - ::Type{MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,S}}, + ::Type{MOI.Indicator{MOI.ACTIVATE_ON_ONE,S}}, ) where {T,S<:Union{MOI.LessThan,MOI.GreaterThan}} return IndicatorSOS1Bridge{T,S,MOI.ConstraintIndex{MOI.SingleVariable,S}} end @@ -147,7 +147,7 @@ end function concrete_bridge_type( ::Type{<:IndicatorSOS1Bridge{T}}, ::Type{<:MOI.AbstractVectorFunction}, - ::Type{MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,S}}, + ::Type{MOI.Indicator{MOI.ACTIVATE_ON_ONE,S}}, ) where {T,S<:MOI.AbstractScalarSet} return IndicatorSOS1Bridge{T,S,Nothing} end diff --git a/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl b/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl index eebe5d891a..bc3422e7da 100644 --- a/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl +++ b/src/DeprecatedTest/UnitTests/basic_constraint_tests.jl @@ -143,19 +143,19 @@ const BasicConstraintTests = Dict( (MOI.VectorAffineFunction{Float64}, MOI.PositiveSemidefiniteConeSquare) => (dummy_vector_affine, 9, MOI.PositiveSemidefiniteConeSquare(3)), ( MOI.VectorAffineFunction{Float64}, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, ) => ( dummy_vector_affine, 2, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(3.0)), + MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(3.0)), ), ( MOI.VectorAffineFunction{Float64}, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.GreaterThan{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.GreaterThan{Float64}}, ) => ( dummy_vector_affine, 2, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.GreaterThan(3.0)), + MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.GreaterThan(3.0)), ), (MOI.VectorQuadraticFunction{Float64}, MOI.Zeros) => (dummy_vector_quadratic, 2, MOI.Zeros(2)), diff --git a/src/DeprecatedTest/intlinear.jl b/src/DeprecatedTest/intlinear.jl index 852ae5e7a9..be9d998617 100644 --- a/src/DeprecatedTest/intlinear.jl +++ b/src/DeprecatedTest/intlinear.jl @@ -551,7 +551,7 @@ function indicator1_test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, ) x1 = MOI.add_variable(model) x2 = MOI.add_variable(model) @@ -566,7 +566,7 @@ function indicator1_test(model::MOI.ModelLike, config::Config) ], [0.0, 0.0], ) - iset1 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(8.0)) + iset1 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(8.0)) MOI.add_constraint(model, f1, iset1) f2 = MOI.VectorAffineFunction( [ @@ -576,7 +576,7 @@ function indicator1_test(model::MOI.ModelLike, config::Config) ], [0.0, 0.0], ) - iset2 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(9.0)) + iset2 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(9.0)) MOI.add_constraint(model, f2, iset2) # Additional regular constraint. MOI.add_constraint( @@ -648,7 +648,7 @@ function indicator2_test(model::MOI.ModelLike, config::Config) ], [0.0, 0.0], ) - iset1 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(8.0)) + iset1 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(8.0)) MOI.add_constraint(model, f1, iset1) f2 = MOI.VectorAffineFunction( [ @@ -658,7 +658,7 @@ function indicator2_test(model::MOI.ModelLike, config::Config) ], [0.0, 0.0], ) - iset2 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(9.0)) + iset2 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(9.0)) MOI.add_constraint(model, f2, iset2) # additional regular constraint MOI.add_constraint( @@ -737,7 +737,7 @@ function indicator3_test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, ) x1 = MOI.add_variable(model) x2 = MOI.add_variable(model) @@ -754,7 +754,7 @@ function indicator3_test(model::MOI.ModelLike, config::Config) ], [0.0, 0.0], ) - iset1 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO}(MOI.LessThan(8.0)) + iset1 = MOI.Indicator{MOI.ACTIVATE_ON_ZERO}(MOI.LessThan(8.0)) MOI.add_constraint(model, f1, iset1) f2 = MOI.VectorAffineFunction( [ @@ -764,7 +764,7 @@ function indicator3_test(model::MOI.ModelLike, config::Config) ], [0.0, 0.0], ) - iset2 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(9.0)) + iset2 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(9.0)) MOI.add_constraint(model, f2, iset2) # Additional regular constraint. MOI.add_constraint( @@ -842,7 +842,7 @@ function indicator4_test(model::MOI.ModelLike, config::Config) @test MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, ) x1 = MOI.add_variable(model) x2 = MOI.add_variable(model) @@ -857,7 +857,7 @@ function indicator4_test(model::MOI.ModelLike, config::Config) ], [0.0, -1.0], ) - iset1 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(7.0)) + iset1 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(7.0)) MOI.add_constraint(model, f1, iset1) f2 = MOI.VectorAffineFunction( [ @@ -867,7 +867,7 @@ function indicator4_test(model::MOI.ModelLike, config::Config) ], [0.0, 1.0], ) - iset2 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(10.0)) + iset2 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(10.0)) MOI.add_constraint(model, f2, iset2) # Additional regular constraint. MOI.add_constraint( diff --git a/src/FileFormats/MOF/MOF.jl b/src/FileFormats/MOF/MOF.jl index 6aa24518ac..a42c86dd04 100644 --- a/src/FileFormats/MOF/MOF.jl +++ b/src/FileFormats/MOF/MOF.jl @@ -64,7 +64,7 @@ MOI.Utilities.@model( (MOI.VectorAffineFunction, MOI.VectorQuadraticFunction) ) -# IndicatorSet is handled by UniversalFallback. +# Indicator is handled by UniversalFallback. const Model = MOI.Utilities.UniversalFallback{InnerModel{Float64}} diff --git a/src/FileFormats/MOF/read.jl b/src/FileFormats/MOF/read.jl index 15f9bbafb9..ee4b15f0af 100644 --- a/src/FileFormats/MOF/read.jl +++ b/src/FileFormats/MOF/read.jl @@ -477,5 +477,5 @@ function set_to_moi(::Val{:IndicatorSet}, object::Object) @assert object["activate_on"]::String == "zero" MOI.ACTIVATE_ON_ZERO end - return MOI.IndicatorSet{indicator}(set) + return MOI.Indicator{indicator}(set) end diff --git a/src/FileFormats/MOF/write.jl b/src/FileFormats/MOF/write.jl index 675eb3f3c8..05c971a67e 100644 --- a/src/FileFormats/MOF/write.jl +++ b/src/FileFormats/MOF/write.jl @@ -295,7 +295,7 @@ head_name(::Type{<:MOI.SOS1}) = "SOS1" head_name(::Type{<:MOI.SOS2}) = "SOS2" function moi_to_object( - set::MOI.IndicatorSet{I,S}, + set::MOI.Indicator{I,S}, name_map::Dict{MOI.VariableIndex,String}, ) where {I,S} @assert I == MOI.ACTIVATE_ON_ONE || I == MOI.ACTIVATE_ON_ZERO diff --git a/src/Test/test_basic_constraint.jl b/src/Test/test_basic_constraint.jl index 494a22a3bc..e37c4c4d5b 100644 --- a/src/Test/test_basic_constraint.jl +++ b/src/Test/test_basic_constraint.jl @@ -104,16 +104,14 @@ _set(::Type{MOI.RootDetConeTriangle}) = MOI.RootDetConeTriangle(3) _set(::Type{MOI.RootDetConeSquare}) = MOI.RootDetConeSquare(3) _set(::Type{MOI.Complements}) = MOI.Complements(2) -function _set( - ::Type{MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}}, -) - return MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(3.0)) +function _set(::Type{MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}}) + return MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(3.0)) end function _set( - ::Type{MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.GreaterThan{Float64}}}, + ::Type{MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.GreaterThan{Float64}}}, ) - return MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.GreaterThan(3.0)) + return MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.GreaterThan(3.0)) end function _basic_constraint_test_helper( @@ -281,7 +279,7 @@ function test_basic_VectorAffineFunction_Indicator_LessThan( model, config, MOI.VectorAffineFunction, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, ) return end @@ -294,7 +292,7 @@ function test_basic_VectorAffineFunction_Indicator_GreaterThan( model, config, MOI.VectorAffineFunction, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.GreaterThan{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.GreaterThan{Float64}}, ) return end diff --git a/src/Test/test_linear.jl b/src/Test/test_linear.jl index 045ab03889..f71ea70f27 100644 --- a/src/Test/test_linear.jl +++ b/src/Test/test_linear.jl @@ -3497,7 +3497,7 @@ function test_linear_Indicator_integration(model::MOI.ModelLike, config::Config) @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, ) x1 = MOI.add_variable(model) x2 = MOI.add_variable(model) @@ -3512,7 +3512,7 @@ function test_linear_Indicator_integration(model::MOI.ModelLike, config::Config) ], [0.0, 0.0], ) - iset1 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(8.0)) + iset1 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(8.0)) MOI.add_constraint(model, f1, iset1) f2 = MOI.VectorAffineFunction( [ @@ -3522,7 +3522,7 @@ function test_linear_Indicator_integration(model::MOI.ModelLike, config::Config) ], [0.0, 0.0], ) - iset2 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(9.0)) + iset2 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(9.0)) MOI.add_constraint(model, f2, iset2) # Additional regular constraint. MOI.add_constraint( @@ -3604,7 +3604,7 @@ function test_linear_Indicator_ON_ONE(model::MOI.ModelLike, config::Config) ], [0.0, 0.0], ) - iset1 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(8.0)) + iset1 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(8.0)) MOI.add_constraint(model, f1, iset1) f2 = MOI.VectorAffineFunction( [ @@ -3614,7 +3614,7 @@ function test_linear_Indicator_ON_ONE(model::MOI.ModelLike, config::Config) ], [0.0, 0.0], ) - iset2 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(9.0)) + iset2 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(9.0)) MOI.add_constraint(model, f2, iset2) # additional regular constraint MOI.add_constraint( @@ -3703,7 +3703,7 @@ function test_linear_Indicator_ON_ZERO(model::MOI.ModelLike, config::Config) @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, ) x1 = MOI.add_variable(model) x2 = MOI.add_variable(model) @@ -3720,7 +3720,7 @@ function test_linear_Indicator_ON_ZERO(model::MOI.ModelLike, config::Config) ], [0.0, 0.0], ) - iset1 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO}(MOI.LessThan(8.0)) + iset1 = MOI.Indicator{MOI.ACTIVATE_ON_ZERO}(MOI.LessThan(8.0)) MOI.add_constraint(model, f1, iset1) f2 = MOI.VectorAffineFunction( [ @@ -3730,7 +3730,7 @@ function test_linear_Indicator_ON_ZERO(model::MOI.ModelLike, config::Config) ], [0.0, 0.0], ) - iset2 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(9.0)) + iset2 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(9.0)) MOI.add_constraint(model, f2, iset2) # Additional regular constraint. MOI.add_constraint( @@ -3822,7 +3822,7 @@ function test_linear_Indicator_constant_term( @requires MOI.supports_constraint( model, MOI.VectorAffineFunction{Float64}, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, ) x1 = MOI.add_variable(model) x2 = MOI.add_variable(model) @@ -3837,7 +3837,7 @@ function test_linear_Indicator_constant_term( ], [0.0, -1.0], ) - iset1 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(7.0)) + iset1 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(7.0)) MOI.add_constraint(model, f1, iset1) f2 = MOI.VectorAffineFunction( [ @@ -3847,7 +3847,7 @@ function test_linear_Indicator_constant_term( ], [0.0, 1.0], ) - iset2 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(10.0)) + iset2 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(10.0)) MOI.add_constraint(model, f2, iset2) # Additional regular constraint. MOI.add_constraint( diff --git a/src/Utilities/model.jl b/src/Utilities/model.jl index bb7d389217..4abfb856de 100644 --- a/src/Utilities/model.jl +++ b/src/Utilities/model.jl @@ -886,10 +886,10 @@ for (loop_name, loop_super_type) in [ end end -const LessThanIndicatorSetOne{T} = - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.LessThan{T}} -const LessThanIndicatorSetZero{T} = - MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO,MOI.LessThan{T}} +const LessThanIndicatorOne{T} = + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.LessThan{T}} +const LessThanIndicatorZero{T} = + MOI.Indicator{MOI.ACTIVATE_ON_ZERO,MOI.LessThan{T}} @model( Model, @@ -930,8 +930,8 @@ const LessThanIndicatorSetZero{T} = MOI.DualPowerCone, MOI.SOS1, MOI.SOS2, - LessThanIndicatorSetOne, - LessThanIndicatorSetZero, + LessThanIndicatorOne, + LessThanIndicatorZero, ), (), (MOI.ScalarAffineFunction, MOI.ScalarQuadraticFunction), diff --git a/src/sets.jl b/src/sets.jl index f94a94c13e..9485006643 100644 --- a/src/sets.jl +++ b/src/sets.jl @@ -986,7 +986,7 @@ dimension(s::Union{SOS1,SOS2}) = length(s.weights) ActivationCondition Activation condition for an indicator constraint. -The enum value is used as first type parameter of `IndicatorSet{A,S}`. +The enum value is used as first type parameter of `Indicator{A,S}`. """ @enum ActivationCondition begin ACTIVATE_ON_ZERO @@ -994,7 +994,7 @@ The enum value is used as first type parameter of `IndicatorSet{A,S}`. end """ - IndicatorSet{A, S <: AbstractScalarSet}(set::S) + Indicator{A, S <: AbstractScalarSet}(set::S) ``\\{(y, x) \\in \\{0, 1\\} \\times \\mathbb{R}^n : y = 0 \\implies x \\in set\\}`` when `A` is `ACTIVATE_ON_ZERO` and @@ -1003,7 +1003,7 @@ when `A` is `ACTIVATE_ON_ONE`. `S` has to be a sub-type of `AbstractScalarSet`. `A` is one of the value of the `ActivationCond` enum. -`IndicatorSet` is used with a `VectorAffineFunction` holding +`Indicator` is used with a `VectorAffineFunction` holding the indicator variable first. Example: ``\\{(y, x) \\in \\{0, 1\\} \\times \\mathbb{R}^2 : y = 1 \\implies x_1 + x_2 \\leq 9 \\} `` @@ -1017,26 +1017,23 @@ f = MOI.VectorAffineFunction( [0.0, 0.0], ) -indicator_set = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(9.0)) +indicator_set = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(9.0)) MOI.add_constraint(model, f, indicator_set) ``` """ -struct IndicatorSet{A,S<:AbstractScalarSet} <: AbstractVectorSet +struct Indicator{A,S<:AbstractScalarSet} <: AbstractVectorSet set::S - IndicatorSet{A}(set::S) where {A,S<:AbstractScalarSet} = new{A,S}(set) + Indicator{A}(set::S) where {A,S<:AbstractScalarSet} = new{A,S}(set) end -dimension(::IndicatorSet) = 2 +dimension(::Indicator) = 2 -function Base.copy(set::IndicatorSet{A,S}) where {A,S} - return IndicatorSet{A}(copy(set.set)) +function Base.copy(set::Indicator{A,S}) where {A,S} + return Indicator{A}(copy(set.set)) end -function Base.:(==)( - set1::IndicatorSet{A,S}, - set2::IndicatorSet{A,S}, -) where {A,S} +function Base.:(==)(set1::Indicator{A,S}, set2::Indicator{A,S}) where {A,S} return set1.set == set2.set end diff --git a/test/Bridges/Constraint/indicator_activate_on_zero.jl b/test/Bridges/Constraint/indicator_activate_on_zero.jl index 82e8954d17..d61175b825 100644 --- a/test/Bridges/Constraint/indicator_activate_on_zero.jl +++ b/test/Bridges/Constraint/indicator_activate_on_zero.jl @@ -48,7 +48,7 @@ function test_indicator_activate_on_zero() ], [0.0, 0.0], ) - iset1 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO}(MOI.LessThan(8.0)) + iset1 = MOI.Indicator{MOI.ACTIVATE_ON_ZERO}(MOI.LessThan(8.0)) BT = MOI.Bridges.Constraint.concrete_bridge_type( MOI.Bridges.Constraint.IndicatorActiveOnFalseBridge{Float64}, typeof(f1), diff --git a/test/Bridges/Constraint/indicator_sos.jl b/test/Bridges/Constraint/indicator_sos.jl index c87294dfd9..1495a0e497 100644 --- a/test/Bridges/Constraint/indicator_sos.jl +++ b/test/Bridges/Constraint/indicator_sos.jl @@ -43,7 +43,7 @@ function test_indicator_by_SOS1() ], [0.0, 0.0], ) - iset1 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(8.0)) + iset1 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(8.0)) f2 = MOI.VectorAffineFunction( [ @@ -53,7 +53,7 @@ function test_indicator_by_SOS1() ], [0.0, 0.0], ) - iset2 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.EqualTo(9.0)) + iset2 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.EqualTo(9.0)) f3 = MOI.VectorAffineFunction( [ @@ -62,7 +62,7 @@ function test_indicator_by_SOS1() ], [0.0, 0.0], ) - iset3 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.GreaterThan(5.0)) + iset3 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.GreaterThan(5.0)) BT1 = MOI.Bridges.Constraint.concrete_bridge_type( MOI.Bridges.Constraint.IndicatorSOS1Bridge{Float64}, @@ -217,7 +217,7 @@ function test_model_equality() ], [0.0, 0.0], ) - iset = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(8.0)) + iset = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(8.0)) ci = MOI.add_constraint(bridged_mock, f, iset) @test length(MOI.get(mock, MOI.ListOfVariableIndices())) == 3 MOI.set( @@ -315,7 +315,7 @@ function test_getting_primal_attributes() ], [0.0, 0.0], ) - iset = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(8.0)) + iset = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(8.0)) BT = MOI.Bridges.Constraint.concrete_bridge_type( MOI.Bridges.Constraint.IndicatorSOS1Bridge{Float64}, typeof(f), @@ -341,7 +341,7 @@ function test_getting_primal_attributes() MOI.get(mock, MOI.ConstraintPrimalStart(), bridge1) .≈ (1.0, affine_value - w_value), ) - iseteq = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.EqualTo(8.0)) + iseteq = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.EqualTo(8.0)) BT = MOI.Bridges.Constraint.concrete_bridge_type( MOI.Bridges.Constraint.IndicatorSOS1Bridge{Float64}, typeof(f), diff --git a/test/Bridges/lazy_bridge_optimizer.jl b/test/Bridges/lazy_bridge_optimizer.jl index cf12e89532..e46ef84c57 100644 --- a/test/Bridges/lazy_bridge_optimizer.jl +++ b/test/Bridges/lazy_bridge_optimizer.jl @@ -1535,8 +1535,8 @@ function MOI.Bridges.Constraint.concrete_bridge_type( return BridgeAddingNoConstraint{T} end -const LessThanIndicatorSetOne{T} = - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.LessThan{T}} +const LessThanIndicatorOne{T} = + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.LessThan{T}} MOI.Utilities.@model( ModelNoZeroIndicator, @@ -1576,7 +1576,7 @@ MOI.Utilities.@model( MOI.DualPowerCone, MOI.SOS1, MOI.SOS2, - LessThanIndicatorSetOne, + LessThanIndicatorOne, ), (), (MOI.ScalarAffineFunction, MOI.ScalarQuadraticFunction), @@ -1865,12 +1865,12 @@ function test_supports() @test !MOI.supports_constraint( mock_indicator, MOI.VectorAffineFunction{Float64}, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO,MOI.LessThan{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ZERO,MOI.LessThan{Float64}}, ) @test MOI.supports_constraint( full_bridged_mock_indicator, MOI.VectorAffineFunction{Float64}, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO,MOI.LessThan{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ZERO,MOI.LessThan{Float64}}, ) mock_sos_indicator = @@ -1880,22 +1880,22 @@ function test_supports() @test !MOI.supports_constraint( mock_sos_indicator, MOI.VectorAffineFunction{Float64}, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, ) @test !MOI.supports_constraint( mock_sos_indicator, MOI.VectorAffineFunction{Float64}, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.EqualTo{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.EqualTo{Float64}}, ) @test MOI.supports_constraint( full_bridged_mock_sos_indicator, MOI.VectorAffineFunction{Float64}, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.LessThan{Float64}}, ) @test MOI.supports_constraint( full_bridged_mock_sos_indicator, MOI.VectorAffineFunction{Float64}, - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE,MOI.EqualTo{Float64}}, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.EqualTo{Float64}}, ) for T in [Float64, Int] no_variable_mock = MOI.Utilities.MockOptimizer(NoVariableModel{T}()) diff --git a/test/FileFormats/MOF/MOF.jl b/test/FileFormats/MOF/MOF.jl index 13142ca2a0..9d8e5f4718 100644 --- a/test/FileFormats/MOF/MOF.jl +++ b/test/FileFormats/MOF/MOF.jl @@ -763,12 +763,12 @@ c1: [t, x1, x2, x3, x4] in RootDetConeSquare(2) ) end -function test_IndicatorSet() +function test_Indicator() _test_model_equality( """ variables: x, y minobjective: x -c1: [x, y] in IndicatorSet{ACTIVATE_ON_ONE}(GreaterThan(1.0)) +c1: [x, y] in Indicator{ACTIVATE_ON_ONE}(GreaterThan(1.0)) """, ["x", "y"], ["c1"], @@ -778,7 +778,7 @@ c1: [x, y] in IndicatorSet{ACTIVATE_ON_ONE}(GreaterThan(1.0)) """ variables: x, y minobjective: x -c1: [x, y] in IndicatorSet{ACTIVATE_ON_ZERO}(GreaterThan(1.0)) +c1: [x, y] in Indicator{ACTIVATE_ON_ZERO}(GreaterThan(1.0)) """, ["x", "y"], ["c1"], diff --git a/test/sets.jl b/test/sets.jl index 7f8fcab254..b2c5a16ca2 100644 --- a/test/sets.jl +++ b/test/sets.jl @@ -46,7 +46,7 @@ function test_sets_equals() @test S(a(), a()) != S(b(), b()) @test S(a(), a()) == S(a(), a()) end - S = MOI.IndicatorSet + S = MOI.Indicator A() = MOI.LessThan(a()) B() = MOI.LessThan(b()) @test S{MOI.ACTIVATE_ON_ZERO}(A()) == S{MOI.ACTIVATE_ON_ZERO}(A()) @@ -70,15 +70,15 @@ function test_sets_sos2_copy() end function test_sets_indicator_copy() - s1 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(4.0)) - s2 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO}(MOI.GreaterThan(4.0)) + s1 = MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(4.0)) + s2 = MOI.Indicator{MOI.ACTIVATE_ON_ZERO}(MOI.GreaterThan(4.0)) s1_copy = copy(s1) s2_copy = copy(s2) - @test s1_copy isa MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE} + @test s1_copy isa MOI.Indicator{MOI.ACTIVATE_ON_ONE} @test s1 == s1_copy - @test s2_copy isa MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO} + @test s2_copy isa MOI.Indicator{MOI.ACTIVATE_ON_ZERO} @test s2 == s2_copy - s3 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO}(MutLessThan(4.0)) + s3 = MOI.Indicator{MOI.ACTIVATE_ON_ZERO}(MutLessThan(4.0)) s3_copy = copy(s3) @test s3.set.upper ≈ 4.0 s3_copy.set.upper = 5.0 @@ -109,7 +109,7 @@ function test_sets_dimension() @test MOI.dimension(MOI.SOS1([1.0, 2.0])) == 2 @test MOI.dimension(MOI.SOS2([1.0, 2.0])) == 2 @test MOI.dimension( - MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(1.0)), + MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(1.0)), ) == 2 @test MOI.dimension(MOI.Complements(10)) == 10 end