1 Introduction
2 Problem formulation
2.1 Optimal control problem
2.2 Application to model predictive control
2.3 Application to moving horizon estimation
3 Optimization algorithm
3.1 Augmented Lagrangian formulation
3.2 Structure of the augmented Lagrangian algorithm
3.3 Gradient algorithm for inner minimization problem
3.4 Convergence criterion
3.5 Update of multipliers and penalties
4 Structure and usage of GRAMPC
4.1 General structure
grampc
. Several parameter settings are problem-specific and need to be provided, whereas other values are set to default values. A generic interface allows one to manipulate the grampc
structure in order to set algorithmic options or parameters for the problem at hand. The functionalities of GRAMPC can be manipulated from Matlab/Simulink by means of mex routines that are wrappers for the corresponding C functions. This allows one to run a GRAMPC project with different parameters and options without recompilation.
4.2 Problem definition
probfct.c
. The following listing gives an expression of the function structure and the problem implementation for the ball-on-plate example (39).ocp_dim
, which defines the dimensions of the optimization problem. Problem specific parameters can be used inside the single functions via the pointer userparam
. For convenience, the desired setpoint (xdes
,udes
) to be stabilized by the MPC is provided to the cost functions separately and therefore does not need to be passed via userparam
.4.3 Calling procedure and options
Nhor
for the horizon [0, T], the maximum number of iterations \((i_{\text {max}},j_{\text {max}})\) for Algorithm 1 and 2, or the choice of integration scheme for solving the canonical equations (22), (26). Currently implemented integration methods are (modified) Euler, Heun, 4th order Runge–Kutta as well as the solver RODAS (Hairer and Wanner 1996) that implements a 4th order Rosenbrock method for solving semi-implicit differential-algebraic equations with possibly singular and sparse mass matrix \(\varvec{M}\), cf. the problem definition in (1). The Euler and Heun methods use a fixed step size depending on the number of discretization points (Nhor
), whereas RODAS and Runge–Kutta use adaptive step size control. The choice of integrator therefore has significant impact on the computation time and allows one to optimize the algorithm in terms of accuracy and computational efficiency. Further options not shown in the listing are e.g. the settings (xScale
,xOffset
) and (uScale
,uOffset
) in order to scale the input and state variables of the optimization problem.userparam
. Under C, userparam
can be an arbitrary structure, whereas the Matlab interface restricts userparam
to be of type array (of arbitrary length). Moreover, the Matlab call of grampc_run_Cmex
returns an updated copy of the grampc
structure as output argument in order to comply with the Matlab policy to not manipulate input arguments.5 Performance evaluation
5.1 General MPC evaluation
5.1.1 Benchmarks
Problem | Dimensions | Constraints | Dynamics | References | ||||
---|---|---|---|---|---|---|---|---|
\(N_{\varvec{x}}\)
|
\(N_{\varvec{u}}\)
|
\(\varvec{u}\)
|
\(\varvec{x}\)
| nonl. | semi-impl. | Linear | ||
Mass-spring-damper | 10 | 2 | Yes | No | No | No | Yes |
Käpernick (2016) |
Motor (PMSM) | 4 | 2 | Yes | Yes | Yes | No | No |
Englert and Graichen (2018) |
Nonl. chain (\(m=4\)) | 21 | 3 | Yes | No | No | No | No |
Kirches et al. (2012) |
Nonl. chain (\(m=6\)) | 33 | 3 | Yes | No | No | No | No |
Kirches et al. (2012) |
Nonl. chain (\(m=8\)) | 45 | 3 | Yes | No | No | No | No |
Kirches et al. (2012) |
Nonl. chain (\(m=10\)) | 57 | 3 | Yes | No | No | No | No |
Kirches et al. (2012) |
2D-Crane | 6 | 2 | Yes | Yes | Yes | No | No |
Käpernick and Graichen (2013) |
3D-Crane | 10 | 3 | Yes | No | No | No | No |
Graichen et al. (2010) |
Helicopter | 6 | 2 | Yes | Yes | No | No | Yes |
Tøndel and Johansen (2002) |
Quadrotor | 9 | 4 | Yes | No | No | No | No |
Käpernick and Graichen (2014a) |
VTOL | 6 | 2 | Yes | No | No | No | No |
Sastry (2013) |
Ball-on-plate | 2 | 1 | Yes | Yes | No | No | Yes |
Richter (2012) |
Vehicle | 5 | 2 | Yes | No | Yes | No | No |
Werling et al. (2012) |
CSTR reactor | 4 | 2 | Yes | No | No | No | No |
Rothfuss et al. (1996) |
PDE reactor | 11 | 1 | Yes | No | No | Yes | No |
Utz et al. (2010) |
5.1.2 Evaluation results
Problem | GRAMPC | ACADO (optimal) | ACADO (speed) | VIATOC (optimal) | VIATOC (speed) | |||||
---|---|---|---|---|---|---|---|---|---|---|
\(J_{\text {int}}\) |
\(t_{\text {CPU}}\)
| \(J_{\text {int}}\) |
\(t_{\text {CPU}}\)
| \(J_{\text {int}}\) |
\(t_{\text {CPU}}\)
| \(J_{\text {int}}\) |
\(t_{\text {CPU}}\)
| \(J_{\text {int}}\) |
\(t_{\text {CPU}}\)
| |
Mass-spring-damper |
\(\varvec{1.000}\)
| 0.060 | 1.030 | 0.370 | 1.351 | 0.110 |
\(\varvec{1.000}\)
| 0.075 | 1.221 |
\(\varvec{0.049}\)
|
Motor (PMSM) | 1.006 |
\(\varvec{0.032}\)
|
\(\varvec{1.000}\)
| 0.129 | 1.096 | 0.057 | – | – | – | – |
Nonl. chain (\(m=4\)) | 1.003 |
\(\varvec{0.301}\)
| 1.003 | 4.666 | 1.027 | 1.770 |
\(\varvec{1.000}\)
| 12.32 | 1.041 | 7.660 |
Nonl. chain (\(m=6\)) |
\(\varvec{1.000}\)
|
\(\varvec{0.707}\)
|
\(\varvec{1.000}\)
| 12.438 | 1.028 | 5.407 |
\(\varvec{1.000}\)
| 18.10 | 1.042 | 11.48 |
Nonl. chain (\(m=8\)) |
\(\varvec{1.000}\)
|
\(\varvec{1.158}\)
| 1.005 | 26.834 | 1.050 | 10.127 |
\(\varvec{1.000}\)
| 38.51 | 1.055 | 15.30 |
Nonl. chain (\(m=10\)) |
\(\varvec{1.000}\)
|
\(\varvec{1.463}\)
| 1.004 | 43.467 | 1.042 | 21.745 | 1.004 | 52.84 | 1.149 | 24.85 |
2D-Crane | 1.032 |
\(\varvec{0.019}\)
|
\(\varvec{1.000}\)
| 0.446 | 1.096 | 0.058 | – | – | – | – |
3D-Crane | 1.002 |
\(\varvec{0.036}\)
|
\(\varvec{1.000}\)
| 0.728 | 1.013 | 0.321 | 1.163 | 0.839 | 1.160 | 0.194 |
Helicopter | 1.017 | 0.054 | 1.006 | 0.163 | 1.096 |
\({\varvec{0.045}}\)
|
\(\varvec{1.000}\)
| 0.185 | 1.060 | 0.071 |
Quadrotor |
\(\varvec{1.000}\)
|
\(\varvec{0.022}\)
|
\(\varvec{1.000}\)
| 1.465 | 1.005 | 0.243 | 1.009 | 0.535 | 1.010 | 0.113 |
VTOL |
\(\varvec{1.000}\)
|
\(\varvec{0.033}\)
| 1.210 | 0.229 | 1.227 | 0.090 | 1.243 | 0.092 | 1.259 | 0.083 |
Ball-on-plate | 1.113 |
\(\varvec{0.014}\)
| 1.112 | 0.068 | 1.126 | 0.022 |
\(\varvec{1.000}\)
| 0.116 | 1.158 | 0.018 |
Vehicle | 1.027 |
\(\varvec{0.092}\)
|
\(\varvec{1.000}\)
| 1.313 | 1.003 | 0.322 | – | – | – | – |
CSTR reactor |
\(\varvec{1.000}\)
|
\(\varvec{0.058}\)
|
\(\varvec{1.000}\)
| 0.195 | 1.002 | 0.076 | 1.001 | 0.365 | 1.017 | 0.140 |
PDE reactor | 1.059 |
\(\varvec{0.362}\)
|
\(\varvec{1.000}\)
| 6.259 | 1.005 | 0.498 | 1.046 | 7.214 | 1.072 | 2.868 |
5.1.3 Embedded realization
Problem | \(t_{{{\textsc {d}{\rm{Space}}}}}\) (ms) | \(t_{{\rm{ECU}}}\) (ms) | Memory (kB) |
---|---|---|---|
Mass-spring-damper | 0.24 | 4.00 | 6.5 |
Motor (PMSM) | 0.13 | 2.10 | 2.4 |
Nonl. chain (\(m=4\)) | 4.79 | – | 12.9 |
Nonl. chain (\(m=6\)) | 9.62 | – | 18.5 |
Nonl. chain (\(m=8\)) | 17.50 | – | 24.1 |
Nonl. chain (\(m=10\)) | 24.20 | – | 29.8 |
2D-Crane | 0.18 | 1.65 | 4.5 |
3D-Crane | 0.31 | 3.05 | 7.3 |
Helicopter | 0.11 | 1.88 | 5.8 |
Quadrotor | 0.21 | 1.60 | 4.4 |
VTOL | 0.37 | 2.80 | 6.2 |
Ball-on-plate | 0.05 | 0.92 | 2.0 |
Vehicle | 0.25 | 2.69 | 3.6 |
CSTR reactor | 0.43 | 6.81 | 5.1 |
PDE reactor | 6.48 | – | 15.0 |
5.2 Application examples
5.2.1 Nonlinear constrained model predictive control
5.2.2 MPC on shrinking horizon
5.2.3 Semi-implicit problems
5.2.4 OCP with equality constraints
Gradient tot. \(\varepsilon _{\text {rel,c}}\) | Constraint tot. \(\varvec{\varepsilon }_{\varvec{g}}\) | Gradient iterations i (avg.) | Augm. Lagr. iterations j | \(t_{\text {CPU}}\) (ms) |
---|---|---|---|---|
1 × 10−5 | 1 × 10−3 | 64 | 189 | 135 |
1 × 10−6 | 1 × 10−4 | 65 | 298 | 214 |
1 × 10−7 | 1 × 10−5 | 306 | 190 | 628 |
1 × 10−8 | 1 × 10−6 | 222 | 431 | 1015 |