HiGHS icon indicating copy to clipboard operation
HiGHS copied to clipboard

Fix interpretation of ("+ +1.23"?), "+ -1.23" and "- -1.23" in .lp file reader

Open jajhall opened this issue 3 years ago • 3 comments

This bug and others are exposed by the simpler model offset.lp.txt and emphasised by the printing added to https://github.com/ERGO-Code/HiGHS/tree/fix-948

@svigerske : You've done much more than I have with the .lp file reader - particularly at the token level. Do you have time to look at this?

Originally posted by @jajhall in https://github.com/ERGO-Code/HiGHS/issues/948#issuecomment-1242206152

jajhall avatar Sep 09 '22 21:09 jajhall

So, @svigerske , having merged (and then deleted) /fix-948 into master, you're free to look at this issue in another branch.

jajhall avatar Sep 10 '22 13:09 jajhall

So what should actually happen in the LP reader with this input?

One could be strict and reject consecutive signs as an error. I doubt that the given example is valid .lp syntax.

It would also be easy to handle two consecutive signs in the way it was probably expected here, but do one want to allow arbitrary many signs, e.g., + - + - + - + [ x^2 ] ?

svigerske avatar Sep 15 '22 12:09 svigerske

It's true that I'd not checked whether Gurobi would read the example. Is "valid .lp syntax." defined to this level of detail?

The issue came up because someone had the substring "+ -1.2345 x1" where, I guess, he'd written the "+" for a new term, then the coefficient value, and then the variable name. This is reasonable, since the "+" is needed in the case where the coefficient is positive (unless the coefficient is written out with an explicit "+") and was read OK by Gurobi.

I'd say that three or more consecutive signs is an error

jajhall avatar Sep 15 '22 12:09 jajhall