Closed mfuhr closed 10 months ago
Thanks, that's a great bug report! Since you found the source of the the error and even the fix, would you mind making a small PR, and maybe even adding a test?
Will do, although I confess to not having much git-fu. Got some learning to do first :-)
PR submitted; hopefully I got it right.
thanks ! fixed in 1.4.2 https://crates.io/crates/good_lp/versions
Using an external solver fails on some problems, e.g., the first example on the main good_lp documentation page. When replacing
default_solver
withLpSolver(GlpkSolver::new())
the code panics withglpsol exited with status exit status: 1
.Running
glpsol
from the shell on a copy of the LP file shows more detail:The file is:
The problem appears to be the
+ -1 a
on line 8. Cplex (at least version 20.1.0.0 at NEOS) also fails with the errorCPLEX Error 1434: Line 8: Couldn't convert '+-1' to a number
but Gurobi accepts the file.I think the formatting is done by
linear_coefficients_str()
in solvers/lp_solvers.rs:I don't know if this is the correct fix or not, but changing the format string to
"{:+} {}"
and the join string to" "
generates a file that's acceptable to Glpk, Cplex, and Gurobi, even for other problems where the first coefficient has a leading+
.Thanks!