Skip to content
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

Simple .lp file no longer readable #1449

Closed
fuglede opened this issue Oct 9, 2023 · 8 comments
Closed

Simple .lp file no longer readable #1449

fuglede opened this issue Oct 9, 2023 · 8 comments
Assignees

Comments

@fuglede
Copy link
Contributor

fuglede commented Oct 9, 2023

This came up while debugging lovasoa/highs-js#34: A one-line .lp file with contents

Maximize a subject to a >= 1 bounds a <= 0

used to be readable by HiGHS which would detect infeasibility, but now it just gives a "parser error".

@fuglede
Copy link
Contributor Author

fuglede commented Oct 9, 2023

Another example is

Maximize a subject to a >= 1

@fuglede
Copy link
Contributor Author

fuglede commented Oct 9, 2023

Arguably, this is actually completely fine since, according to the specification,

The file must end with the word end in any combination of upper- and lower-case characters, alone on a line. This word is not required for files that are read in to lpsolve, but it is strongly recommended. Files that have been corrupted can frequently be detected by a missing last line.

@jajhall
Copy link
Member

jajhall commented Oct 9, 2023

Fair cop, we didn't have a file of this kind in the test cases.

@fuglede
Copy link
Contributor Author

fuglede commented Oct 9, 2023

I think it's fine; append the "End" line and both cases work as expected.

@fuglede fuglede closed this as completed Oct 9, 2023
@jajhall
Copy link
Member

jajhall commented Oct 9, 2023

Yes, not requiring an "End" line is lp_solve LP format- that we don't support

@fuglede
Copy link
Contributor Author

fuglede commented Oct 10, 2023

Reopening per discussion here: lovasoa/highs-js#35 (comment)

@fuglede fuglede reopened this Oct 10, 2023
@jajhall jajhall self-assigned this Oct 10, 2023
@jajhall
Copy link
Member

jajhall commented Oct 10, 2023

Having looked at these two files, Gurobi reads

Maximize a subject to a >= 1

but not

Maximize a subject to a >= 1 bounds a <= 0

so they are clearly on the margins of what's readable. In both cases, if end is appended to the line HiGHS reads them fine

Looking again at the statement in (CPLEX-format)[https://web.mit.edu/lpsolve/doc/CPLEX-format.htm],

The file must end with the word end in any combination of upper- and lower-case characters, alone on a line. This word is not required for files that are read in to lpsolve, but it is strongly recommended. Files that have been corrupted can frequently be detected by a missing last line.

rather than allow HiGHS to interpret EOF as a missing end statement - as it did before - I've decided that it's better to require end so that corrupted (truncated) files are flagged up.

@jajhall jajhall closed this as completed Oct 10, 2023
@fuglede
Copy link
Contributor Author

fuglede commented Oct 18, 2023

And while we're at it, the specification also requires that

Each constraint definition must begin on a new line.

which clearly wasn't the case here, so even though it's parsable once the "End" line is added, it's really still invalid according to the specification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants