Skip to content

Commit ea5f1a6

Browse files
authored
[FileFormats.NL] ignore, rather than error, when names are given (#2390)
1 parent 957328f commit ea5f1a6

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

src/FileFormats/NL/NL.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,8 @@ function Base.write(io::IO, model::Model)
548548
# Line 1: Always the same
549549
# Notes:
550550
# * I think these are magic bytes used by AMPL internally for stuff.
551+
# * The first "1" is if the next row includes the number of logical
552+
# constraints.
551553
println(io, "g3 1 1 0")
552554

553555
# Line 2: vars, constraints, objectives, ranges, eqns, logical constraints

src/FileFormats/NL/read.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,8 @@ function _parse_header(io::IO, model::_CacheModel)
312312
@assert _next(Int, io, model) >= 0
313313
_read_til_newline(io)
314314
# Line 9
315-
# We don't support reading variable and constraint names
316-
@assert _next(Int, io, model) == 0
317-
@assert _next(Int, io, model) == 0
315+
# We don't support reading variable and constraint names, so just ignore
316+
# them
318317
_read_til_newline(io)
319318
# Line 10
320319
# We don't support reading common subexpressions

test/FileFormats/NL/read.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ function test_parse_header_assertion_errors()
150150
"g3 1 1 0\n4 2 1 0 1 0\n2 1\n0 0\n4 0 0\n0 0 1 1\n",
151151
"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",
152152
"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",
153-
"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",
154-
"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",
155153
]
156154
io = IOBuffer()
157155
write(io, header)

0 commit comments

Comments
 (0)