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!