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
Add an interface to SciPy-accessible LP solvers #1414
Comments
I have been working on a new Solver interface to incorporate the HiGHS solvers (https://www.maths.ed.ac.uk/hall/HiGHS/#guide) via SciPy and by following the steps in the contributing section of CVXPY (https://www.cvxpy.org/contributing/index.html#solver-interfaces) I managed to get a working solution however I had two questions:
|
For (1), I think having an explicit keyword argument
then your interface will effectively do something like
For (2), setting |
@rileyjmurray - thank you for your response. I have now amended the scipy_conif script so that it works as you describe above. I did not change the "method" parameter as it does not cause any issues when contained within scipy_options. It will pop "method" and "bounds" from the dictionary and leave the rest to be used as options. I did not include "callback" or "x0" as neither are supported by the HiGHS solvers and the latter is only applicable for the "revised-simplex" method. I also changed the default solver to "highs" as suggested within the Notes section of the documnetation: https://docs.scipy.org/doc/scipy/reference/optimize.linprog-highs.html#optimize-linprog-highs I ran a couple of scenarios and it seems to work really well with insignificant overhead from SciPy, it is still a pity that we do not have access to the dual-variables but we could think of a direct interface with HiGHS solvers in the future if needed. One question I had before moving on to building tests was on the apply() function within the _conif.py files. Since I only implemented SciPy's linprog function, it will only work for LPs just like with GLPK. I took a look at glpk_conif.py (https://github.com/cvxpy/cvxpy/blob/master/cvxpy/reductions/solvers/conic_solvers/glpk_conif.py) and noticed that it calls the cvxopt_confi.py apply() function through super() which has the following code:
Since we are only looking at LPs, wouldn't that mean that SOC or PSD or ExpCone constraints are not supported? So should the code for the new SciPy interface (and possible a change for GLPK) look more like this:
|
Side note: I looked into the scipy wrapper of the HiGHS solvers and it looks like they are planning to carry back the dual-variables from the solver's results, it just is not implemented yet in the final version. This can be seen in the git repo in this file https://github.com/scipy/scipy/blob/master/scipy/optimize/_linprog_highs.py at lines 388-396 and 415-440 at this point in time. |
Responding to a few points, @Michael-git96
All that sounds good.
Excellent! For dual variables you can create a new GitHub issue after your PR is merged, and that GitHub issue can be linked to an issue on the SciPy repo.
You are correct that ExpCone, SOC, PSD, and PowCone3D are all not supported by this solver. Your interface should inherit from
ConicSolver.format_constraints has code to account for other cones, but that code won't be invoked unless you modify SCIPY.SUPPORTED_CONSTRAINTS .)
|
@rileyjmurray Thank you, I will ensure that only the NonNeg and Zero constraints are used in the apply() function and I checked and indeed SCIPY does inherit from ConicSolver and so SUPPORTED_CONSTRAINTS only include Zero and NonNeg. I can modify scipy_conif and push the changes so they appear in the pull request I submitted. |
* Add an interface to SciPy-accessible LP solvers - Issue: #1414 * Added version requirement for SciPy in setup * Removing redundant constraints SOC and PSD in apply function of SCIPY class in scipy_conif.py * Removed scipy >= 1.6.1 requirement and added warnings if method not specified * Added version default choice and removed bounds parameter * Added SciPy/HiGHS solver to documentation * Added SciPy/HiGHS solver to install documentation * Removed redundant check for SciPy in the unit tests * Replaced SciPy/HiGHS with SCIPY for install doc * Changed Scipy/HiGHS to SCIPY and added more detail to Setting Solver Options * Corrected flake8 error * Skip SCIPY in test_verbose in test_problem.py
Scipy version 1.6.1 and later versions have access to HiGHS solvers (https://www.maths.ed.ac.uk/hall/HiGHS/#guide) for LPs via the linprog function which are comparable with GLPK and other solvers in terms of performance especially for large sparse LP problems which uses SciPy.sparse matrices.
The aim would be to have a new interface with SciPy so that users can access the HiGHS solvers through CVXPY.
I have forked and cloned the repo and have already started to work on such an interface.
The text was updated successfully, but these errors were encountered: