Hello,
I'm using CasADi 3.1-RC1 on Matlab 2015b and Mac OS. A detailed explanation of my question is at the bottom. The short version is as following. I implemented several CasADi's user-defined functions by subclassing casadi.Callback. It's necessary due to performance issues and that I need to supply user data to the functions. I observed that, at least in Matlab, the overhead of evaluating a user-defined function is quite high, about 4ms on my system. By profiling the code, I saw the majority of computation time was spent on CasADi's DM-related classes (e.g., DM.delete,
DM.DM, GenDM, ExpDM, SpDM...). That seems to me like a large overhead for a simple function evaluation. I figure that by eliminating or reducing this overhead significantly, I may save 20-30% the time to solve my NLPs. Is there a way to speed up the evaluation of user-defined functions in CasADi (in Matlab at least)?
Thanks.
Truong.
Detailed explanation of my question:
I'm working with NLPs that involve very large and complex nonlinear functions. Initially I used CasADi's symbolics to construct the nonlinear Functions, but it took over 2 minutes and gigabytes of memory for CasADi to construct each function, and the evaluation is not very fast (I believe due to the size of the functions). So I combined code generation and custom high-performance C code to implement these nonlinear functions in C, which are instantaneous to initialize and up to 10x faster to evaluate than CasADi. I then implemented user-defined functions by subclassing casadi.Callback. I had to do this rather than using external functions because I need to supply user data to my functions. When using the user-defined functions, I observed large overhead in evaluating the functions as explained above.