“Max iteration reached” occur frequently

I am using acado python interface to get mpc control of a Heterogeneous robot system
I find that it usually get the error “max iteration reached”, especially when I set initial state far away from goal state. I don’t know what’s the problem and I want to know how to solve it? Can anyone help me please? Or at least give me some advice about how to check more specific reason?(for example how to check whether this is because I give a ill-conditioned problem)
More information that may be helpful:

  1. I am basically making a little change for the example to solve my problem, I rewrite the model and constrains, other options parameter include:
self.ocp.solver_options.qp_solver = 'PARTIAL_CONDENSING_HPIPM'
self.ocp.solver_options.hessian_approx = 'GAUSS_NEWTON'
self.ocp.solver_options.integrator_type = 'IRK'
self.ocp.solver_options.nlp_solver_type = 'SQP'
  1. One state variable is not included in cost function, so I set the corresponding position in Q matrix as zero, I don’t know if it is a proper way.

I suggest to print the solver statistics to get some more info.
Of course initialization can help.
Plus, you might just increase the number of iterations.

thank you, I have checked the output of print_statistics(), and I find that the result remain unchanged from a certain iteration. While other res is close to 0, the res_stat remain a non-zero value, I guess this is abnormal? But I don’t know why and how to solve it. Thank you

I would suggest to enable line search to help the convergence of SQP methods (set globalization='MERTI_BACKTRACKING' and line_search_use_sufficient_descent=1), and print the statistics again. You might see the residuals to decrease slowly (sometimes too slow). But in general we cannot expect the solver to always converge to high precision (residuals goes to very small value like 1e-8) in a few iterations.

By my experience, getting max iteration reached is not a big problem. I can usually get reasonable solutions so I tend to ignore this warning.

About the ill-conditioned problem, this post might give you some hints: Solver sensitivity to weight parameter & solver options - #5 by Grunnet.

Just to add on top of the previous answer:

If that value is close to the NLP solver tolerance you can try to set a lower QP tolerance, i.e. qp_tol_stat.