Trouble solving "simple" problem

I’m having trouble solving what seems to be a fairly straightforward problem. I’m using a 2D single integrator model, trying to move from (0,0) towards (10,5), with a two norm input constraint, something like:
opt_problem

What I would expect is a straight line from the origin pointing towards (10,5). With a one second horizon, the answer should be (0.89443,0.44721). For some reason though, Acados is unable to converge the nonlinear inequality constraint. The solver doesn’t seem to make progress towards the solution, and doesn’t seem to respect the constraint bounds, though without a converged solution that may not mean much.

What is strange is that IPOPT is able to solve the same problem in just a handful of iterations, producing the expected result. Even when initialized with the solution from IPOPT, Acados does not converge, which makes me wonder if I am missing something. I tried with HPIPM, OSQP, and QPOASES, with similar results from all three.

Is there a reason this specific type of problem might be difficult for Acados to solve?

OCP script:

Model:

Hi @aknight0,

I just had a look at your example.
The problem is that the Hessian with respect to u is basically indefinite.

You can recover convergence by:
a) adding a penalty on u.
In your example:

expr_ext_cost = (x(1)-10)^2 + (x(2)-5)^2 + 1 * dot(u,u);

b) I recently implemented the option to add Levenberg-Marquadt regularization term to the Hessian, basically adding a multiple of the unit matrix to the Hessian.
It is not merged yet, but you can find it here:

With this feature, you can also do:

ocp_opts.set('levenberg_marquadt', 1.0);

Cheers!

Brilliant! I pulled your Levenberg-Marquadt branch down, and using that option solved my problem. If I recall correctly, I think IPOPT does something similar to try to regularize the Hessian? Now I’m getting equivalent answers from IPOPT and Acados, which is great. Is the 1.0 you set a binary switch, or can this be applied in varying magnitudes?

As a side note, adding a penalty on u also helped, but took more iterations and also required that I reduce the solver step size. The regularization method solved in fewer iterations with the default step size.

Thanks for putting up with my endless stream of questions! This is a great project, and you’ve been extremely helpful.

Great!
The Levenberg-Marquadt value is the factor for the unit matrix that is added to the Hessian.
Both options to fix the convergence issue have some tuning parameter and I would not say one is strictly better than the other.

Happy to hear that! :blush:

Hi @aknight0 @FreyJo,

I have tried the code from aknight0, it works well.

But I don’t know why if I change the original constraints:

ocp_model.set('constr_lh', 0);
ocp_model.set('constr_uh', 1);

to:

ocp_model.set('constr_lh', 0.000001); % lower bound on h ocp_model.set('constr_uh', 1); % upper bound on h

The result shows nothing, xtraj and utraj are all 0.

I would appreciate it if you guys could give me some instructions.