Need Speed Up for my Code

333 views
Skip to first unread message

Dev Soni

unread,
Sep 13, 2022, 11:03:20 PM9/13/22
to CasADi
I implemented MPC with Casadi but I'm working on a project in which I need to run 1426 MPC iterations 200 times means 200*1426 MPC iterations.
Casadi function is taking too much time is there any way to increase the speed of this code?

Bruno M L

unread,
Sep 19, 2022, 7:42:35 AM9/19/22
to CasADi
Hi!

I did not look at your code, but you could try some things.

Take a look at map functionality of casadi. It evaluates the casadi function in parallel with threads. It might help if the symbolic function is nasty. It also helps when you are writing your MPC algorithm with multiple-shooting strategy.

Make sure you are warm starting the solver properly after each sampling time of the MPC. It speeds up the code a lot. Take a look at this post

Also, with ipopt, try changing the hessian_approximation option to limite-memory. It changes the hessian calculation for a first order approximation. It might help the speed with each iteration at the cost of more iterations.

Since you have many scenarios, try executing them in parallel. Take a look at this post.

I hope it helps!
Reply all
Reply to author
Forward
0 new messages