Skip to content

Commit 1694a00

Browse files
authored
[FileFormats.MPS] test that duplicate entries are summed (#2787)
1 parent 27ac092 commit 1694a00

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

test/FileFormats/MPS/MPS.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,20 @@ function test_obj_constant_max_to_max()
16611661
return
16621662
end
16631663

1664+
function test_duplicate_coefficient()
1665+
model = MPS.Model()
1666+
MOI.read_from_file(model, joinpath(@__DIR__, "duplicate_coefficient.mps"))
1667+
dest = MOI.Utilities.Model{Float64}()
1668+
MOI.copy_to(dest, model)
1669+
F, S = MOI.ScalarAffineFunction{Float64}, MOI.EqualTo{Float64}
1670+
x = only(MOI.get(dest, MOI.ListOfVariableIndices()))
1671+
c = only(MOI.get(dest, MOI.ListOfConstraintIndices{F,S}()))
1672+
f = MOI.get(dest, MOI.ConstraintFunction(), c)
1673+
@test isapprox(f, 2.0 * x)
1674+
@test MOI.get(dest, MOI.ConstraintSet(), c) == MOI.EqualTo(1.0)
1675+
return
1676+
end
1677+
16641678
end # TestMPS
16651679

16661680
TestMPS.runtests()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
NAME DUPLICATE_COEFFICIENT
2+
ROWS
3+
N obj
4+
E c
5+
COLUMNS
6+
x obj 1
7+
x c 1
8+
x c 1
9+
RHS
10+
rhs c 1
11+
BOUNDS
12+
FR bounds x
13+
ENDATA

0 commit comments

Comments
 (0)