Skip to content

Commit

Permalink
[docs] update docstrings for SOS1 and SOS2 (#3565)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Nov 7, 2023
1 parent 7f72a6a commit 4d3eab4
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions src/sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,19 @@ struct RotatedSecondOrderCone <: AbstractVectorSet end
moi_set(::RotatedSecondOrderCone, dim::Int) = MOI.RotatedSecondOrderCone(dim)

"""
SOS1
SOS1 (Special Ordered Sets type 1) object than can be used to constrain a
vector `x` to a set where at most 1 variable can take a non-zero value, all
others being at 0.
The `weights`, when specified, induce an ordering of the variables; as such,
they should be unique values. The *k*th element in the set corresponds to the
*k*th weight in `weights`. See [here](http://lpsolve.sourceforge.net/5.5/SOS.htm)
for a description of SOS constraints and their potential uses.
This is a shortcut for the `MathOptInterface.SOS1` set.
SOS1(weights = Real[])
The SOS1 (Special Ordered Set of Type 1) set constrains a vector `x` to the set
where at most one variable can take a non-zero value, and all other elements are
zero.
The `weights` vector, if specified, induces an ordering of the variables; as
such, it should contain unique values. The `weights` vector must have the same
number of elements as the vector `x`, and the element `weights[i]` corresponds
to element `x[i]`. If not provided, the `weights` vector defaults to
`weights[i] = i`.
This is a shortcut for the [`MOI.SOS1`](@ref) set.
"""
struct SOS1{T} <: AbstractVectorSet
weights::Vector{T}
Expand All @@ -213,17 +216,20 @@ function moi_set(set::SOS1{T}, dim::Int) where {T}
end

"""
SOS2
SOS1 (Special Ordered Sets type 2) object than can be used to constrain a
vector `x` to a set where at most 2 variables can take a non-zero value, all
others being at 0. In addition, if two are non-zero these must be consecutive
in their ordering.
The `weights` induce an ordering of the variables; as such, they should be unique
values. The *k*th element in the set corresponds to the *k*th weight in `weights`.
See [here](http://lpsolve.sourceforge.net/5.5/SOS.htm) for a description of SOS
constraints and their potential uses.
This is a shortcut for the `MathOptInterface.SOS2` set.
SOS2(weights = Real[])
The SOS2 (Special Ordered Set of Type 2) set constrains a vector `x` to the set
where at most two variables can take a non-zero value, and all other elements
are zero. In addition, the two non-zero values must be consecutive given the
ordering of the `x` vector induced by `weights`.
The `weights` vector, if specified, induces an ordering of the variables; as
such, it must contain unique values. The `weights` vector must have the same
number of elements as the vector `x`, and the element `weights[i]` corresponds
to element `x[i]`. If not provided, the `weights` vector defaults to
`weights[i] = i`.
This is a shortcut for the [`MOI.SOS2`](@ref) set.
"""
struct SOS2{T} <: AbstractVectorSet
weights::Vector{T}
Expand Down

0 comments on commit 4d3eab4

Please sign in to comment.