diff --git a/src/FileFormats/SDPA/SDPA.jl b/src/FileFormats/SDPA/SDPA.jl index f7b2a3a19a..2fffbe650e 100644 --- a/src/FileFormats/SDPA/SDPA.jl +++ b/src/FileFormats/SDPA/SDPA.jl @@ -190,7 +190,7 @@ function Base.write(io::IO, model::Model{T}) where {T} F0 = MOI.constant(func) for k in eachindex(F0) if !iszero(F0[k]) - _print_entry(0, block, psd, k, F0[k]) + _print_entry(0, block, psd, k, -F0[k]) end end for term in func.terms @@ -322,7 +322,7 @@ function Base.read!(io::IO, model::Model{T}) where T end if iszero(matrix) if !iszero(coef) - funcs[block].constants[k] += coef + funcs[block].constants[k] -= coef end else if !iszero(coef) diff --git a/test/FileFormats/SDPA/SDPA.jl b/test/FileFormats/SDPA/SDPA.jl index 0971014052..3827bfd113 100644 --- a/test/FileFormats/SDPA/SDPA.jl +++ b/test/FileFormats/SDPA/SDPA.jl @@ -193,13 +193,13 @@ example_models = [ ("example_A.sdpa", """ variables: x, y minobjective: 10x + 20y - c1: [x + 1, 0, x + 2] in PositiveSemidefiniteConeTriangle(2) - c2: [5y + 3, 4y, 6y + 4] in PositiveSemidefiniteConeTriangle(2) + c1: [x + -1, 0, x + -2] in PositiveSemidefiniteConeTriangle(2) + c2: [5y + -3, 4y, 6y + -4] in PositiveSemidefiniteConeTriangle(2) """), ("example_B.sdpa", """ variables: x minobjective: 1x - c1: [0, 2x + 2, 0] in PositiveSemidefiniteConeTriangle(2) + c1: [0, 2x + -2, 0] in PositiveSemidefiniteConeTriangle(2) """), ] @testset "Read and write/read $model_name" for (model_name, model_string) in example_models