FAQ: general speedup tricks
András Retzler edited this page Oct 7, 2022
·
2 revisions
In my MPC I have to solve my NLP within a given time frame. With the default options it is too slow.
Reusing expressions instead of generating them again. (could be solved with “common subexpression” elimination (cse)). Instead of:
a = b*x
c = b*x + d
e = c + a
Total number of operations: 4
Rather use:
a = b*x
c = a + d
e = c + a
Total number of operations: 3
with cse (available in the develop branch of casadi):
a = b*x
c = b*x + d
e = cse(c + a)
Total number of operations: 3, since it recognizes that b*x
is assigned to a
.
FAQTODO: move this to a page on CSE
Not really a casadi tip, but make sure your optimization problem is regularized to speed up convergence.