pylpsolve
pylpsolve copied to clipboard
Read solved variables with get_var_primalresult to avoid incorrect column indices after presolve.
This fixes use of incorrect column indices when the presolver removes rows or columns. A serious but silent error when using presolve_cols
.
Of my several pull requests to this project (awesome work by the way!), this is the only one that I feel is particularly necessary. When a presolver is run, the matrix's indices can be altered and some even removed, which means that getSolution
and getSolutionDict
return silently incorrect results.
It's possible to get the stil-existing new column indices back either by name or get_orig_index
, get_origcol_name
/get_col_name
, etc, however those do not provide values for removed columns (for example, when presolve_cols
determines its value, saves it, and removes the column for the solver).
According to the documentation:
To retrieve the variable data of all variables, including the presolved variables, API call get_var_primalresult must be used. This is the only call available to get all information.