Number of nonzeros in equality constraint Jacobian...: 83419 Number of nonzeros in inequality constraint Jacobian.: 10795 Number of nonzeros in Lagrangian Hessian.............: 25423
Total number of variables............................: 18450 variables with only lower bounds: 1350 variables with lower and upper bounds: 1125 variables with only upper bounds: 0 Total number of equality constraints.................: 12600 Total number of inequality constraints...............: 4950 inequality constraints with only lower bounds: 675 inequality constraints with lower and upper bounds: 3600 inequality constraints with only upper bounds: 675+------------------------------------------+-------------------------------------+----------------------------+------------+---------------------+----------------+|Mode |(1): Time in function evaluation* (s)|(2): Total solution time (s)|(3): (1)/(2)|(4): IPOPT iterations|(5): (2)/(4) (s)||------------------------------------------+-------------------------------------+----------------------------+------------+---------------------+----------------||1) MX | 103.8 | 141 | 0.7362| 381| 0.3701||2) gcc-7 -march=haswell | 7.69| 55 | 0.1398| 482| 0.1141||3) gcc-7 -march=x86-64 | 5.82| 42.6| 0.1366| 381| 0.1118||4) clang-6 -march=x86-64 | 3.76| 40.7| 0.0923| 381| 0.1068||5) clang-6 -march=x86-64 -fno-math-errno | 3.72| 40.6| 0.0917| 381| 0.1066||6) clang-6 -march=haswell | 3.72| 40.7| 0.0914| 381| 0.1068||7) clang-6 -march=haswell -fno-math-errno | 3.78| 40.6| 0.0932| 381| 0.1066||8) SX (expand=True) | 3.52| 65.3| 0.0539| 620| 0.1053|+------------------------------------------+-------------------------------------+----------------------------+------------+---------------------+----------------+Dear Adrian,Your table implies that in all cases, the time spent in the solver (probably the factorisation of the linear system) is dominant over the time spent in function evaluations.Column 5 is then just converging to the mean cost of an iteration when function evaluations are free?It also implies you should pick any of 2-8, and focus your efforts on bringing down the factorisation time (what other linear solvers have you tried?).
SX versus MX may not preserve order of operations, which leads to slight differences due to floating point arithmetic.
The generic advice is to keep your graphs compact by having a hierarchy of Functions (see also http://docs.casadi.org/#for-loop-equivalents ).
There's also a memory-speed trade-off internal to CasADi that may be influenced withGlobalOptions.setMaxNumDir(n);or with 'max_num_dir' option. Both are fragile commands, the GlobalOptions is less likely to be broken.Default n = 64 gives fast, but possibly large graphs (-> large generated c code -> slow compiling).n = 1 would give the most compact c code, but possibly slower.
Best,Joris