Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[breaking] rename SymMatrixSpace to SymmetricMatrixSpace #2889

Merged
merged 1 commit into from
Feb 23, 2022
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
4 changes: 2 additions & 2 deletions docs/src/manual/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -1038,9 +1038,9 @@ julia> @variable(model, x[1:2, 1:2] in PSDCone())
### Example: symmetric variables

As an alternative to the syntax in [Symmetric variables](@ref), declare a matrix
of JuMP variables to be symmetric using [`SymMatrixSpace`](@ref):
of JuMP variables to be symmetric using [`SymmetricMatrixSpace`](@ref):
```jldoctest; setup=:(model=Model())
julia> @variable(model, x[1:2, 1:2] in SymMatrixSpace())
julia> @variable(model, x[1:2, 1:2] in SymmetricMatrixSpace())
2×2 LinearAlgebra.Symmetric{VariableRef, Matrix{VariableRef}}:
x[1,1] x[1,2]
x[1,2] x[2,2]
Expand Down
2 changes: 1 addition & 1 deletion docs/src/reference/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ SOS1
SOS2
SkewSymmetricMatrixSpace
SkewSymmetricMatrixShape
SymMatrixSpace
SymmetricMatrixSpace
moi_set
```

Expand Down
4 changes: 2 additions & 2 deletions src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ The recognized positional arguments in `args` are the following:
It creates a symmetric matrix of variable, that is, it only creates a
new variable for `varname[i,j]` with `i ≤ j` and sets `varname[j,i]` to the
same variable as `varname[i,j]`. It is equivalent to using
`varexpr in SymMatrixSpace()` as `expr`.
`varexpr in SymmetricMatrixSpace()` as `expr`.
* `PSD`: The square matrix of variable is both `Symmetric` and constrained to be
positive semidefinite. It is equivalent to using `varexpr in PSDCone()` as
`expr`.
Expand Down Expand Up @@ -1948,7 +1948,7 @@ macro variable(args...)
"Cannot specify `Symmetric` when the set is already specified, the variable is constrained to belong to `$set`.",
)
end
set = :(JuMP.SymMatrixSpace())
set = :(JuMP.SymmetricMatrixSpace())
end
extra = filter(x -> (x != :PSD && x != :Symmetric), extra) # filter out PSD and sym tag
for ex in extra
Expand Down
14 changes: 9 additions & 5 deletions src/sd.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
"""
SymMatrixSpace()
SymmetricMatrixSpace()

Use in the [`@variable`](@ref) macro to constrain a matrix of variables to be
symmetric.

## Examples

```jldoctest; setup=:(model = Model())
julia> @variable(model, Q[1:2, 1:2] in SymMatrixSpace())
julia> @variable(model, Q[1:2, 1:2] in SymmetricMatrixSpace())
2×2 LinearAlgebra.Symmetric{VariableRef,Array{VariableRef,2}}:
Q[1,1] Q[1,2]
Q[1,2] Q[2,2]
```
"""
struct SymMatrixSpace end
struct SymmetricMatrixSpace end

function SymMatrixSpace()
return error("`SymMatrixSpace` has been renamed to `SymmetricMatrixSpace`")
end

"""
SkewSymmetricMatrixSpace()
Expand Down Expand Up @@ -264,7 +268,7 @@ function _vectorize_variables(_error::Function, matrix::Matrix)
end

"""
build_variable(_error::Function, variables, ::SymMatrixSpace)
build_variable(_error::Function, variables, ::SymmetricMatrixSpace)

Return a `VariablesConstrainedOnCreation` of shape [`SymmetricMatrixShape`](@ref)
creating variables in `MOI.Reals`, i.e. "free" variables unless they are
Expand All @@ -278,7 +282,7 @@ This function is used by the [`@variable`](@ref) macro as follows:
function build_variable(
_error::Function,
variables::Matrix{<:AbstractVariable},
::SymMatrixSpace,
::SymmetricMatrixSpace,
)
n = _square_side(_error, variables)
set = MOI.Reals(MOI.dimension(MOI.PositiveSemidefiniteConeTriangle(n)))
Expand Down