@FreyJo

Thanks a lot for all the help! After your hints on how to transcribe the current example to the LINEAR_LS formulation, I could get the code to compile and iterate. Sadly, I always get zero as a result.

My current `y`

consists of a “concatenation” of: `[h(x,z), w, x, z]`

(the measurement function, the process noise and the arrival cost for x[0] and z[0], respectively).

In a CasADi SX expression it would be:

`[x_0, x_1, x_2, z_0, z_1, z_2, z_3, z_4, z_5, w_0, w_1, w_2, w_3, w_4, w_5, w_6, w_7, w_8, w_9, x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8, x_9, z_0, z_1, z_2, z_3, z_4, z_5]`

To get this terms arranged this way, I did the following with the Vx, Vu, Vz and W matrices:

```
nx = model.x.size()[0] # 10
nu = model.u.size()[0] # 10 (the process noise)
nz = model.z.size()[0] # 6
nparam = model.p.size()[0] # 0
n_meas = 9 # the output size of h(x,z)
ny = 3 + 6 + nu + nx + nz # h(x,z), w and arrival cost for x0 and z0
ny_e = 0
ocp_mhe.cost.Vx = np.zeros((ny, nx))
ocp_mhe.cost.Vu = np.zeros((ny, nu))
ocp_mhe.cost.Vz = np.zeros((ny, nz))
ocp_mhe.cost.W = block_diag(R, Q, 0.0* Q0_x, 0.0 * Q0_z)
ocp_mhe.cost.Vx[:3, :3] = np.eye(3)
ocp_mhe.cost.Vx[n_meas + nx: n_meas + nx + nx, :] = np.eye(nx)
ocp_mhe.cost.Vu[n_meas: n_meas + nu, :] = np.eye(nu)
ocp_mhe.cost.Vz[3: 3+nz, :] = np.eye(nz)
ocp_mhe.cost.Vz[n_meas + nu + nx:, :] = np.eye(nz)
acados_solver_mhe.cost_set(0, "W", block_diag(R, Q, Q0_x, Q0_z))
```

After that, I call the solver with the same data I use in an implementation of MHE that uses CasADi + IPOPT. For example, I initialize the acados MHE in this way:

```
# Initialize the MHE problem by setting the measurements and arrival cost
for j in range(N):
yref = np.hstack([simY[j, ], np.zeros((nw,)), x0bar, z0bar])
acados_solver_mhe.set(j, "yref", yref)
# solve mhe problem
status = acados_solver_mhe.solve()
# print the solution
for j in range(N):
print(acados_solver_mhe.get(j, "x"))
```

And all the states that are variables of the optimization problem are equal to zero.