CURENT / andes

Python toolbox / library for power system transient dynamics simulation with symbolic modeling and numerical analysis 🔥
https://ltb.curent.org
Other
223 stars 111 forks source link

Deprecate native dependency on ``umfpack`` #562

Open jinningwang opened 4 weeks ago

jinningwang commented 4 weeks ago

Is your feature request related to a problem? Please describe. The native dependency on umfpack via kvxopt can introduce license issue. The involved implementation in ANDES is in: https://github.com/CURENT/andes/blob/5ab784b75347a98d07c004e32d7c4b39d407ea2e/andes/linsolvers/suitesparse.py#L7-L8

Further, it can be traced back to SuiteSparse via kvxopt: https://github.com/sanurielf/kvxopt/blob/cc4cd9a4f2f27c2f5cac1363ba0f36574b16b0bd/setup.py#L76-L93

Describe the solution you'd like

For reference, package SciPy provides wrappers of umfpack (via a BSD licensed packagescikit-umfpack), but doesn't include it as a dependency.

Code: https://github.com/scipy/scipy/blob/9e9d534b7afac90e8d2fa23be1d0ab1201c1bde1/scipy/sparse/linalg/_dsolve/linsolve.py#L13-L19

Documentation: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.use_solver.html

Dependency: In the dependency, the package scikit-umfpack is included in [test] rather than in [build-system]. https://github.com/scipy/scipy/blob/9e9d534b7afac90e8d2fa23be1d0ab1201c1bde1/pyproject.toml#L18-L32

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context

cuihantao commented 4 weeks ago

Jinning,

Thanks! UNFPACK support comes for free with KVXOPT or cvxopt. Once we replace the sparse matrices handling with SciPy, we will automatically switch to using UMFPACK from there.

Get Outlook for iOShttps://aka.ms/o0ukef


From: Jinning Wang @.> Sent: Thursday, August 15, 2024 9:59:25 AM To: CURENT/andes @.> Cc: Hantao Cui @.>; Assign @.> Subject: Re: [CURENT/andes] Deprecate native dependency on umfpack (Issue #562)

Assigned #562https://github.com/CURENT/andes/issues/562 to @cuihantaohttps://github.com/cuihantao.

— Reply to this email directly, view it on GitHubhttps://github.com/CURENT/andes/issues/562#event-13896180517, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABSNZA3I7LJUYTXCKOSCQBTZRSX33AVCNFSM6AAAAABMSIHBJ2VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJTHA4TMMJYGA2TCNY. You are receiving this because you were assigned.Message ID: @.***>

jinningwang commented 4 weeks ago

I'm thinking that, maybe we can benchmark the performance of involved methods? Here is a code to my mind.

Feel free to let me know if you have any other comments.

scipy.sparse.linalg import spsolve

# assume `A` is a 2D matrix and `b` is a vector

# method1
x1 = spsolve(A, b, use_umfpack=True)

# method2
x2 = spsolve(A, b, use_umfpack=False)
cuihantao commented 4 weeks ago

Sure. This is benchmarking UMFPACK and SuperLU performance. And remember the default solver is KLU, which is probably 30% faster than UMFPACK. And.. using KVXOPT to handle sparse matrices can be 20%-50% faster than using SciPy for systems with, say, 10,000 buses.

On Aug 15, 2024, at 11:12 AM, Jinning Wang @.***> wrote:

I'm thinking that, maybe we can benchmark the performance of involved methods? Here is a code to my mind.

Feel free to let me know if you have any other comments.

scipy.sparse.linalg import spsolve

assume A is a 2D matrix and b is a vector

method1

x1 = spsolve(A, b, use_umfpack=True)

method2

x2 = spsolve(A, b, use_umfpack=False) — Reply to this email directly, view it on GitHub https://github.com/CURENT/andes/issues/562#issuecomment-2291495059, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSNZA72HTK7S2KU3GAU5PDZRTANDAVCNFSM6AAAAABMSIHBJ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJRGQ4TKMBVHE. You are receiving this because you were mentioned.