Constraint Tuning#
This section shows how the options of GRAMPC can be adjusted in such a way that the performance in terms of computation time and optimality is improved. To this end, a specific OCP problem is considered. However, the approach can serve as template for different problems.
Problem formulation#
The system at hand is a double integrator with one inequality constraint and a terminal equality constraint for each state [1]. The OCP problem is then defined as
with the weight \(r= 0.5\) and the initial state \(\mb{x}(0) = [0, 1]^\mathsf{T}\). The target of the problem is to steer the double integrator states to the terminal state \(\mb{x}(T) = [0, -1]^\mathsf{T}\) without violating the inequality constraint \(h(\mb{x}(t))\) . The time in which the set point change should be executed is set to \(T=1\,\mathrm{s}\).
Tuning approach#
Fig. 16 The prediction plot of GRAMPC for the double integrator example in (29).#
In the listing below, the step by step approach of tuning the parameters of the augmented Lagrangian algorithm are detailed. The computation time as well as the number of outer and inner iterations are shown in Table 2 along with the corresponding option that was added or changed in each step.
Step |
Time |
MultIter |
GradIter (mean) |
Additional option |
|---|---|---|---|---|
343 ms |
3883 |
10.3 |
Default settings |
|
129 ms |
637 |
22.4 |
|
|
59 ms |
171 |
42.0 |
\(\text{PenaltyIncreaseFactor}=1.5\) |
|
36 ms |
98 |
46.6 |
\(\text{PenaltyIncreaseThreshold}=0.75\) |
|
22 ms |
42 |
61.2 |
\(\text{LineSearchInit}=5\text{e-7}\) |
|
22 ms |
42 |
61.2 |
\(\text{PenaltyMin}=2\text{e4}\) |
The choice of the initial penalty parameter is crucial for numerical conditioning and therefore convergence. A value that is too high will initially put an unnecessary amount of weight on constraint satisfaction and mostly ignore the optimality. If the value is too low, the opposite will happen, i.e. at first the cost function is decreased at the cost of constraint violation. This will be especially detrimental in MPC applications. If no prior knowledge is available, it is recommended to use the function
grampc_estim_penmin(or the corresponding Cmex interfacegrampc_estim_penmin_Cmex). For the example at hand, this reduces the computation time by approximately a third. Fig. 16 shows the simulation results using the estimated value forPenaltyMin.While the convergence speed is significantly increased, the penalty parameters at \(0.3\,\mathrm{s}\) and \(0.7\,\mathrm{s}\) are several magnitudes greater than the initial value. Since this huge penalty parameter occurs only at two points during the simulation, it is advisable to set the
PenaltyIncreaseFactorto a bigger value. This again reduces the computation time by more than half, since fewer increases of the penalty parameter during the outer iterations are necessary. The value should not be chosen too big, as this will have an adverse effect on the numerical conditioning and convergence.In accordance with the previous step, the threshold to increase the penalty parameter, i.e.
PenaltyIncreaseThresholdis lowered in order to increase the penalty parameter more aggressively. This step almost doubles the convergence speed. Note that this step and the previous step are interchangeable.Another common tuning possibility is the initial step size of the line search, especially if one of the explicit methods is used, cf. Explicit line search. Note that the initial value
LineSearchInitis used in the case that the explicit formula results in a negative step size. One approach is to use theLineSearchExpAutoFallbackoption. However, problem specific tuning (mostly trial and error) can result in a significant performance boost. In the example at hand, this results in approximately 40% faster convergence speed.To further optimize the parameters, the estimation function for the minimal penalty parameter can be deactivated again and a better value for
PenaltyMinbe used (note that the parameter is increased until there is no further improvement or an decrease in performance). This results in an additional 15%` decrease of computation time.