 # Cost and linearization points

Hi everyone,
I was wondering if acados takes only the continuous time cost as definition specified in the release notes of the latest version. If so could you please elaborate on how this cost is formulated? Currently, I have LL cost in discrete time and maybe have to covert it into continuous time if such is the case.

I am working on reference tracking problem and using “SQP_RTI” solver in acados. What is the linearization trajectory used by acados in this case? Does it take reference trajectory as linearization trajectory? Can I specify linearization trajectory separately?

Assuming that it takes reference trajectory as linearization trajectory, I get totally different result in Matlab SQP RTI implementation than acados. Note that, In Matlab I use reference trajectory as linearization trajectory.

However the result of SQP (fully converged solution) solver is similar to SQP (fully converged) solution of Matlab but not exact.

Regards,
Jay

Hi Jay,

What do you mean by LL cost? Regarding the linearization point, it’s the current approximate solution (like it should be in a standard SQP algorithm). If you linearize at the reference, you might still converge to a solution, but in that case you would be doing a different kind of Newton-type iterations.

Hi @zanellia,
Sorry I meant LLS (Linear Least Square) objective for reference tracking.
Yes I am doing only the one iteration of RTI_SQP in acados and comparing it with Matlab implementation of same algorithm with one iteration by linearizing at reference. However assuming there is no bug in my code they should match but I get different results.
Again to be clear does RTI_SQP solver with one iteration use reference to linearize?

Regards,
Jay

Hi Jay,

The linear least-squares cost terms are defined as described in the documentation at page 3 and the discretization of the cost is carried out using (for now) explicit Euler.

Regarding the linearization point, as I mentioned in the previous post, `acados` implements a rather standard SQP algorithm where linearization is carried out at the current approximate solution. If you carry out a single iteration within `acados` and you want to compare the result to the one obtained with your MATLAB implementation, you can initialize the primal solution to the reference (notice that, of course, if you use the exact Hessian, you will also need to define an initial point for the dual variables and use the same in both `acados` and your MATLAB implentation). Here is how you can initialize the iterates: https://github.com/acados/acados/blob/master/examples/acados_matlab_octave/pendulum_on_cart_model/example_closed_loop.m#L324. If you are using `SQP_RTI`, the linearization point will be updated automatically every time you make a call to `ocp.solve()`.

2 Likes

Hi Andrea,

Thanks for the answer. Now it’s clear!

Sorry to mention it now but I’m implementing in python so are there equivalent parameters to following in python to set linearization trajectory initially?

``````ocp.set('init_x', x_traj_init);
ocp.set('init_u', u_traj_init);
ocp.set('init_pi', pi_traj_init);
``````

I tried the same commands but it throws an error of invalid fields “init_x/u/p”

cheers,
Jay

Hey Jay,

in Python you can initialize the solver like here:

Cheers,
Jonathan

2 Likes

Hi Jonathan & Andrea,