Difference between constr_x0 and x_init in S-function

Gooed evening guys !

First of all I want to congratulate with you on the beautiful work done till now :slight_smile:
I am still studying all the potential that acados offers but, in general, i’m trying to build an s-function in simulink for real time purposes.
From what i understand from the pdf “Problem formulation” the state initialization can be done by setting lbx_0 and ubx_0 equal to the actual measured state.
However I can’t figure out what the variable x_init is for and how to use it (for example, is it better to initialize the entire prediction horizon with the current measured state, or initialized with the prediction in the previous step?). For the variable u_int, on the other hand, is the same thing true?
There is some “generale rule” useful for the convergence of the solver ?
Thanks in advance,

Hi Giulio,

Setting lbx_0 and ubx_0 to the same value fixes the initial state to that value. I would not call this “initialization”, but rather “setting bounds on the initial state value” or “fixing the initial state value”.

x_init and u_init on the other hand are used to initialize the primal variables in the SQP solver.
They are used to initialize the full trajectory.
It is not easy to say what initialization is the best for your use-case.
For solver convergence and speed it is of course ideal to initialize it close to the solution.
In a classic MPC setting, one typically uses the previous or shifted solution.
However, when starting the process, for nonuniform time discretization or when a reference trajectory is changed a lot, figuring out a dedicated initialization strategy is harder.


thanks Jonathan !
I understand the point :slight_smile: