I am using acados with Python interface to solve a MHE simple test program using my own model instead of export_pendulum_ode_model().
I tried to replicate as much as possible the structure of minimal_example_mhe.py.
The first section of my program, that implements an OCP to generate data to be fed to the MHE, works without problems. The following MHE section instead produces totally empty arrays after executing status = acados_solver_mhe.solve().
In addition, with acados_solver_mhe.get_stats('sqp_iter'), I checked that the MHE solver returns after just 0 SQP iteration. No error messages are produced.
The only difference compared to the original minimal_example_mhe.py is that I have an output y=h(x,u) that is a very complex function of the status x and so I was forced to generate the nonlinear cost_y_expr directly in the export_mhe_ode_model and add “model.cost_y_expr = cost_y_expr” in it at the end, instead of adding “model.cost_y_expr = cost_y_expr” inside export_mhe_solver.
I checked everything to try to solve this but I didn’t find any other difference with the original example.
I thank you in advance for your support.
it is hard to tell from this what is going on.
One thing that could lead to 0 SQP iterations, is that the initialization is already the solution.
I would try something like
acados_solver_mhe.print_statistics()
to see if the residuals are evaluated initially, and if they are small.
However, this does not explain why you get empty arrays from the MHE solver.
Maybe check in the MHE .json file if the dimensions are correct.
thank you for your prompt reply.
As I am using an ACADOS version of March 2020, I don’t have the function print_statistics in AcadosOcpSolver. I am quite afraid to upgrade it to the last version because when I installed it the first time it took me quite a lot to have it up and running in PyCharm. Is there an easy way to just modify the AcadosOcpSolver file I already have to insert the print_statistics function?
Thanks
I reinstalled Acados to the latest release.
It seems that it still works fine in Pycharm.
minimal_example_closed_loop.py runs to completion without errors.
Now I can’t run successfully anymore minimal_example_mhe.py.
This is the screenshot I got
So you were missing -DACADOS_WITH_QPOASES?
I can try to have another look at the actual issue of this topic next week.
If you can share the source code with me, that might be the easiest.
The following line seems not valid: "Vu""Vx""Vx_e": [],
Is this actually the generated json file?
Some more questions to trouble shoot this issue…
Do the libraries for the solver compile correctly?
I.e. when you do:
acados_solver_mhe = export_mhe_solver_Li_SPM_1(model_mhe, N, h, Q_mhe, Q0_mhe, R_mhe)
Moreover, are the model.name different for the MHE and MPC solver?
Maybe try again after removing the whole c_generated_code folder.
Did you try to get the values from the MHE solver?
Do they have the correct dimensions?
Are they zero or matching your initialization or have they been changed by the solver?
from the compilation output, everything seems fine.
Setting print_level and getting values from the solver and the print_statistics are usually enough for users.
However, at this point, it seems like one has to dig deeper.
Where does the solver terminate?
Why does it before updating the variables, which should at least be done once?
For OCP solvers, I would first compile and run the associated generated main C file.
And run it with a debugger.
However, I am not sure if this main file needs to be adapted for the MHE case.
Alternatively, one can add prints in the SQP source code to see what is going on…
Hi Jonatahan,
thanks for your suggestion.
Before start digging in acados C files (this would be quite a daunting task to me!) I want to try one thing.
Could it be that the solver terminates at iter=0 because, during the minimization, the state function evolution f(x,u,w) becomes infinite? Differently from the OPC solver, in the MHE solver I didn’t put bounds on x variables and I know that my model equations can become infinite if x goes outside a specified range.
I’ll let you know the results of this test.
great that you solved it without digging into the C code!
It seems reasonable to have these bounds in your problem.
I still would have guessed, that the infinity values from the linearization go to the QP solver, which then throws an error, instead of returning None status.