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

[docs] add warning about Y <= X, Set() syntax #3769

Merged
merged 2 commits into from
Jun 9, 2024
Merged
Changes from 1 commit
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
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 @@
## Set inequality syntax

For modeling convenience, the syntax `@constraint(model, x >= y, Set())` is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that as per https://docs.julialang.org/en/v1/manual/unicode-input/
can be "trivially" inputted as \succeq.

Wouldn't it be possible to:

@constraint(model, x \succeq y)
# error: specify one of the conic sets
@constraint(model, x >= y, <... Some conic set ...>)
# warning: use \succeq instead
@constraint(model, x \succeq y, <... Some non-conic set ...>)
# warning: use >= instead
@constraint(model, x >= y)
# becomes @constraint(model, x - y, Nonnegatives)
@constraint(model, x <= y)
# becomes @constraint(model, x - y, Nonpositives)

Is the concern that someone writes @constraint(model, x >= y) thinking it means PSDCone,
it silently works, and doesn't do what's expected? Or is there some other concern?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the concern that someone writes @constraint(model, x >= y) thinking it means PSDCone,
it silently works, and doesn't do what's expected?

Yes.

We won't be adding support for \succeq. There is too much risk of confusion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:/ I really feel such a decision should be made with a larger headcount than i see here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll open a new issue

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> @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 @@
[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 connstraint may be the negative of what you expect.

Check failure on line 1274 in docs/src/manual/constraints.md

View workflow job for this annotation

GitHub Actions / build

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'connstraint'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'connstraint'?", "location": {"path": "docs/src/manual/constraints.md", "range": {"start": {"line": 1274, "column": 14}}}, "severity": "ERROR"}
odow marked this conversation as resolved.
Show resolved Hide resolved

## Second-order cone constraints

A [`SecondOrderCone`](@ref) constrains the variables `t` and `x` to the set:
Expand Down Expand Up @@ -1440,6 +1443,11 @@
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 connstraint may be the negative of what you expect.

Check failure on line 1449 in docs/src/manual/constraints.md

View workflow job for this annotation

GitHub Actions / build

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'connstraint'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'connstraint'?", "location": {"path": "docs/src/manual/constraints.md", "range": {"start": {"line": 1449, "column": 14}}}, "severity": "ERROR"}
odow marked this conversation as resolved.
Show resolved Hide resolved

### Symmetry

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