• Keine Ergebnisse gefunden

6.2 Receding Horizon Controller

6.2.2 Class SuboptimalityMPC

The class SuboptimalityMPC is derived from the class MPC and contains the methods described in Chapter 3 to obtain stability and suboptimality results. In particular, all methods from class MPCare inherited such that a RHC controller utilizing the additional estimation methods can be implemented identically. Hence, only the class name within the construction/destruction of the object needs to be replaced:

btmb::MPC2::S u b o p t i m a l i t y M P C * m p c _ p r o b l e m = new S u b o p t i m a l i t y M P C ( INF ) ;

delete m p c _ p r o b l e m;

Listing 6.11: Constructing/Destructing call of a classSuboptimalityMPC object Moreover, internal variables are set to default values. The meaning and usage of these variables are explained within the description of the estimation procedures.

6.2.2.1 A posteriori Suboptimality Estimate Calling the method

mpc_problem - > a p o s t e r i o r i E s t i m a t e ( x , alpha ) ; Listing 6.12: Calculating α according to Proposition 3.3

leads to an evaluation of Proposition 3.3 using Algorithm 3.8 to compute the suboptimality degree α= alpha.

To this end, the values of V(x(n)) and V(x(n+ 1)) as well as l(x(n), µN(x(n))) must be known. In this implementation, these values willnotbe computed by the procedure within every step. Instead, the previous optimal value functionV(x(n−1)) and the corresponding first stage costl(x(n−1), µN(x(n−1))) are stored within a classSuboptimalityMPCobject mpc_problem and V(x(n)) is computed by the procedure by a postoptimal evaluation of the cost function, i.e. no additional optimization is required. To this end, the variable x can be used to incorporate measurement or prediction errors. Hence, this setting is purely a posteriori. Internally calculating the optimal finite horizon cost V(x(n)) gives us, as a byproduct, the stage costl(x(n), µN(x(n))) and both are used to replace the stored values of the last step, see also Section 6.2.3.3 below for further details.

Remark 6.9

This setup can be extended to analyze the suboptimality of a so called m–step feedback, see e.g. [99, 100], by storing a sum of the stage costs. This is implemented within the method mstepAposterioriEstimate, see Listing 6.13.

mpc_problem - > m s t e p A p o s t e r i o r i E s t i m a t e ( x , alpha , m ) ; Listing 6.13: Calculating α similar to Proposition 3.3 for an m–step feedback The internal boolean variable single can be used to obtainlocal or closed–loop subopti-mality results. If αis to be computed for every single point of the trajectory, the variable single is set to the default value true. Ifsingle is set to false by calling

mpc_problem - > s e t S i n g l e ( false ) ;

Listing 6.14: Setting the internal variable single

the minimal α along the points under consideration is the result of this method. Note that the variable alpha must not be changed within the calling program.

Remark 6.10

The underlying problem has to meet the form which is the basis of Proposition 3.3. Hence, the user must check the implemented cost functionalobjectiveFunction andthe additive discrete–time cost functional pointcostFunction defined within the class Model object used by a class SuboptimalityMPC object.

6.2.2.2 A priori Suboptimality Estimate

In contrast to Section 6.2.2.1 using Algorithm 3.8, we now compute an estimateα =alpha a priori based on Algorithm 3.16. In particular, it is not necessary for this procedure to store any past data of the class SuboptimalityMPC problem since all values can be computed based on the actual initial valuex and the calculated optimal control sequence u which is available within a class SuboptimalityMPC object mpc_problem.

In order to obtain Vk(xuN(N −k, x(n))) and l(xuN(N −k, x(n)), µk(xuN(N −k, x(n)))) for all k ∈ {N0, . . . , N}, it suffices to solve the dynamic of the problem using the pre-computed optimal control sequence u. However, to retrieve the value of l(xuN(N − j, x(n)), µj1(xuN(N−j, x(n)))) for all j ∈ {2, . . . , N0} we have to solve a whole series of optimal control problems. This requires the user to call the routine

