• No results found

4.3 Deterministic Predictive Control

4.3.5 Real-time Nonlinear Model Predictive Control

During the past years, different algorithms and tools have been introduced that can be used to implement the various type of NMPCs. Due to the computational delay of the

NMPCs, having a real-time online algorithm that is capable of dealing with theOCPis a challenging task. However, there are some algorithms, which can be utilised in real- time systems. Some of these algorithms classified and reviewed by M. Diehl, Ferreau, et al. (2009). The main focus of this study is to implement a real-time NMPC. Many software packages are currently available for real-time NMPCs on embedded hardware. For example, ACADO Toolkit is a software environment and algorithm collection for automatic control and dynamic optimization. In this tool, several open-source convex solvers such as qpOASES (Ferreau et al., 2014) and FORCES (Domahidi et al., 2012) have been interfaced for direct optimal control.

Considering the indirect method basedNMPCsolvers, Continuation/Generalized Mini- mal RESidual (C/GMRES) as a fast numerical algorithm for nonlinear receding horizon control is proposed by Ohtsuka (2004). Similar to the Newton-Type controller, the

C/GMRESmethod performs only one Newton type iteration in each sampling time and is based on a sequential formulation. It is based on an IP treatment of the inequali- ties with fixed path parameter and it uses the iterative GMRES method as a Krylov subspace method for linear system solution in each Newton step. For more information about GMRES method see e.g., Kelley (1995). Most important, it makes no use of a shift, but instead, use of the tangential predictor. This feature seems to allow it to follow the nonlinear IP solution manifold well which is strongly curved at active set changes (M. Diehl, Ferreau, et al.,2009). The closed-loop stability of the method is in principle covered by the stability analysis for the real-time iterations without shift given by M. Diehl, Findeisen, et al. (2007). A variant of the method is given by Shimizu et al. (2009), which uses a simultaneous approach and condensing and leads to improved accuracy and lower computational cost in each Newton type iteration. RecentNMPC research along similar ideas has benefited considerably from progress in numerical optimization, being able to take advantage of structural properties on the NMPCproblem and general effi- ciency improvements and important issues such as robustness (Grancharova et al.,2012). For instance, there are several automotive application of NMPC that were introduced by Md Abdus Samad Kamal et al. (2013), Gagliardi et al. (2014), and M. Huang et al. (2015). In addition, the C/GMRES have been implemented in various applications such as the Large Hadron Collider (LHC) at the European Organization for Nuclear Research (CERN), the world’s highest energy particle accelerator and collider, which was presented by Noga et al. (2011). Thus, the real-time C/GMRES algorithm is the main numerical method applied in this study. The next subsection presents the detailed solution approach of theNMPC based on theC/GMRES.

4.3.5.1 Problem Formulation

Let’s consider a continuous-time system and assume that every function is differentiable as many times as necessary. The state equation and an nc-dimensional equality con-

straint are given as: ˙

x = f (x(t), u(t)), C(x(t), u(t)) = 0. (4.49) An inequality constraint can be converted into equality constraint by introducing a dummy input based on auxiliary variable method (Ohtsuka, 2004). The following per- formance index with the initial state given by the actual state x(t) is minimised:

VT(x(t), u(t)) =

Z t+T

t

Jc(x(t0), u(t0))dt0+ Jf(x(t + T )). (4.50)

The optimal control u∗(t0; t, x(t)) minimising VT(x(t), u(t)) is computed over prediction

horizon t0∈ [t, t+T ]. TheNMPCproblem is essentially a family of finite-horizon optimal control problems along a fictitious time τ as follows:

VT∗(x(t)) := minimise u∗ Z T 0 Jc(x∗(τ, t), u∗(τ, t))dτ + Jf(x∗(T, t)) (4.51a) subject to: x∗τ(τ, t) = f (x∗(τ, t), u∗(τ, t)), (4.51b) C(x∗(τ, t), u∗(τ, t)) = 0, (4.51c) x(0, t) = x(t), (4.51d)

where subscript τ denotes partial differentiation with respect to τ (M. Diehl, Ferreau, et al., 2009). The new state vector x∗(τ, t) represents a trajectory along the τ axis starting from x(t) at τ = 0 and the prediction horizon T is a function of time, T = T (t) in general (Ohtsuka and Ozaki, 2009).

Let H denotes the Hamiltonian defined by:

H(x, λ, u, µ) = Jc(x, u) + λTf (x, u) + µTC(x, u), (4.52)

where λ ∈ Rnx denotes the costate, and µ ∈ Rnc denotes the Lagrange multipliers

The first-order conditions necessary for theOCPare obtained by the calculus of variation as the Euler-Lagrange equations (Ohtsuka and Ozaki, 2009):

x∗τ = f (x∗, u∗), x∗(0, t) = x(t), (4.53a)

