I have a dynamical system which as dynamics which look a bit like dot(x) = sqrt(x).
If I run the ocp solver starting from x = 0, MATLAB completely crashes, apparently in the ocp_create mex-file. (Windows, 64 bit, compiled with MinGW, and all defaults btw).
It is quite understandable that the mathematical problem might be unsolvable for such a case where the derivative is infinite, but it would be nice to get an exception in MATLAB i.s.o. MATLAB completely crashing and needing a restart.
I havenât included a minimal code example nor the MATLAB crash log yet, as my guess was that the âproblemâ formulated above would already be sufficiently specific. If you need either or both, I can make the effort.
Is any change in internal exception handling scheduled for future releases?
Unfortunately, the mat-file is a problem because CasADi objects cannot be easily dumped into it.
I get Warning: Serializing SWIG objects not supported.
Thus the solver can not be created it seems.
Well, the remainder of the code in the script is exactly to restore what cannot be saved into a mat file, namely the casadi variables and the dynamics defined using those variables.
I think that warning can be ignored and has nothing to do with the actual problem. If it also crashes with you now, it makes sense to check that it doesnât when you replace the square root in the dynamics with an identity (by uncommenting the proper piece in the script).
The mat-file contained a custom class of which the definition was in my path (but not yours). I have converted it into a standard MATLAB struct and have made a new upload: Wetransfer update
thanks for the updated files!
I could reproduce the crash.
It seems to be an issue in the regularization.
For now, you can avoid the crash by not using the project regularization, you can for example set ocp_opts.opts_struct.regularize_method = 'convexify';
before creating the solver with ocp = acados_ocp(ocp_model, ocp_opts);
I will need some more time to find the actual bug and fix issue.
I will update this topic then.
So, I found the bug and this should be the proper fix:
For your problem, the solver returns error status 4 since the QP solver is returning error status 3.
Thus, the first QP seems infeasible.
Probably, you can solve it with a better initialization.
Good to hear you found multiple ways to relieve the problem !
Regarding infeasibility, knowing the system dynamics that shouldnât happen. The only (inequality) constraints we have are some bounds on the controls (actually we also introduced 2 helper states to be able to implement rate constraints as well). The control u = 0 should be feasible (though on the lower bound), but of course have a poor tracking error. There is something problematic in there which is due to a square root in the dynamics such that getting the state away from the initial state might be very difficult as some gradient/jacobian becomes infinite on this square root. It must be numerical problems that look like infeasibility?
I did try to make a minimal example with dot(x) = sqrt(x) + u, but that did not give the same error though.