BYU-PRISM / GEKKO

GEKKO Python for Machine Learning and Dynamic Optimization
https://machinelearning.byu.edu
Other
573 stars 102 forks source link

is it possible to speed up solve with CUDA? #123

Closed Tibalt closed 2 years ago

Tibalt commented 2 years ago

Hi,

I do not know if somebody tried to speed up gekko optimization with CUDA?

now I am using gekko to control two cv with one mv and it will cost more than 20 seconds. I do believe there is a way to speed up the calculation.

Or should I adjust the weights?

Regards tibalt

APMonitor commented 2 years ago

Gekko currently runs on a CPU but there are some elements that could be transferred to a GPU but those are mostly in the solver realm such as indirect sparse solvers. Some of that is already happening with specialized linear solvers and integration with the nonlinear solvers to obtain search directions, but it is not ready yet.

There are other strategies to speed up the code that can make a big difference with only a small sacrifice in accuracy. For MPC, one common strategy is to use a non-continuous time horizon such as m.time=[0,0.1,0.2,0.4,1,2,4,8,20] instead of m.time=np.linspace(0,20,201). The first step needs to be the cycle time of the controller but the other time steps can be whatever is needed to maintain model accuracy and approximate the arrival cost to the target (or steady-state).

Please post your complete and minimal example of your problem to Stack Overflow with tag gekko to see if we can provide more specific suggestions.

Tibalt commented 2 years ago

thanks for the helpful reply!