Skip to content

Commit

Permalink
[docs] add warning about Y <= X, Set() syntax (#3769)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Jun 9, 2024
1 parent b369f5b commit 5e0a975
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions docs/src/manual/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -1238,8 +1238,9 @@ julia> @constraint(model, x in MOI.ExponentialCone())
## Set inequality syntax

For modeling convenience, the syntax `@constraint(model, x >= y, Set())` is
short-hand for `@constraint(model, x - y in Set())`. Therefore, the following
calls are equivalent:
short-hand for `@constraint(model, x - y in Set())`.

Therefore, the following calls are equivalent:
```jldoctest set_inequality
julia> model = Model();
Expand All @@ -1250,9 +1251,6 @@ julia> y = [0.5, 0.75];
julia> @constraint(model, x >= y, MOI.Nonnegatives(2))
[x[1] - 0.5, x[2] - 0.75] ∈ MathOptInterface.Nonnegatives(2)
julia> @constraint(model, y <= x, MOI.Nonnegatives(2))
[x[1] - 0.5, x[2] - 0.75] ∈ MathOptInterface.Nonnegatives(2)
julia> @constraint(model, x - y in MOI.Nonnegatives(2))
[x[1] - 0.5, x[2] - 0.75] ∈ MathOptInterface.Nonnegatives(2)
```
Expand All @@ -1270,6 +1268,11 @@ julia> @constraint(model, x .- 1 >= 0, MOI.Nonnegatives(2))
[x[1] - 1, x[2] - 1] ∈ MathOptInterface.Nonnegatives(2)
```

!!! warning
The syntax `@constraint(model, y <= x, Set())` is supported, but it is not
recommended because the value of the primal and dual solutions associated
with the constraint may be the negative of what you expect.

## Second-order cone constraints

A [`SecondOrderCone`](@ref) constrains the variables `t` and `x` to the set:
Expand Down Expand Up @@ -1440,6 +1443,11 @@ julia> @constraint(model, X >= Y, PSDCone())
X[2,1] - 2 X[2,2] - 1] ∈ PSDCone()
```

!!! warning
The syntax `@constraint(model, Y <= X, PSDCone())` is supported, but it is
not recommended because the value of the primal and dual solutions associated
with the constraint may be the negative of what you expect.

### Symmetry

Solvers supporting PSD constraints usually expect to be given a matrix that
Expand Down

0 comments on commit 5e0a975

Please sign in to comment.