Skip to content

Commit a5916de

Browse files
committed
[SDPA] Add missing negation of constant
1 parent cdf87e9 commit a5916de

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/FileFormats/SDPA/SDPA.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function Base.write(io::IO, model::Model{T}) where {T}
190190
F0 = MOI.constant(func)
191191
for k in eachindex(F0)
192192
if !iszero(F0[k])
193-
_print_entry(0, block, psd, k, F0[k])
193+
_print_entry(0, block, psd, k, -F0[k])
194194
end
195195
end
196196
for term in func.terms
@@ -322,7 +322,7 @@ function Base.read!(io::IO, model::Model{T}) where T
322322
end
323323
if iszero(matrix)
324324
if !iszero(coef)
325-
funcs[block].constants[k] += coef
325+
funcs[block].constants[k] -= coef
326326
end
327327
else
328328
if !iszero(coef)

test/FileFormats/SDPA/SDPA.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,13 @@ example_models = [
193193
("example_A.sdpa", """
194194
variables: x, y
195195
minobjective: 10x + 20y
196-
c1: [x + 1, 0, x + 2] in PositiveSemidefiniteConeTriangle(2)
197-
c2: [5y + 3, 4y, 6y + 4] in PositiveSemidefiniteConeTriangle(2)
196+
c1: [x + -1, 0, x + -2] in PositiveSemidefiniteConeTriangle(2)
197+
c2: [5y + -3, 4y, 6y + -4] in PositiveSemidefiniteConeTriangle(2)
198198
"""),
199199
("example_B.sdpa", """
200200
variables: x
201201
minobjective: 1x
202-
c1: [0, 2x + 2, 0] in PositiveSemidefiniteConeTriangle(2)
202+
c1: [0, 2x + -2, 0] in PositiveSemidefiniteConeTriangle(2)
203203
"""),
204204
]
205205
@testset "Read and write/read $model_name" for (model_name, model_string) in example_models

0 commit comments

Comments
 (0)