Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Jun 25, 2024
1 parent bc1396a commit 1ee6039
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/src/manual/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ julia> b = [5, 6]
6
julia> @constraint(model, con_vector, A * x == b)
con_vector : [x[1] + 2 x[2] - 5, 3 x[1] + 4 x[2] - 6] ∈ MathOptInterface.Zeros(2)
con_vector : [x[1] + 2 x[2] - 5, 3 x[1] + 4 x[2] - 6] ∈ Zeros()
julia> @constraint(model, con_scalar, A * x .== b)
2-element Vector{ConstraintRef{Model, MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}, ScalarShape}}:
Expand Down Expand Up @@ -1257,7 +1257,7 @@ 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())`.
short-hand for `@constraint(model, x - y in Set())`.

Therefore, the following calls are equivalent:
```jldoctest set_inequality
Expand Down
4 changes: 2 additions & 2 deletions src/macros/@constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -630,14 +630,14 @@ julia> @variable(model, x[1:2])
x[2]
julia> @constraint(model, x in Zeros())
[x[1], x[2]] ∈ MathOptInterface.Zeros(2)
[x[1], x[2]] ∈ Zeros()
julia> A = [1 2; 3 4];
julia> b = [5, 6];
julia> @constraint(model, A * x == b)
[x[1] + 2 x[2] - 5, 3 x[1] + 4 x[2] - 6] ∈ MathOptInterface.Zeros(2)
[x[1] + 2 x[2] - 5, 3 x[1] + 4 x[2] - 6] ∈ Zeros()
```
"""
struct Zeros end
Expand Down
3 changes: 2 additions & 1 deletion test/test_macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1977,6 +1977,7 @@ function test_matrix_in_vector_set()
),
@constraint(model, X <= A),
)
Y = Containers.DenseAxisArray(X, 2:3, 2:3)
B = Containers.DenseAxisArray(A, 2:3, 2:3)
@test_throws_runtime(
ErrorException(
Expand All @@ -1986,7 +1987,7 @@ function test_matrix_in_vector_set()
"this syntax is supported in the special case that the matrices are " *
"`Array`, `LinearAlgebra.Symmetric`, or `LinearAlgebra.Hermitian`.",
),
@constraint(model, X == B),
@constraint(model, Y == B),
)
return
end
Expand Down

0 comments on commit 1ee6039

Please sign in to comment.