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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion docs/src/manual/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/src/manual/standard_form.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion docs/src/reference/standard_form.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ NormSpectralCone
NormNuclearCone
SOS1
SOS2
IndicatorSet
Indicator
Complements
```

Expand Down
19 changes: 8 additions & 11 deletions src/Bridges/Constraint/indicator_activate_on_zero.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -34,26 +34,23 @@ 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())
# z1 + z2 == 1
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
Expand All @@ -69,22 +66,22 @@ 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

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
10 changes: 5 additions & 5 deletions src/Bridges/Constraint/indicator_sos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -139,15 +139,15 @@ 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

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
Expand Down
8 changes: 4 additions & 4 deletions src/DeprecatedTest/UnitTests/basic_constraint_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
22 changes: 11 additions & 11 deletions src/DeprecatedTest/intlinear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
[
Expand All @@ -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(
Expand Down Expand Up @@ -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(
[
Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand All @@ -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(
[
Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand All @@ -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(
[
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/FileFormats/MOF/MOF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}

Expand Down
2 changes: 1 addition & 1 deletion src/FileFormats/MOF/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/FileFormats/MOF/write.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions src/Test/test_basic_constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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
Loading