• No results found

6.4 Algorithms Tailored to Nonlinear MPC

7.1.1 Introduction and Scope

While linear MPC generally requires a dedicated QP solver, a couple of additional algorithmic routines are required to tackle nonlinear MPC problems as outlined in Chapter 6 for direct methods. When searching the literature, a number of optimisation software packages for solving nonlinear optimal control problems (1.2) can be found. In order to motivate the development of the ACADO Toolkit, we briefly discuss some frequently used packages:

• A very popular interior-point algorithm for optimising large-scale differential algebraic systems is the open-source package Ipopt [235, 236], originally developed by Andreas W¨achter and Larry Biegler. It can be combined with collocation methods for discretising continuous-time dynamic systems and implements a filter strategy as globalisation technique. Ipopt is written

in C/C++ or FORTRAN, but uses modelling languages like AMPL or Mat-

labto provide a more convenient user interface and to allow for automatic differentiation.

• The Matlab package PROPT [183] receives increasing attention. PROPT is a commercial software tool developed by Tomlab Optimization Inc. It solves optimal control problems based on collocation techniques, and uses existing NLP solvers such as KNITRO [45] or SNOPT [100]. The use of Matlab syntax increases the user-friendliness of PROPT but restricts its use to platforms on which Matlab is available.

• Recently, the open-source code dsoa has been published by Brian Fabien [74]. This package is written in C/C++ and discretises differential algebraic systems based on implicit Runge-Kutta methods [121]. Unfortunately, the package only implements a single shooting method, which is often not advisable for nonlinear optimal control problems. An SQP method is used to solve the resulting NLP.

• Another SQP-based optimal control package is MUSCOD-II, originally developed by Daniel Leineweber [156]. It discretises the differential algebraic systems based on backward differentiation formula (BDF) [4] or Runge-Kutta integration methods and uses direct multiple shooting [38]. MUSCOD-II is proprietary software written in C/C++. Its numerical algorithms seem to be more elaborated than those of dsoa and also support optimal control problems comprising integer-valued variables.

• Finally, the development of software packages dedicated to nonlinear MPC in the process industry has been reported in the literature: The open-source packages OptCon [216] and NEWCON [204] both employ a multiple shooting method in combination with the sparse SQP method HQP [90].

OVERVIEW OF THE SOFTWARE PACKAGE 113

Each of the above packages has its particular strengths and all of them have proven successful for a specific range of applications. As they are all tailored to a certain choice of underlying numerical algorithms, it is usually problem-dependent which one is most suited. Moreover, their specialised software design renders it difficult to combine algorithmic ideas from different packages or to extend them with new mathematical concepts. Finally, most packages aim at users with a sound programming background and some of them are either not freely available or rely on proprietary external packages (like the sparse linear system solver within Ipopt).

The ACADO Toolkit has been designed to overcome these issues. Besides the efficiency of the implementation, four key properties have been identified that are believed to be crucial for any automatic control software based on dynamic optimisation. These properties have guided the implementation of the ACADO Toolkit:

1. Open-source. As such a software package should be freely available at least to academic users, the ACADO Toolkit is distributed under the GNU Lesser General Public Licence (LGPL) [134]. Releasing the software as open-source code also allows other researchers to reproduce all results easily, to check whether all steps of an algorithm have been implemented as stated and to try out own modifications.

2. User-friendly. The syntax to formulate optimal control problems should be as intuitive as possible. Thus, the ACADO Toolkit makes intensive use of the object-oriented capabilities of C++, in particular operator overloading, to allow the user to formulate control problems in a way that is very close to the usual mathematical syntax (see the example listing in Section 7.3). For experienced users this might only be a question of convenience. But given the fact that dynamic optimisation is more and more widely used in many different engineering applications, also non-experts with little programming experience should be able to formulate their control problems within a reasonable period of time. Another aspect of user-friendliness requires that the software should, as far as possible, also make consistent default choices for algorithmic settings and initialisations automatically in case they are not provided by the user.

