rust-or / rust-lp-modeler

Lp modeler written in Rust
MIT License
96 stars 29 forks source link

newline before comparison operator in .lp file format #72

Closed dlaehnemann closed 3 years ago

dlaehnemann commented 3 years ago

This is a workaround for this curious cbc bug that I encountered: https://github.com/coin-or/CoinUtils/issues/144

It seems that the LP file format is not standardized (yay!). However, points 5 and 9 in this lpsolve documentation for the CPLEX LP format and this IBM CPLEX LP format description of constraints agree in that constraints can go across multiple lines. Only the constraint name and its colon (e.g. c1234:) need to appear on the same line, as do the comparison operator and the right-hand side (e.g. >= 5678). And I found this slide deck that refers to the LP file format as developed by CPLEX. So I assume cbc (and the other solvers) will follow these kinds of "format descriptions".

So introducing these newlines should be safe to do and will prevent this bug. To get back the original format, this PR can later be reverted once the issue in CoinUtils (and thus cbc) is addressed. To make this easier, I would squash the commits in this PR during merging.

dlaehnemann commented 3 years ago

After extensive digging, I have now found a better workaround using the NativeCbcSolver. However, for this to work, the used cbc currently still has to be patched to avoid a concurrency until a new major version is released. If anybody is looking to use the NativeCbcSolver and running into issues with multiple Cbc instances (on separate problems and on separate threads, but on the same system) running in parallel with some of them randomly crashing, here are solutions that I found: https://github.com/KardinalAI/coin_cbc/pull/7#issuecomment-786189288

I'll close this issue, because this is only a workaround until a new release of CoinUtils with the recent fixes to the LP input parsing bugs I reported. It's not worth merging this, if it becomes obsolete in the near future and will only cause confusion.