mpc_problem - > a p r i o r i E s t i m a t e ( x , alpha , gamma , N0 ) ; Listing 6.15: Calculating α according to Theorem 3.22

where x is a possibly updated estimate of the current state. Internally a series of new, smaller optimal control problems and their discretizations are generated. To solve the resulting minimization problems, another instance of the supplied optimization routine object_minimizer and of the differential equation managerobject_odemanager need to be generated.

Again, the internal boolean variablesinglecan be used to obtain the local suboptimality estimates α by setting it to true and the closed–loop suboptimality estimate if single is set to false.

Last, the variable N0 which specifies the shortened optimal tail to be considered in the analysis needs to be set by the user.

b b b b b b

b b b b N0 = 4

x(n)

xuN(1, x(n))

b b b N0 = 3

xuN(2, x(n))

b b N0 = 2

xuN(3, x(n))

xuN(4, x(n))

xuN(5, x(n))

Figure 6.7: Schematic representation of solution “tails” used within the a priori subopti-mality estimation of Theorem 3.22 for N = 5

6.2 Receding Horizon Controller 151 Remark 6.11

For large values ofN0 =N0 ∈ {2, . . . , N−1}the additional optimal control problem causes this procedure to be not negligible considering the computing time. Hence, in the context of time–critical applications, only small values of N0 should be used, see also Section 8.4 for numerical tests of this routine and the impact of the parameter N0 and Section 8.5 for results in the adaptive receding horizon control setting.

6.2.2.3 A posteriori Practical Suboptimality Estimate Similar to the routine for the non–practical case, the call

mpc_problem - > a p o s t e r i o r i P r a c t i c a l E s t i m a t e ( x , alpha ) ; Listing 6.16: Calculating α according to Proposition 3.28

computes the suboptimality degree α = alpha according to Proposition 3.28, i.e. Al-gorithm 3.30. Here, we use the same setup as in Section 6.2.2.1 for storing past data, supplying the actual state vector xand influencing the output to be alocal orclosed–loop estimate via the internal boolean variable single.

Different to the non–practical case, the internal variable epsilon is utilized for cutting the stage costs. This variable is set to epsilon =ε= 106 and can be reset using

mpc_problem - > s e t E p s i l o n ( 1E -10 ) ;

Listing 6.17: Setting the internal variableepsilon

In general, its magnitude should be of the size of the optimality tolerance of the under-lying class MinProg object object_minimizer. However, this rule of thumb only holds if the tolerances of the class OdeSolve object used by the class IOdeManager object object_odemanager are lower than the optimality tolerance of the minimizer.

The underlying problem has to meet the form used within Proposition 3.28. To this end, the implemented cost functionalobjectiveFunction andthe additive discrete–time cost functional pointcostFunction defined within a class Model object object_model used by a SuboptimalityMPC object must be reviewed.

Remark 6.12

Similar to the non–practical case, an extension to m–step feedbacks is implemented within the method mstepAposterioriPracticalEstimate, cf. Listing 6.13.

6.2.2.4 A priori Practical Suboptimality Estimate

The a priori practical estimate uses the same extension as the a posteriori estimate from the previous Section 6.2.2.3. Hence, the call

mpc_problem - > a p r i o r i P r a c t i c a l E s t i m a t e ( x , alpha , gamma , N0 )

;

Listing 6.18: Calculating α according to Proposition 3.39

from Listing 6.15 uses the internal variableepsilonto cut the stage cost. Here, Algorithm 3.40 is implemented to compute the estimate α = alpha. Similar to Section 6.2.2.2, the values of l(xuN(N −j, x(n)), µj1(xuN(N −j, x(n)))) have to be obtained via a series of new smaller optimal control problems. These problems are generated, discretized and solved by instances of the objects created within the class SuboptimalityMPC object.

Similar to Section 6.2.2.2, the variable N0 specifies the shortened optimal tail and the boolean single is utilized to distinguish between local and closed–loop suboptimality results.