Skip to content

Commit

Permalink
Update to cdots
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Jun 4, 2024
1 parent 77b8baf commit e6483dc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions docs/src/manual/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ julia> @variable(model, X[1:2, 1:2], Symmetric)
julia> @constraint(model, X == LinearAlgebra.I)
[X[1,1] - 1 X[1,2]
X[2,2] - 1] ∈ Zeros()
X[2,2] - 1] ∈ Zeros()
```

This will add only three rows to the constraint matrix because the symmetric
Expand Down Expand Up @@ -1462,15 +1462,15 @@ julia> Z = [X[1, 1] X[1, 2]; X[1, 2] X[2, 2]]
julia> @constraint(model, LinearAlgebra.Symmetric(Z) >= 0, PSDCone())
[X[1,1] X[1,2]
X[2,2]] ∈ PSDCone()
X[2,2]] ∈ PSDCone()
```

Note that the lower triangular entries are ignored even if they are
different so use it with caution:
```jldoctest con_psd
julia> @constraint(model, LinearAlgebra.Symmetric(X) >= 0, PSDCone())
[X[1,1] X[1,2]
X[2,2]] ∈ PSDCone()
X[2,2]] ∈ PSDCone()
```
(Note that no error is thrown, even though `X` is not symmetric.)

Expand Down
8 changes: 5 additions & 3 deletions src/print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -908,9 +908,9 @@ function function_string(
line *= " & "
end
if A isa LinearAlgebra.Symmetric && i > j
line *= "\\cdot"
line *= "\\cdots"
elseif A isa LinearAlgebra.UpperTriangular && i > j
line *= "\\cdot"
line *= "\\cdots"
else
line *= function_string(mode, A[i, j])
end
Expand All @@ -935,7 +935,9 @@ function function_string(
constraint::VectorConstraint{F,S,SymmetricMatrixShape},
) where {F,S}
f = reshape_vector(jump_function(constraint), shape(constraint))
return function_string(mode, LinearAlgebra.UpperTriangular(f))
str = function_string(mode, LinearAlgebra.UpperTriangular(f))
return replace(str, "" => "")

end

function function_string(mode::MIME, p::NonlinearExpression)
Expand Down
2 changes: 1 addition & 1 deletion src/sd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ julia> b = [1 2; 2 4];
julia> cref = @constraint(model, Symmetric(a - b) in PSDCone())
[x - 1 2 x - 2
x - 4] ∈ PSDCone()
x - 4] ∈ PSDCone()
julia> jump_function(constraint_object(cref))
3-element Vector{AffExpr}:
Expand Down
10 changes: 5 additions & 5 deletions test/test_print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ Subject to
con : a + b - 10 c + c1 - 2 x $le 1
a*b $le 2
[a b
x] $inset $(PSDCone())
x] $inset $(PSDCone())
[a, b, c] $inset $(MOI.PositiveSemidefiniteConeTriangle(2))
[a b
c x] $inset $(PSDCone())
Expand Down Expand Up @@ -666,7 +666,7 @@ Names registered in the model: a, a1, b, b1, c, c1, con, fi, soc, u, x, y, z""";
" & a\\times b \\leq 2\\\\\n" *
" & \\begin{bmatrix}\n" *
"a & b\\\\\n" *
"\\cdot & x\\\\\n" *
"\\cdots & x\\\\\n" *
"\\end{bmatrix} \\in \\text{$(PSDCone())}\\\\\n" *
" & [a, b, c] \\in \\text{MathOptInterface.PositiveSemidefiniteConeTriangle(2)}\\\\\n" *
" & \\begin{bmatrix}\n" *
Expand Down Expand Up @@ -1100,13 +1100,13 @@ function test_symmetric_constraint()
@test function_string(MIME("text/plain"), x) ==
"[x[1,1] x[1,2]\n x[1,2] x[2,2]]"
@test function_string(MIME("text/latex"), x) ==
"\\begin{bmatrix}\nx_{1,1} & x_{1,2}\\\\\n\\cdot & x_{2,2}\\\\\n\\end{bmatrix}"
"\\begin{bmatrix}\nx_{1,1} & x_{1,2}\\\\\n\\cdots & x_{2,2}\\\\\n\\end{bmatrix}"
c = @constraint(model, x in PSDCone())
o = constraint_object(c)
@test function_string(MIME("text/plain"), o) ==
"[x[1,1] x[1,2]\n x[2,2]]"
"[x[1,1] x[1,2]\n x[2,2]]"
@test function_string(MIME("text/latex"), o) ==
"\\begin{bmatrix}\nx_{1,1} & x_{1,2}\\\\\n\\cdot & x_{2,2}\\\\\n\\end{bmatrix}"
"\\begin{bmatrix}\nx_{1,1} & x_{1,2}\\\\\n\\cdots & x_{2,2}\\\\\n\\end{bmatrix}"
return
end

Expand Down

0 comments on commit e6483dc

Please sign in to comment.