mdhaber / scipy

Scipy library main repository
http://scipy.org/scipylib/
BSD 3-Clause "New" or "Revised" License
1 stars 5 forks source link

ENH: linalg/optimize: improved support for large, sparse problems #47

Open mdhaber opened 3 years ago

mdhaber commented 3 years ago

SciPy seeks to provide access

This issue summarizes the status of SciPy's support for sparse linear algebra and optimization, and it details what I propose to add.

Linear Algebra

SciPy has some support for sparse linear algebra:

SciPy lacks sparse support for other fundamental linear algebra algorithms, most notably Cholesky decomposition and QR decomposition. Also, better support for sparse SVD has been desired for years (gh-857). There is some support for solving these problems in the greater scientific Python ecosystem, but there are also unmet needs. Following the model of SciPy's scipy.sparse.linalg.spsolve, my goal is to enable easy access to both permissively-licensed implementations and more performant (potentially copyleft-licensed) implementations of algorithms for these problems from Linux, Mac, and (the oft forgotten) Windows.

Optimization

SciPy has some support for sparse optimization: scipy.optimize.minimize(method='trust-constr') and scipy.optimize.linprog(method='interior-point') exploit sparsity, and SciPy 1.6 will vendor the linear programming software HiGHS and add an interface via linprog. However, these offerings are substantially less powerful than copyleft-licensed counterparts, and convenient Python interfaces to the copyleft software is not available on all platforms. Following the model of SciPy's scipy.sparse.linalg.spsolve, my goal is to enable access to both permissively-licensed implementations and more performant (potentially copyleft-licensed) implementations of these solvers from Mac, Linux, and Windows.

Installation Notes

Notes from attempts to install the software above on Windows 11/30/2020:

mckib2 commented 3 years ago

@mdhaber is there a wishlist ranking of projects, i.e. what makes sense to prioritize first?

I've updated the HiGHS wrappers (waiting on some bug fixes to open a PR), but it leaves me in the position to start looking at a MIP interface for HiGHS (and presumably the rest of the MIP solvers mentioned here)

mdhaber commented 3 years ago

I wrote this up for @rgommers based on what we had written for the CZI Cycle 3 proposal and what I'd most like to do for the NASA ROSES opportunity. There's no need to get started on anything yet, but yes, we could start looking into those other HiGHS features we've discussed.

rgommers commented 3 years ago

It's pretty difficult to figure out what to prioritize I think. Based on what I'd expect the effort to be plus licensing constraints and future maintenance considerations, my opinion would be:

  1. BSD-licensed functionality that can be wrapped - PROPACK, HiGHS
  2. Fix up issues with separate sparse wrappers - scikit-umfpack, scikit-sparse, one of the sparse qr options
  3. One of the CLP/CBC interface options
  4. Writing sparse Cholesky from scratch
mdhaber commented 3 years ago

Sure, I can add more HiGHS work to the list. There are a lot of features they've had that we'd like to wrap (dual problem / sensitivity analysis information and MPS format conversion), and they recently merged a MIP solver into master.

mckib2 commented 3 years ago

@mdhaber FYI, MPS writer is already available as a development debugging tool in scipy.optimize._highs, just needs a public API. The HiGHS reader should be similarly easy to wrap. The hard part here is making tests

mckib2 commented 3 years ago

@mdhaber I have a HiGHS MIP wrapper working in a branch of my HiGHS fork.

Major changes:

I only tested on a few small examples and I expect it will require a lot more testing and debugging.

I would like to wait until https://github.com/scipy/scipy/pull/13197 is merged before I start on another PR because my changes are based on updates in the existing PR.

mdhaber commented 3 years ago

Ok. I can't really work on optimize right now, though : / There is too much to finish on stats. When this project is done, though, I'll take a look.

rgommers commented 3 years ago

I have a HiGHS MIP wrapper working in a branch of my HiGHS fork.

That sounds great!

I would like to wait until scipy#13197 is merged before I start on another PR because my changes are based on updates in the existing PR.

You can always base one PR on the other one - it'll have duplicate commits, but those will disappear as soon as PR 1 is merged.

rgommers commented 3 years ago

@mdhaber it would be nice to move this content, which will be useful long-term, into a couple of issues on the main repo. Maybe one for sparse and one for optimize, as tracking issues for external libraries that we'd like to have wrappers/interfaces for?