Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Jun 26, 2024
1 parent 2f4e05c commit a523624
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion docs/src/manual/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ The syntax `x >= y` is ambiguous for matrices because we cannot tell if
you intend a positive semidefinite constraint or an an elementwise
inequality.
To create a positive semidefinite constraint, pass `PSDCone()`:
To create a positive semidefinite constraint, pass `PSDCone()` or
`HermitianPSDCone()`:
```julia
@constraint(model, x >= y, PSDCone())
Expand Down
13 changes: 9 additions & 4 deletions src/macros/@constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ end

function build_constraint(
error_fn::Function,
::AbstractMatrix,
::Union{Matrix,LinearAlgebra.Symmetric,LinearAlgebra.Hermitian},
::_OpGreaterThan,
)
return error_fn(
Expand All @@ -804,7 +804,8 @@ function build_constraint(
you intend a positive semidefinite constraint or an an elementwise
inequality.
To create a positive semidefinite constraint, pass `PSDCone()`:
To create a positive semidefinite constraint, pass `PSDCone()` or
`HermitianPSDCone()`:
```julia
@constraint(model, x >= y, PSDCone())
Expand Down Expand Up @@ -835,7 +836,11 @@ function build_constraint(
return build_constraint(error_fn, f, Nonpositives(), args...; kwargs...)
end

function build_constraint(error_fn::Function, ::AbstractMatrix, ::_OpLessThan)
function build_constraint(
error_fn::Function,
::Union{Matrix,LinearAlgebra.Symmetric,LinearAlgebra.Hermitian},
::_OpLessThan,
)
return error_fn(
"""
Expand All @@ -844,7 +849,7 @@ function build_constraint(error_fn::Function, ::AbstractMatrix, ::_OpLessThan)
inequality.
To create a positive semidefinite constraint, reverse the sense of the
inequality and pass `PSDCone()`:
inequality and pass `PSDCone()` or `HermitianPSDCone()`:
```julia
@constraint(model, y >= x, PSDCone())
Expand Down
5 changes: 3 additions & 2 deletions test/test_constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1991,7 +1991,8 @@ function test_matrix_ambiguous_greater_than_inequality()
you intend a positive semidefinite constraint or an an elementwise
inequality.
To create a positive semidefinite constraint, pass `PSDCone()`:
To create a positive semidefinite constraint, pass `PSDCone()` or
`HermitianPSDCone()`:
```julia
@constraint(model, x >= y, PSDCone())
Expand Down Expand Up @@ -2025,7 +2026,7 @@ function test_matrix_ambiguous_less_than_inequality()
inequality.
To create a positive semidefinite constraint, reverse the sense of the
inequality and pass `PSDCone()`:
inequality and pass `PSDCone()` or `HermitianPSDCone()`:
```julia
@constraint(model, y >= x, PSDCone())
Expand Down

0 comments on commit a523624

Please sign in to comment.