Skip to content

[FileFormats.NL] ignore, rather than error, when names are given #2390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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