3. Extensible code. A favourable feature is a software design that makes it easy to extend the package by linking existing algorithms and adding new developments while avoiding the duplication of code. The ACADO Toolkit realises this requirement by a careful interface design guaranteeing that almost all algorithmic parts could also be used stand-alone. This is done using well-established object-oriented software design concepts such as abstract base classes and inheritance.

4. Self-contained. In particular for use in model predictive controllers on embedded hardware, it is important that the software must only depend on external packages if really inevitable (see also the discussion in Subsection 5.1.2). While linking additional libraries during offline simulations is usually less of a problem, the main package should provide a mode to run stand-alone on the controller hardware if possible. The ACADO Toolkit is written in a completely self-contained manner and optionally allows one to use external packages for graphical output or specialised linear algebra operations (e.g. sparse solvers for linear systems). The latter three design goals are typically conflicting with the efficiency of the implemented algorithms. Let us briefly summarise how the ACADO Toolkit deals with this trade-off: First, the symbolic syntax introduces a certain runtime overhead, which can become considerable if the problem formulation comprises very lengthy expressions. However, as all symbolic expressions need to be pre- processed only once in an initialisation phase, this overhead might be compensated by the ability to automatically detect and exploit structural information of the problem formulation (see Subsection 7.1.2). Second, some algorithmic overhead is introduced by the object-oriented design of the ACADO Toolkit (e.g. due to virtual inheritance) that keeps the package extensible. Though it is hard to quantify this effect, it is believed to be minor as executing the respective parts of a numerical algorithm is typically much more expensive than switching between different variants of them. Third, keeping the code self-contained (and open-source) can introduce a serious loss of efficiency as it prevents the use of existing highly efficient implementations of certain algorithmic components. This seems to be particularly crucial for the implementation of linear algebra routines (such as BLAS [31] or LAPACK[6]), which are at the base of any numerical algorithm. By encapsulating these operations in dedicated classes, the ACADO Toolkit in principle allows to replace the built-in implementation by existing linear algebra packages (as has been done with CSPARSE [55]). This promises significant runtime improvements for larger-scale problem formulations.

The ACADO Toolkit can deal with the following four problem classes: 1. Optimal control problems of the following form:

min x(·),z(·), u(·),p,T t0R+T t0 ψ t, x(t), z(t), u(t), pdt + φ x(t0+ T ), z(t0+ T ), p, t0+ T s. t. ˙x(t) = f t, x(t), z(t), u(t), p ∀ t ∈ [t0, t0+ T ] , 0 = g t, x(t), z(t), u(t), p ∀ t ∈ [t0, t0+ T ] , 0 ≥ c t, x(t), z(t), u(t), p ∀ t ∈ [t0, t0+ T ] , 0 ≥ r x(t0), z(t0), x(t0+ T ), z(t0+ T ), p, t0+ T. (7.1)

OVERVIEW OF THE SOFTWARE PACKAGE 115

This formulation extends the one given in Definition 1.1 by also including

algebraic states z : R → RnZ for dealing with differential algebraic equation

(DAE) models. Moreover, the horizon length does not need to be fixed but might also be subject to optimisation.

The algorithms implemented in ACADO Toolkit assume that the differential and algebraic right-hand side functions f and g are sufficiently smooth. Moreover, it is assumed that the function ∂g∂z is always regular, i.e. that the DAE is of index one. The remaining functions, namely the Lagrange term ψ, the Mayer term φ, the path constraint function c, as well as the boundary constraint function r are assumed to be at least twice continuously differentiable in all their arguments.

2. Multi-objective optimisation and optimal control problems, which require the simultaneous minimisation of more than one objective. These multi-objective optimisation problems typically result in a set of Pareto optimal solutions instead of one single (local) optimum. More details can be found in [163] and the references therein.

3. Parameter and state estimation problems, where parameters, unknown control inputs or initial states are to be identified by measuring an output of a given (nonlinear) dynamic system.

4. Model predictive control problems and online state estimation, where parameterised dynamic optimisation problems have to be solved repeatedly to obtain a dynamic feedback control law. We will focus on this problem class in Section 7.2.

We will now outline the main algorithmic features of the ACADO Toolkit and also give an overview of its software design.