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
14351435# ==============================================================================
14361436
14371437function parse_rows_line (data:: TempMPSModel{T} , items:: Vector{String} ) where {T}
1438- if length (items) != 2
1438+ if length (items) < 2
14391439 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.
14401447 end
14411448 sense, name = Sense (items[1 ]), items[2 ]
14421449 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()
8888 joinpath (@__DIR__ , " failing_models" , filename),
8989 )
9090 end
91+ return
9192end
9293
9394function test_empty_row_name ()
@@ -1675,6 +1676,33 @@ function test_duplicate_coefficient()
16751676 return
16761677end
16771678
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+
16781706end # TestMPS
16791707
16801708TestMPS. runtests ()
Original file line number Diff line number Diff line change 11NAME
22ROWS
3- N c d
3+ N
44COLUMNS
55ENDATA
You can’t perform that action at this time.
0 commit comments