yizeli020 / Benjaminlee1

0 stars 0 forks source link

Optimization performance issue #2

Open mynanshan opened 4 months ago

mynanshan commented 4 months ago

What is the actual algorithm used by the minimize?

https://github.com/yizeli020/Benjaminlee1/blob/2e4059e7f5fc32de30e6a8836858f0736a0cfd56/demo-ODEparamEst-spline.py#L56

This optimization step takes a while to be finished. The consumed time is too long for this simple ODE model. Try to switch to a better algorithm. It will usually be good to use explicitly calculated gradients, instead of just providing the objective function to a minimizer.

mynanshan commented 3 months ago

https://github.com/yizeli020/Benjaminlee1/blob/316cf4bc62ac31dd9e3423c50f49b5cf5cd3eefd/version%202#L48-L64

You mentioned that the modified optimization procedure was not faster than the old one. It is probably due to the implementation. Generally speaking, matrix-vector operations with Numpy are fast as they can be computed in a parallel fashion. However, in the current code snippet, there is a for-loop with nested numerical integration treating each component in c separately, which means the computation-demanding part has to be computed sequentially. We can discuss how to optimize this part of the codes.