From ea5f1a633f12e43245023b33d135df32ded4d209 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 4 Jan 2024 22:38:45 +1300 Subject: [PATCH] [FileFormats.NL] ignore, rather than error, when names are given (#2390) --- src/FileFormats/NL/NL.jl | 2 ++ src/FileFormats/NL/read.jl | 5 ++--- test/FileFormats/NL/read.jl | 2 -- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/FileFormats/NL/NL.jl b/src/FileFormats/NL/NL.jl index cc0fa0e211..da3a452613 100644 --- a/src/FileFormats/NL/NL.jl +++ b/src/FileFormats/NL/NL.jl @@ -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 diff --git a/src/FileFormats/NL/read.jl b/src/FileFormats/NL/read.jl index e38f9d1dc2..a43604eec4 100644 --- a/src/FileFormats/NL/read.jl +++ b/src/FileFormats/NL/read.jl @@ -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 diff --git a/test/FileFormats/NL/read.jl b/test/FileFormats/NL/read.jl index a815af70f9..ed34d7d26c 100644 --- a/test/FileFormats/NL/read.jl +++ b/test/FileFormats/NL/read.jl @@ -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)