File tree Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -1435,8 +1435,15 @@ end
1435
1435
# ==============================================================================
1436
1436
1437
1437
function parse_rows_line (data:: TempMPSModel{T} , items:: Vector{String} ) where {T}
1438
- if length (items) != 2
1438
+ if length (items) < 2
1439
1439
error (" Malformed ROWS line: $(join (items, " " )) " )
1440
+ elseif length (items) > 2
1441
+ # We could throw an error here, but it seems like other solvers just
1442
+ # happily ignore the extra fields.
1443
+ #
1444
+ # See https://github.com/jump-dev/MathOptInterface.jl/issues/2792
1445
+ #
1446
+ # Oscar dislikes the poorly standardized nature of MPS.
1440
1447
end
1441
1448
sense, name = Sense (items[1 ]), items[2 ]
1442
1449
if haskey (data. name_to_row, name)
Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ function test_failing_models()
88
88
joinpath (@__DIR__ , " failing_models" , filename),
89
89
)
90
90
end
91
+ return
91
92
end
92
93
93
94
function test_empty_row_name ()
@@ -1675,6 +1676,33 @@ function test_duplicate_coefficient()
1675
1676
return
1676
1677
end
1677
1678
1679
+ function test_issue_2792 ()
1680
+ src = """
1681
+ NAME
1682
+ ROWS
1683
+ N OBJ \$ t3 0
1684
+ COLUMNS
1685
+ x OBJ 2
1686
+ RHS
1687
+ rhs OBJ -3
1688
+ BOUNDS
1689
+ LO bounds x 1
1690
+ PL bounds x
1691
+ ENDATA
1692
+ """
1693
+ model = MPS. Model ()
1694
+ read! (IOBuffer (src), model)
1695
+ dest = MOI. Utilities. Model {Float64} ()
1696
+ MOI. copy_to (dest, model)
1697
+ @test MOI. get (dest, MOI. ListOfConstraintTypesPresent ()) ==
1698
+ [(MOI. VariableIndex, MOI. GreaterThan{Float64})]
1699
+ x = only (MOI. get (dest, MOI. ListOfVariableIndices ()))
1700
+ F = MOI. get (dest, MOI. ObjectiveFunctionType ())
1701
+ f = MOI. get (dest, MOI. ObjectiveFunction {F} ())
1702
+ @test isapprox (f, 2.0 * x + 3.0 )
1703
+ return
1704
+ end
1705
+
1678
1706
end # TestMPS
1679
1707
1680
1708
TestMPS. runtests ()
Original file line number Diff line number Diff line change 1
1
NAME
2
2
ROWS
3
- N c d
3
+ N
4
4
COLUMNS
5
5
ENDATA
You can’t perform that action at this time.
0 commit comments