• Keine Ergebnisse gefunden

5.2 Implementation

5.2.2 MPC-POD Algorithm

In this section we give an overview about the implementation of the algorithms introduced in Section 4.2 which combine POD with MPC. The emphasis is on the program flow and the connection between the involved classes. We will not go into implementation details or display the source code. The interested reader can find the concrete example on the enclosed CD-ROM.

Figure 5.7: Program structure of MPCPOD.

In Figure 5.7 the structure of theMPCPOD code is displayed. Each box represents a class and the arrows indicate the information flow between the classes. The file MPCPOD.cpp is the main program where the MPC algorithm takes place. Fur-thermore, the snapshots to determine the reduced model are created here. For this

5.2 Implementation purpose it requires the simulations of the full model which are provided by the class Model. The abstract classModel is the one we already introduced in Section 5.2.1.

Depending on the type of snapshots (see the discussion in Section 2.3.1) it has to provide solutions of the state and adjoint equation for the high dimensional model.

Based on the snapshots the class PODBasis builds up the correlation matrix. The corresponding eigenvalues and eigenvectors are computed in the class EigenValues.

By using the eigenvalues and eigenvectors the classPODBasisdetermines the dimen-sion of the reduced model and calculate the reduced stiffness and mass matrices.

The class ReducedModel contains the small dimensional POD model. It requires the corresponding matrices from class PODBasis and model information, e.g. the nonlinearity and the cost functional, from class Model. In our implementation Re-ducedModel is a subclass of the yane model superclass. The MPC library yane is well suited for these small dimensional problems. However, the implementation of other ODE optimal control solvers is also possible. Finally, the reduced OCP is provided to MPCPOD.

Note that the presented structure only describes the generation of the reduced POD model. The actual implementation of the algorithms presented in Section 4.2 takes place in MPCPOD.cpp.

5.2.3 Adaptive Horizon MPC

In this section we describe the implementation of the adaptive horizon algorithms presented in Section 4.3.1. The focus is on the class AdaptiveHorizon which is a realization of the hierarchical grids Algorithm 4.17. The plain adaptive horizon Al-gorithm 4.16 also fits into this setting if only the finest spatial grid is investigated.

The main task of this class is to compute an appropriate horizon which guarantees a certain quality of the MPC closed loop solution. According to Algorithm 4.17 this step is done for the discretized PDE on a coarse grid. Therefore, the actual opti-mization of the full problem has to be done afterwards. This step can be omitted if the horizon is calculated from the full model (Algorithm 4.16). In this case the optimal control sequence is already known.

Listing 5.7: Initialization of the class AdaptiveHorizon.

A d a p t i v e H o r i z o n * a d a p t i v e h o r i z o n =new A d a p t i v e H o r i z o n ( optimize , maxN , N0 , dalpha , usecontrol , resty , restu )

In Listing 5.7 we see the initialization of the class AdaptiveHorizon. An explanation of the required input variables can be found in Table 5.7. It should be mentioned that the required optimization algorithm is that for the PDE on the coarse grid.

Depending on the used algorithm the maximum horizon maxN and the initial hori-zonN0 play an important role for the performance of the adaptive horizon method.

The parameter dalpha denotes the prescribed degree of suboptimality. With the parameter usecontrol one can decide whether the control on the coarse grid (true) or the shifted control from the previous MPC step (f alse) should be used as initial

5 Numerical Implementation

Type Name Description

OPTIMIZE optimize Optimization algorithm on coarse grid

int maxN Maximum horizon

int N0 Initial horizon

double dalpha Desired α bool usecontrol Use control

int resty Quotient of fine and coarse grid (state) int restu Quotient of fine and coarse grid (control) Table 5.7: Required variables for the constructor of class AdaptiveHorizon.

guess for the optimization algorithm. This choice is nontrivial because it depends on the considered example and on the fineness of the coarse grid, see Section 6.4 for details. If the horizon is determined by the full model one should use the option true, because in this case the following optimization can be omitted. The remaining variables resty and restu denote the quotient of the fine and the coarse grid for the state and control variable respectively. These information are required by the internal restriction and prolongation methods.

The actual calculation of the horizon is done by the method calcAdaptive, see List-ing 5.8. This method is called in each MPC step before the optimization algorithm starts. The input variables are the current state x, the shifted control from the previous MPC step Control and the current horizon N. After execution of the method,N contains the new horizon. If the parameterusecontrol is set totrue, the variableControl contains the optimal control on the coarse grid prolongated on the fine grid. Otherwise, it is the same as before. Afterwards, the horizon of the full problem has to be set to the previously computed one. This can be done with the method resizeHorizon(N).

Listing 5.8: Initialization of the class AdaptiveHorizon.

a d a p t i v e hor izon - > c a l c A d a p t i v e ( x , Control , N );

optimize - > r e s i z e H o r i z o n ( N );

Finally, we want to take a note on the internal restriction and prolongation methods.

Their task is to convert variables on different meshes. For the case of spatially one dimensional systems the corresponding operators can be found in textbooks about multigrid methods, e.g. [19]. It is important to mention that the conversion matrices are not build up explicitly. For the general case with higher dimensional unstructured domains the construction of restriction and prolongation methods is nontrivial and not yet implemented in our algorithm.

6 Numerical Results

In this chapter we present the main numerical results. In Section 6.1 we start with some prototype closed loop simulations for the example PDEs introduced in Section 5.1. Afterwards in Section 6.2 we investigate the optimization algorithms presented in Section 4.1 in detail. The focus is laid on the suitability for the MPC algorithm and the dependence on parameters like spatial discretization, horizon length, regularization and reaction values. In the ensuing Section 6.3 we analyse the performance of the algorithms in which we combine MPC and POD concepts, see Section 4.2. The advantages and limitations of the adaptive horizon algorithms introduced in Section 4.3 are presented in Section 6.4. Throughout this chapter, all presented results have been computed on a machine Intel(R) Core(TM)2 Duo CPU E6850 @ 3.00GHz with 4 Gbyte internal memory. The operating system is openSUSE 11.1 (x86 64).

6.1 Numerical Examples