MPCC cost implementation

Hi :wave:

I am working on a nonlinear MPC to achieve optimal raceline generation and following by using the model predictive contouring control (MPCC) formulation as stated in: https://arxiv.org/pdf/1711.07300 (at formula 13).

I found an implementation of this problem using acados in https://github.com/mlab-upenn/mpcc?tab=readme-ov-file but they linearize both the errors and the track around the previous solution of theta for that shooting node. Although this is a clever approach, I want to experiment with the results when not linearizing the problem.

I am using the python interface.

  • My first question is whether acados runs faster when using the nonlinear least squares cost formulation instead of an external cost formulation. I would think this is the case as the specific structure of a nonlinear least squares formulation can be exploited and solved more efficiently?

  • My second question is related to the linear term in the MPCC cost formulation (see figure). If I want to use the nonlinearLQ formulation, I can achieve this linear term by

    1. Using the square root of the state theta_dot as nonlinear function and -Q_theta as diagonal element in the cost matrix W
    2. Adding an extra state with constant value 1 to the states, such that a linear term is achieved by using nondiagonal elements in W hat couple theta_dot and 1.

    A problem with this is that for both methods, the cost matrix W becomes non-positive-semi-definite and the nonlinearLQ requires W to be positive-semi-definite (PSD). My question thus is whether ACADOS will make it PSD by matrix manipulation such as adding a multiple of the unit matrix or will the solver always fail when the provided W matrix is not PSD?

Thanks for helping me!

Hi :wave:

and welcome to the acados forum!

In general, I would recommend to use the (non)linear least-squares cost module whenever possible. This allows you to use a Gauss-Newton Hessian approximation, which is often cheap to compute (compared to an exact Hessian) and guaranteed to be psd.

In your specific case with the additional linear term, you could

  • use an external cost formulation and in addition provide a custom Hessian corresponding to a Gauss-Newton Hessian with no contribution from the linear term, cf. this example for how to define a custom Hessian
  • use a convex-over-nonlinear cost formulation where the outer convex function is quadratic for the NLS terms and the identity function for the linear term, cf. this example and Section 3.5 of the problem formulation.

Hope this is helpful!

Best, Katrin

2 Likes