λ∗τ = −HxT(x∗, λ∗, u∗, µ∗), λ∗(T, t) = JfT(x∗(T )), (4.53b)

HuT(x∗, λ∗, u∗, µ∗) = 0, (4.53c)

C(x∗, u∗) = 0. (4.53d)

The control input u∗ and the Lagrange multiplier µ∗ at each time τ on the prediction horizon are determined from x∗ and λ∗ by algebraic equations Hu(·) = 0 and C(·) = 0.

The nonlinear TP-BVP has to be solved within the sampling period for the measured state x(t) at each sampling time, which is one of the major difficulties inNMPC(Ohtsuka and Ozaki,2009).

In real-timeNMPCalgorithm using theC/GMRES, the update of the optimal solution (more precisely, a stationary solution) is regarded as a continuous-time dynamic process described as a differential equation (Ohtsuka, 2004). This algorithm can be viewed as a type of continuation method (S. Richter et al.,1983). In order to find the initial costate λ∗(0, t) without an iterative search, its differential equation along real time t is derived. Note that ˙λ = λ∗(0, t) holds and λ∗t is unknown while λ∗τ is given as λ∗τ = −HxT. In practice, the initial value λ(0) = λ∗(0, 0) is given by the trivial solution to theTP-BVP

for T = 0, and the horizon length T is smoothly increased to some constant value. More details of real-time costate equation computation was presented by Ohtsuka and Ozaki (2009).

The control input function over the prediction horizon is regarded as the unknown quantity in theTP-BVP. In order to represent the unknown control input function with a finite number of parameters, the prediction horizon of the OCPis discretised into N steps. Then, the discretised conditions for optimality are given as follows:

x∗i+1(t) = x∗i(t) + f (x∗i(t), u∗i(t))∆τ, x∗0(t) = x(t), (4.54a) λ∗i = λ∗i+1− HxT(x∗i(t), λ∗i+1(t), u∗i(t), µ∗i(t))∆τ, λ∗N(t) = JfT(x∗N(t)), (4.54b) HuT(x∗i(t), λi+1∗ (t), u∗i(t), µ∗i(t)) = 0, (4.54c)

C(x∗i(t), u∗i(t)) = 0, (4.54d)

where ∆τ := T /N . On the discretised horizon, sequences of the state, costate, input, and Lagrange multiplier associated with the equality constraint are denoted by {x∗i(t)}Ni=0, {λ∗

discrete-time TP-BVP (4.54) for a measured state x(t) at time t (Ohtsuka and Ozaki,

2009).

Let us define vector U (t) ∈ RnN (n := nu+ nc) composed of the sequences of the input

vectors and multipliers as follows:

U (t) := [u∗T0 (t), µ∗T0 (t) · · · u∗TN −1(t), µ∗TN −1(t)]T. (4.55)

The sequences of {x∗i(t)}Ni=0 and {λ∗i(t)}Ni=0 can be regarded as functions of U (t) and x(t). Then, the optimality conditions (4.54) can be regarded as an nN -dimensional equation system given by:

F (U (t), x(t), t) :=           HuT(x∗0, λ∗1, u∗0, µ∗0) C(x∗0, u∗0) .. . HuT(x∗N −1, λ∗N, u∗N −1, µ∗N −1) C(x∗N −1, u∗N −1)           = 0, (4.56)

where F depends on t when the horizon length T is time dependent (Ohtsuka and Ozaki,

2009).

Solving (4.56) at each time by the iterative methods such as Newton’s method is com- putationally expensive and thus inefficient. Instead, the continuation method is applied (S. Richter et al.,1983), considering the real time t as the continuation parameter. That is, the time derivative of U obtained so that (4.56) is satisfied identically. If the initial solution U (0) of the problem is determined so as to satisfy F (U (0), x(0), 0) = 0, then we can trace U (t) by integrating ˙U (t) fulfilling the condition:

˙

F (U (t), x(t), t) = AsF (U (t), x(t), t), (4.57)

where As is a positive real number. The right-hand side of (4.57) stabilizes F = 0.

Equation (4.57) is equivalent to a linear equation with respect to ˙U (t) given by: ˙

U = FU−1(−AsF − Fxx − F˙ t). (4.58)

If the matrix FU is nonsingular, (4.58) is solved efficiently by the GMRES (Kelley,1995),

one of the Krylov subspace methods for linear equations. We can update the unknown quantity U by integrating the obtained ˙U (t) by, for example, the Euler method in real- time. In the case of the explicit Euler method, the computational cost for updating U corresponds to only one iteration in Newton’s method but achieves higher accuracy by taking the time dependency of the equation into account (Ohtsuka and Ozaki, 2009).

For more details about the C/GMRES see e.g., Ohtsuka (2004), Ohtsuka and Ozaki (2009), Shimizu et al. (2009), and Knyazev et al. (2017).