Skip to content

Commit

Permalink
[FileFormats.NL] ignore, rather than error, when names are given (#2390)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Jan 4, 2024
1 parent 957328f commit ea5f1a6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/FileFormats/NL/NL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,8 @@ function Base.write(io::IO, model::Model)
# Line 1: Always the same
# Notes:
# * I think these are magic bytes used by AMPL internally for stuff.
# * The first "1" is if the next row includes the number of logical
# constraints.
println(io, "g3 1 1 0")

# Line 2: vars, constraints, objectives, ranges, eqns, logical constraints
Expand Down
5 changes: 2 additions & 3 deletions src/FileFormats/NL/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,8 @@ function _parse_header(io::IO, model::_CacheModel)
@assert _next(Int, io, model) >= 0
_read_til_newline(io)
# Line 9
# We don't support reading variable and constraint names
@assert _next(Int, io, model) == 0
@assert _next(Int, io, model) == 0
# We don't support reading variable and constraint names, so just ignore
# them
_read_til_newline(io)
# Line 10
# We don't support reading common subexpressions
Expand Down
2 changes: 0 additions & 2 deletions test/FileFormats/NL/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ function test_parse_header_assertion_errors()
"g3 1 1 0\n4 2 1 0 1 0\n2 1\n0 0\n4 0 0\n0 0 1 1\n",
"g3 1 1 0\n4 2 1 0 1 0\n2 1\n0 0\n4 0 0\n0 0 0 1\n0 0 0 2 0\n-1 0\n",
"g3 1 1 0\n4 2 1 0 1 0\n2 1\n0 0\n4 0 0\n0 0 0 1\n0 0 0 2 0\n0 -1\n",
"g3 1 1 0\n4 2 1 0 1 0\n2 1\n0 0\n4 0 0\n0 0 0 1\n0 0 0 2 0\n8 4\n1 0\n",
"g3 1 1 0\n4 2 1 0 1 0\n2 1\n0 0\n4 0 0\n0 0 0 1\n0 0 0 2 0\n8 4\n0 1\n",
]
io = IOBuffer()
write(io, header)
Expand Down

0 comments on commit ea5f1a6

Please sign in to comment.