casadi / casadi

CasADi is a symbolic framework for numeric optimization implementing automatic differentiation in forward and reverse modes on sparse matrix-valued computational graphs. It supports self-contained C-code generation and interfaces state-of-the-art codes such as SUNDIALS, IPOPT etc. It can be used from C++, Python or Matlab/Octave.
http://casadi.org
GNU Lesser General Public License v3.0
1.58k stars 357 forks source link

using Casadi #3690

Open tommasoandina1 opened 3 weeks ago

tommasoandina1 commented 3 weeks ago

Hi everyone,

I'm attempting to utilize the CasADi library for simulating robots, but I'm encountering numerous values that don't seem to make sense. For example, here's a segment of my code:

[[(((@135H_0)+(@139H_4))+(@145H_8)), (((@135H_1)+(@139H_5))+(@145H_9)), (((@135H_2)+(@139H_6))+(@145H_10)), (((@445H_0)+(@449H_4))+(@455H_8)), (((@445H_1)+(@449H_5))+(@455H_9)), (((@445H_2)+(@449H_6))+(@455H_10))]

I'm struggling to comprehend its meaning. My objective is to calculate the mean error of a desired vector compared to a vector I need to compute using the CasADi library. However, in the second vector, I'm obtaining numerous values like the ones above.

Could someone offer assistance?

Thanks.

jaeandersson commented 3 weeks ago

It looks like a 3-by-2 matrix where each element is sum of three different symbolic expressions.

The "@..."etc variables define shared subexpressions, i.e. expressions that appear more than once in the printout. They should have been defined earlier in their printout. So for example if you have an expression like:

A = SOME_VERY_LONG_EXPRESSION

And then do say "A + A" it will be displayed as

@1 = SOME_VERY_LONG_EXPRESSION; [@1 + @1]

Instead of

[SOME_VERY_LONG_EXPRESSION + SOME_VERY_LONG_EXPRESSION]

When the expressions are deep, the difference between the two can grow exponentially.