원시데이터 수집 시스템
선정목록으로

Flexible development and evaluation of machine‐learning‐supported optimal control and estimation methods via HILO‐MPC

간접 관련 엔지니어링 플라스틱 · (23) 컴파운드 (3) 자동차 인테리어 소재(4) 카시트 모듈

기본 정보

저자
  1. Johannes Pohlodek — Control and Cyber-Physical Systems Laboratory, TU Darmstadt, Darmstadt, Germany
  2. Bruno Morabito — R&D Department Yokogawa Insilico Biotechnology GmbH Stuttgart Germany
  3. Christian Schlauch — Research Center Trustworthy Data Science and Security, TU Dortmund, Darmstadt, Germany
  4. Pablo Zometa — Faculty of Engineering, German International University, Berlin, Germany
  5. Rolf Findeisen — Control and Cyber-Physical Systems Laboratory, TU Darmstadt, Darmstadt, Germany
DOI
10.1002/rnc.7275
저널
International Journal of Robust and Nonlinear Control
발행년도
2024
발행기관
Wiley
피인용수
8
라이선스
cc-by
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.1002/rnc.7275
토픽
Fuel Cells and Related Materials
OpenAlex ID
W4392594237

평가 내용

관련도
간접 관련
사업분야
엔지니어링 플라스틱 · (23) 컴파운드
부 분야
(3) 자동차 인테리어 소재, (4) 카시트 모듈
R&D 측면
분석·모델링
확신도
0.70
근거 용어
Model predictive control, Machine learning, Optimization, Embedded applications, System dynamics
판단 근거
본 논문은 머신러닝을 결합한 모델 예측 제어(MPC) 및 최적화 알고리즘을 다루는 소프트웨어 툴박스에 관한 연구입니다. 이는 코오롱인더스트리의 직접적인 제품 연구는 아니나, 모빌리티(자동차 제어)나 컴파운드 제조 공정의 최적화 및 자동화 제어 시스템 구축에 응용될 수 있는 방법론을 제시합니다.
R&D 활용 포인트
자동차 인테리어/카시트 모듈의 전장 제어 시스템이나, 화학/수지/컴파운드 제조 공정의 실시간 최적 제어 및 공정 모델링(Digital Twin) 기술에 활용 가능합니다.
평가 입력
섹션 본문 44,883자 중 30,032자 발췌

초록

Abstract Model‐based optimization approaches for monitoring and control, such as model predictive control and optimal state and parameter estimation, have been used successfully for decades in many engineering applications. Models describing the dynamics, constraints, and desired performance criteria are fundamental to model‐based approaches. Thanks to recent technological advancements in digitalization, machine‐learning methods such as deep learning, and computing power, there has been an increasing interest in using machine learning methods alongside model‐based approaches for control and estimation. The number of new methods and theoretical findings using machine learning for model‐based control and optimization is increasing rapidly. However, there are no easy‐to‐use, flexible, and freely available open‐source tools that support the development and straightforward solution to these problems. This article outlines the basic ideas and principles behind an easy‐to‐use Python toolbox that allows to solve machine‐learning‐supported optimization, model predictive control, and estimation problems quickly and efficiently. The toolbox leverages state‐of‐the‐art machine learning libraries to train components used to define the problem. Machine learning can be used for a broad spectrum of problems, ranging from model predictive control for stabilization, set point tracking, path following, and trajectory tracking to moving horizon estimation and Kalman filtering. For linear systems, it enables quick generation of code for embedded model predictive control applications. HILO‐MPC is flexible and adaptable, making it especially suitable for research and fundamental development tasks. Due to its simplicity and numerous already implemented examples, it is also a powerful teaching tool. The usability is underlined, presenting a series of application examples.

본문 46,159자

본문 펼치기
Model-based optimization approaches for monitoring and control, such as model predictive control and optimal state and parameter estimation, have been used successfully for decades in many engineering applications.Models describing the dynamics, constraints, and desired performance criteria are fundamental to modelbased approaches.Thanks to recent technological advancements in digitalization, machine learning methods such as deep learning, and computing power, there has been an increasing interest in using machine learning methods alongside modelbased approaches for control and estimation.The number of new methods and theoretical findings using machine learning for model-based control and optimization is increasing rapidly.However, there are no easy-to-use, flexible, and freely available open-source tools that support the development and straightforward solution to these problems.This paper outlines the basic ideas and principles behind an easy-to-use Python toolbox that allows to quickly and efficiently solve machinelearning-supported optimization, model predictive control, and estimation problems.The toolbox leverages state-of-the-art machine learning libraries to train components used to define the problem.It allows to efficiently solve the resulting optimization problems.Machine learning can be used for a broad spectrum of problems, ranging from model predictive control for stabilization, setpoint tracking, path following, and trajectory tracking to moving horizon estimation and Kalman filtering.For linear systems it enables quick generation of code for embedded MPC applications.HILO-MPC is flexible and adaptable, making it especially suitable for research and fundamental development tasks.Due to its simplicity and numerous already implemented examples, it is also a powerful teaching tool.The usability is underlined, presenting a series of application examples. INTRODUCTION Advanced optimal control and estimation problems such as model predictive control, moving horizon estimation, and Kalman filters require models representing, e.g., the system dynamics, constraints, reference values, and objective functions.Based on these models, the inputs, the estimates of the states, or parameters are found based on the minimization of an objective function 1,2 Often obtaining accurate models is challenging.For example, dynamical models can be constructed with first principles, such as conservation of energy, matter, and thermodynamics laws.However, underlying unknown nonlinearities, parameters, or coupling effects, often results in complex dynamics, which is challenging to model, thus rendering it difficult to employ such model-based methods for process control or numerical simulations. INTRODUCTION Alternatively, if only data is used to derive a model, one generally talks about data-driven or machine learning models. 1,3achine learning has recently obtained much attention since it allows to model and to simulate complex, not well-understood phenomena or efficiently simulate complex, large-scale systems, provided that a sufficiently large amount of data is available.For many decades the scarcity of data, features selection, and computational power have been the main bottlenecks to the widespread use of machine learning for modeling and control.The situation is rapidly changing due to the rapid digitization and interconnection (e.g., Internet of Things and Industry 4.0 initiatives), advances in machine learning, and cloud computing. 4,5Hence, machine learning is finding more and more applications, not only in research but in everyday life.In recent years, the number of machine learning applications, publications, new methods, and theoretical findings has increased rapidly.Furthermore, opensource libraries for machine learning such as TensorFlow 6 and PyTorch 7 offer a low entry barrier to this technology and allow fast development of machine learning solutions.The combination of these factors boosted the quality and quantity of results in many fields such as medicine, 8 autonomous driving, 9 transportation, 10 Internet of Things, 11 image recognition 12 and many others.The control and optimization community also recognized the usefulness of machine learning for control, e.g., for efficient and safe optimal control and model predictive control (MPC), motivating many contributions. 2,13,14,15hile machine learning libraries are powerful tools to build machine learning models, using these models in a control strategy requires typically ad-hoc solutions, which are complicated, prone to bugs, and not easily transferable to other applications.In the frame of this work, we outline an approach to interconnect machine learning methods and tools with methods from optimizationbased control and estimation using Python.The resulting open-source Python library, named HILO-MPC 1 aims at providing a way to easily implement machine learning models into a wide variety of control, optimization and estimation problems, tailored towards fundamental research and basic development tasks (see Fig. 1).It interfaces with PyTorch and TensorFlow to train neural networks and uses in-house code to train Gaussian processes.The trained models can be used in a large variety of control or estimation problems for example, in the system's dynamics, the constraints, the cost functions, or even the controller itself (see Figure 2). INTRODUCTION To speed up the development time, HILO-MPC provides a way to define and solve a broad spectrum of optimal control and estimation problems quickly and with minimum effort.Table 1 summarizes the different problems that can be solved.The philosophy followed is the ease of use and modularity.Ease of use is achieved by providing an intuitive high-level interface for the problem definition.At the same time, modularity is obtained by ensuring effortless interfaces between the different tools (see Figure 2).This allows using the toolbox both for research and for teaching.Table 1 summarizes the main tools and methods available. INTRODUCTION The main contribution of this paper is the presentation of a modular way to fuse modeling, simulation, estimation, control, machine learning approaches, and optimization, resulting in a flexible yet easy-to-use open-source toolbox.The usability is underlined, presenting a series of application examples, spanning from the problem to learn the dynamic model of a car for racing, learning references to be tracked, learning the solution of an MPC controller, and the embedded implementation of a MPC controller.Note that, while we focus on the integration of machine learning into control and estimation problems, most of the parts can also be used without any machine learning component. INTRODUCTION The remainder of this paper is structured as follows.Section 3 provides a brief overview of toolboxes available for optimal and predictive control, with a specific focus on open-source toolboxes.In Section 3 the different modules of the toolbox are described.Furthermore, we show example code snippets to illustrate the required syntax.In Section 4 we apply the toolbox in four examples.Finally, in Section 5 we conclude and give an outlook on current and future developments. INTRODUCTION Note that this paper only provides a glimpse of the principles and main ideas and the usability via some example applications.It is not a manual, as providing a comprehensive description of the toolbox is outside the scope of this work.For this, the reader is referred to the documentation. 2 A GLIMPSE REVIEW OF OPEN-SOURCE MPC TOOLS By now a wide variety of toolboxes for MPC exist.We ocus on freely available, open-source toolboxes.The software ACADO 17 and ACADOS 18 aim at efficiency and fast solution keeping embedded applications in mind.Note that, although interfaces to embedded MPC libraries are offered, embedded MPC is not the main focus of the toolbox.MPT3 focuses on computational geometry, which is particularly useful for some classes of robust MPC approaches. 23YALMIP instead offers a broad spectrum of optimization problems, such as bilevel optimization and mixed-integer programming, and some MPC schemes. 24The toolbox do-mpc implements robust multi-stage MPC and moving horizon estimation (MHE). 20MPCTools offers some interfaces that help build MPC and MHE control problems in CasADi. 21,22 Using machine learning models in the previously mentioned toolboxes is often not straightforward.We tackle this challenge by providing wrappers for machine learning libraries and some in-house learning libraries.Furthermore, compared to the other toolboxes, it focuses on a simple and intuitive interface that makes it easy to use also for beginners. BASIC CONCEPTS AND COMPONENTS To provide flexibility five main components are tightly integrated -in the following denoted as modules named dynamic model, control, estimator, machine learning, and embedded (see Figure 1).The dynamic model module is used to generate dynamic models which are used in all other modules.The control module allows to setup and formulate controllers, solve and apply them.It focuses, but is not limited to predictive and optimal controllers.The estimator module focuses on state and parameter estimation using the dynamic models.The machine learning module is responsible for defining and training machine learning models that can be used in any of the previous modules.Finally, the embedded module currently interfaces with embedded linear MPC software ( AO-MPC 16 ) that allows to easily deploy the code for embedded applications.In the next sections, we will briefly describe the different modules in more detail. 3he backbone of HILO-MPC is CasADi. 25CasADi is a flexible and widely used tool for algorithmic differentiation and optimization.It has interfaces with a wide range of solvers for linear and quadratic programming (CLP, 26 qpOASES 27 ), nonlinear programming such as IPOPT, 28 quadratic mixed-integer programming (CPLEX, 29 GUROBI 30 ), for non quadratic nonlinear mixed-integer problems (BONMIN, 31 KNITRO 32 ) and large nonlinear problems WORHP. 33asADI is used to build the models, optimization, and estimation problems.TensorFlow or PyTorch are interfaced by automatically translating the models into CasADi-compatible structures.Hence, a CasADi problem is defined and solved. BASIC CONCEPTS AND COMPONENTS In the following, we briefly outline the core modules and provide insights in the formulations and solution approaches. Dynamic Model Module The dynamic model module forms the foundation for all other components.It is a high-level interface to generate representations of dynamical systems that can be used for model-based controllers and estimators, like MPC or MHE, or inside simulations to reproduce the behavior of a plant (or a controller) in a control loop.The module currently supports linear and nonlinear, timeinvariant and time-variant, discrete-time systems described in discrete time by difference equations, continuous-time systems described by ordinary differential equations (ODEs), and differential algebraic equations (DAEs).For example, the module allows to describe a general time-variant continuous-time nonlinear model given by a DAE of the form ̇ ( ) = ( , ( ), ( ), ( ), ), 0 = ( , ( ), ( ), ( ), ), Dynamic Model Module ( ) = ℎ( , ( ), ( ), ( ), ).Here ( ) ∈ ℝ is the differential state vector, ( ) ∈ ℝ the vector of algebraic states, ( ) ∈ ℝ is the input vector and ∈ ℝ is a vector of parameters.The function ∶ ℝ × ℝ × ℝ × ℝ × ℝ → ℝ represents the ODEs of the model, and the function ∶ ℝ × ℝ × ℝ × ℝ × ℝ → ℝ describes the algebraic equations forming a semi-explicit DAE system overall. 4he function ℎ ∶ ℝ × ℝ × ℝ × ℝ × ℝ → ℝ describes the measurement equations mapping to some measurable quantity of the system.If these measurement equations are not defined during the setup of the model, the controllers and estimators using the model assume that all states are measured. Dynamic Model Module When necessary, continuous-time models can be easily discretized using the model.discretize(...) method.Available discretization methods are explicit Runge-Kutta methods up to the 4th order and implicit collocation schemes. 35For the explicit Runge-Kutta methods, a series of Butcher tableaus is available, while the implicit collocation schemes only support Gauss-Legendre polynomials and Gauss-Radau polynomials for the calculation of the collocation points. Dynamic Model Module For some applications and control and estimation methods a linear model might be necessary.The direct creation of linear models is also possible by supplying the required matrices during model setup.If only a nonlinear model is available, this can be easily linearized with respect to an equilibrium point using model.linearize(...). Dynamic Model Module To underline the simplicity of defining a model, we consider a simple single-track car/bicycle (see Fig. 3) model which will be used as an example model in the following sections Dynamic Model Module Here, x and y are the -and -coordinates of the vehicle center of mass, is the norm of the velocity of the center of mass, and is the orientation angle of the vehicle with respect to the -coordinate.The inputs are the acceleration of the center of Note that the model equations are supplied in the form of a string.HILO-MPC is able to parse the most common functions and operations in this format, while it also provides the flexibility to use other input formats, e.g., by explicitly defining the inputs and states of the system.Units, labels and descriptions of all variables can also be set for convenience and for use in the plotting functionality.For a more in-depth description of available functionalities, refer to the documentation.Once the initial conditions are set, the model can be used for simulation by running model.simulate(u=u,p=p).Note that, for every integration interval given by the sampling time d the input for the continuous times system is kept constant, as it is commonly done.One can easily store, access, and plot solutions generated by simulations.Every time the method model.simulate(...) is executed, the solution is saved in the model.solutionobject.This can be accessed similarly to a Python dictionary.To plot the solution, i.e., the evolution of states, inputs, and parameters with time, the user can use the method model.solution.plot(). Machine Learning Module The machine learning module is responsible for defining and training machine learning models.Machine learning models are data-driven models that are used to map selected inputs ∈ ℝ , also called features, to outputs ∈ ℝ , also called labels.The machine learning models can be used to describe dynamical systems, unknown functions, constraints, cost functions, or a controller (see Fig. 2). Machine Learning Module Two machine learning approaches/models are currently integrated: artificial feedforward fully connected neural networks and Gaussian processes.Further approaches are under development. Artificial Neural Networks We briefly review artificial neural networks (ANNs) to introduce the required notation and concepts.Inspired by the neural circuits in brains, 36 ANNs can be represented as a collection of interconnected nodes, the so-called neurons, that are usually organized into layers.We focus on feedforward fully connected ANNs (Figure 4).Each layer of the ANN is mathematically represented by Artificial Neural Networks where ∈ ℝ is the output vector of layer with the features being the input to the first layer (i.e., = 0 ) and the labels being the output of the last layer.The function ∶ ℝ → ℝ is the activation function.Common nonlinear activation functions are the sigmoid function, hyperbolic tangent, or the ReLU function. 37The training of the ANN is achieved by iteratively adapting the weight matrices ∈ ℝ × −1 and the bias vectors ∈ ℝ , so that a user-defined loss function is minimized.For regression problems, one of the most commonly used loss functions is the mean squared error (MSE) Artificial Neural Networks where ̂ are the values of the labels predicted by the ANN.Other loss functions supported by HILO-MPC include the mean absolute error (MAE) or the Huber loss.Optimization algorithms like gradient descent or stochastic gradient descent are used to minimize the loss.A number of minimization algorithms can be interfaced in HILO-MPC, e.g., the Adam algorithm, a modification of stochastic gradient descent.These minimization algorithms return a gradient vector of the loss with respect to the output of the ANN.By applying the backpropagation algorithm, this gradient vector can then be used to update the weight matrices and the bias vectors throughout the ANN. 38The training is stopped when there is no significant change in the loss over a defined number of iterations or if the number of maximum iterations is reached. Artificial Neural Networks In HILO-MPC, the training of the ANNs itself is performed by the respective machine learning libraries, i.e., currently TensorFlow or PyTorch.The specific parameters and characteristics for the training of the ANN (e.g., epochs, batch size, loss function, etc.) as well as the training data are automatically processed and forwarded to the chosen machine learning library.After the training of the ANN is completed, all relevant information is extracted, and an equivalent CasADi graph is created for later use in the model or model-based controllers and estimators. Artificial Neural Networks The following example shows how to define an ANN consisting of two layers with 10 neurons each, using a sigmoid function as activation function, and how to train the resulting model where Dense(...) creates a fully connected layer.One can simply replace specific variables of a model with the predictions of the ANN by the command model.substitute_from(ann).The variables to be replaced will be automatically detected and exchanged with the corresponding predictions of the ANN.Alternatively, it is also possible to directly add the ANN to the model via summation or subtraction. Gaussian Processes A Gaussian process (GP) is a probability distribution over a function in which any finite subset of random variables has a joint Gaussian distribution. 39Besides being less prone to overfitting, one key advantage of using a GP is that it naturally measures the output uncertainty by estimating the variance of the predictions.GPs can be used to approximate input-output mappings = ( ) + , where the output ∈ ℝ is affected by some zero-mean normally distributed measurement noise ∼  (0, 2 ) with variance 2 .Starting from a given prior distribution, described by a mean function and a covariance function, the GP is trained on observed data (see Figure 5). Gaussian Processes In general, both the prior mean function and the prior covariance function depend on so-called hyperparameters.During the training, the hyperparameters are obtained via optimization, i.e., the hyperparameters are chosen such that the resulting GP can be used to infer the input-output mapping given available training data.Typically, the prior mean function is assumed to be zero, 40 but HILO-MPC also supports other prior mean functions.The covariance function, or kernel, is often assumed to be a smooth function that is infinitely differentiable.A number of covariance functions that meet this criterion are provided, e.g., the stationary squared exponential and rational quadratic kernels.The prior means, as well as the kernels, can be combined with each other through summation or multiplication. Gaussian Processes The objective of the optimization problem that underlies the training step is usually to maximize the log marginal likelihood 39 log ( ( Gaussian Processes where ∈ ℝ × describes the matrix containing the training inputs, ∈ ℝ × is the covariance matrix resulting from the used kernel and the supplied training data, and is the identity matrix of corresponding size.The element ( , ) of is ( , ), where ∶ ℝ × ℝ → ℝ is the kernel.The predictive mean ̄ and variance 2 of the trained GP can be obtained for test data as follows Gaussian Processes where the -th element of ̃ ∈ ℝ is ( , ).The following example outlines how GPs can be setup Similarly to ANNs, the GPs can be integrated in models. Control Module The control module realizes feedback controllers of proportional-integral-derivative (PID) type, linear quadratic regulators (LQR), as well as optimal and MPC controllers.The latter are outlined in the following. Model Predictive Control Model predictive control repeatedly solves a finite-horizon optimal control problem (OCP). 41,42,43Optimal control problems and MPC problems for continuous-time systems are realized in sampled-data fashion in HILO-MPC as outlined in the following. 44quivalent formulations for discrete-time nonlinear system are also possible.At a sampling time 0 the optimal control problem Model Predictive Control 0 ≥ ( , ( ), ( ), ( ), ), (3d) Model Predictive Control for Model Predictive Control Here, (⋅) is the optimal input function, Model Predictive Control cost, is the prediction horizon, and the control horizon.The vector ̂ ( 0 ) contains the measured or estimated states at the current sampling time 0 and is the time variable.The equation Model Predictive Control Remark 1.In principle any of the equations in (3) could be completely or partially learned from data (see Figure 2), using the learning approaches outlined in Section 3.2.Table 3 gives an overview of other works where different components are learned.These cases can be handled using the machine learning module. Model Predictive Control 0 ≥ ( , ( ), ( ), , ), (4e) Model Predictive Control where Δ is the sampling time, = ceil( ∕Δ ) is the control horizon and = … is the sequence of piece-wise constant inputs applied to the plant, i.e., ( ) = , ∀ ∈ [ , + Δ ) ⊂ ℝ.The function ceil ∶ ℝ → ℤ is the ceiling function, i.e., a function that returns the smallest integer that is larger than a given real number.HILO-MPC also implements the multiple shooting approach. 56The integration of the system model in between the shooting points can be done with Runge-Kutta methods of various order, orthogonal collocation, 57 or the dynamics can be integrated with CVODES or IDAS solvers. 58The default method is orthogonal collocation, while any other method can be selected if needed.Note that for simplicity piece-wise, constant inputs are assumed at every control interval, which can be generalized to introducing virtual inputs.Hence, the real formulation of Problem (3) depends on which method is used for the discretization.Here, no further details of the formulation of the approximated problem are provided.See the cited papers for more information. Model Predictive Control Remark 2. Note that it is also possible to optimize the sampling intervals.This will add to Problem (4) the vector Δ … Δ as optimization variable.This allows the solution of minimum time problems, and optimal sampling time problems.This frequently appears for example in network controlled systems. 59,5e stage cost (⋅) and arrival cost (⋅) depend on the type of optimal control formulation/MPC formulation implemented.In the following we sketch different MPC formulations contained in the toolbox.For simplicity of explanation, we focus on quadratic cost functions; however, HILO-MPC is not limited to those. MPC for set point tracking In set point tracking MPC 60 the variables , and are desired to track a known reference, which can be formulated in terms of the cost function and terminal cost, for example, as MPC for set point tracking Here , , and are fixed references and ∈ ℝ × , ∈ ℝ × , ∈ ℝ × , T ∈ ℝ × , and T ∈ ℝ × are weighting matrices.To outline the simplicity to formulate MPC problems, consider the one-track car model as discussed in section 3.1.The goal is that the car should track a set point reference speed r = 2 m∕s.We consider a prediction horizon of 20 steps.The corresponding MPC controller can be formulated as The solution of the MPC (e.g., input and state sequences) are stored in the mpc.solution() object. MPC for trajectory-tracking For trajectory tracking problems the variables need to track a time-varying reference. 60Considering a quadratic cost function, this can be formulated as MPC for trajectory-tracking Here ∶ ℝ → ℝ , ∶ ℝ → ℝ , and ∶ ℝ → ℝ are time-varying references.For example, a trajectory tracking problem for a single-track car model can be defined by MPC for path following While in the MPC for trajectory tracking both the value of the reference and time are fixed simultaneously, MPC for path following exploits additional degrees of freedom by choosing when to be where on the path. 60,61Do do so, we augment the model with a virtual path state min (⋅), pf (⋅) 0 + ∫ 0 ( , ( ), ( ), ( ), )d + ( 0 + , ( 0 + ), ( 0 + ), ), (5a) s.t.̇ ( ) = ( , ( ), ( ), ( ), ), ( 0 ) = ̂ ( 0 ), (5b) 0 = ( , ( ), ( ), ( ), ), (5c) MPC for path following 0 ≥ ( , ( ), ( ), ( ), , ), (5e) MPC for path following for MPC for path following Here ∈ ℝ is a virtual path state vector and pf ∈ ℝ , is the virtual input that the controller can choose.Hence, the objective function becomes MPC for path following To force the controller to move only in the direction of the path usually a lower bound on pf is added, i.e., pf > pf,min with pf,min ∈ ℝ , + .It is also possible to track a constant pf , so that the MPC tries to maintain a constant speed of the virtual state MPC for path following In comparison to other toolboxes, path following MPC/optimal control problems can be easily formulated.The user needs to activate the path following mode for the desired variables, as shown in the following Note that the toolbox allows to mix the previous problem formulations with minimum effort, e.g., the user can track some constant references for some of the variables, while performing path tracking for the other variables. Soft constraints Soft constraints are typically used in optimal control/MPC to avoid infeasibility, conservative solutions due to active constraints, or to speed up computations. 62,63When soft constraints are selected, slack variables p ∈ ℝ and T ∈ ℝ ,T are automatically added to the path and terminal constraints, respectively, as follows Soft constraints p ≥ ( , ( ), ( ), ( ), ), Soft constraints T ≥ ( 0 + , ( 0 + ), ( 0 + ), ), Soft constraints ( ) = ℎ( , ( ), ( ), ( ), ), (6f) Soft constraints for Soft constraints where and p ∈ ℝ × and T ∈ ℝ ,T × ,T are weighting matrices that limit the increase of the slack variables and can be chosen by the user, and p,max and T,max are the maximum constraint violations of path and terminal constraints, respectively. Estimator Module Estimating states and parameters from measurements is indispensable in control if not all variables can be accessed directly. Estimator Module The estimator module provides access to a moving horizon estimator, Kalman filters, and particle filters. Moving Horizon Estimation Moving horizon estimators (MHE) obtain state estimates based on the solution of an optimization problem similar to the MPC problem. 42,64,65We focus on moving horizon estimators operating on equidistant sampling times.At these sampling times measurements are taken.Due to the discrete measurements, the objective function in an MHE is usually given in discrete form. Moving Horizon Estimation For simplicity we indicate with (⋅) Moving Horizon Estimation | the variable at time , i.e., for the MHE problem solved at time we obtain Moving Horizon Estimation for Moving Horizon Estimation where ̄ is the horizon length, ̂ the output measurements, and ̂ the input measurements at time .The first term of the objective function is the arrival cost, while the second and third weigh the measurement and state noise, respectively. 42,66he matrices ∈ ℝ × , ∈ ℝ × and ∈ ℝ ( + )×( + ) are the weighting matrices for the outputs, state noise, and arrival cost.The optimization variables are: the state − ̄ | , i.e., the state at the beginning of the horizon, the state noise Moving Horizon Estimation ]} and the system parameters .Note that the parameters are considered constant in the horizon, but can be updated every time the optimization is run, to adapt to the new measurements.For the single-track car model, an MHE with = = = 10 (where is the identity matrix of appropriate dimensions) can be easily defined as follows Similar to other objects, the solution of the MHE is stored in mhe.solution(). Kalman Filters and Particle Filters Besides an MHE, Kalman filters (KFs) and particle filters (PFs) are provided for estimation.KFs allow for the estimation of observable states via available measurement data.Generally, a KF consists of two steps: the prediction step and the update step. Kalman Filters and Particle Filters In the prediction step, the estimated states from the previous iteration are propagated through the model dynamics to obtain preliminary values for the states at the current time step, the so-called a priori estimates.These a priori estimates are then updated in the update step using the measurement data to obtain a posteriori estimates.HILO-MPC contains KFs in various formulations.An unscented KF 67 can simply be integrated by Kalman Filters and Particle Filters In a similar fashion particle filters can be formulated and used. Embedded Module Implementing optimization-based controllers/MPC controllers on embedded systems requires a tailored implementation.By now, a series of tailored automatic code generation tools for MPC exist. 17,19,16,68ILO-MPC provides an interface for the code generation of MPC for linear time-invariant discrete-time model predictive control, tailored for small embedded systems, like microcontrollers. 16he code generation is limited to discrete-time linear time-invariant systems of the form Embedded Module subject to input and state constraints ≤ ≤ , ≤ ≤ , where and denote the state and input at the current sampling time, and + denotes the state at the next sampling time.The considered linear MPC problem formulation is Embedded Module where the integer ≥ 2 is the prediction horizon, the matrices ∈ ℝ × , ∈ ℝ × and ∈ ℝ × are the state, input, and terminal weighting matrix, respectively.The input sequence u = 0 … −1 is the optimization variable.For automatic code generation of the problem (9) tailored towards microcontrollers, we rely on AO-MPC, 16 a code generation tool that uses an augmented Lagrangian and Nesterov's fast gradient method. 69,70By design, the algorithm's implementation is simple and relies only on matrix-vector operations (i.e., no divisions), it can easily be warm started and computes good MPC inputs in very few iterations of the algorithm.For well-behaved problems, the computations can be made more efficient by using fixed-point arithmetic (instead of floating-point). Embedded Module The code generation reformulates the MPC optimization problem (9) as a condensed parametric QP ( ) Embedded Module where the constant Hessian matrix = > 0 ∈ ℝ × and the gradient vector ( ) depend on the system (8) and the objective function in (9).Additionally, ( ) depends on the current state (i.e., the parameter).The set  = {u | ≤ ≤ , = 0, ..., − 1} defines the input constraints.The constant matrix and the constraint vectors z( ) and z( ) depend on the constraints in (9). Embedded Module The generated code is highly portable C-code.It is split into the data for the QP ( ) (e.g., the constant matrix and the parametric vector ( )) and the implementation of the optimization algorithm to solve the QP. 69,70igure 6 depicts an overview of the embedded module.Similarly to other modules, the LMPC class is initialized using a Model object.In this case, a linear time-invariant discrete-time model is used.Calling the LMPC.setup()method, specifying the solver 'muaompc', will trigger the code generation procedure.The code generation automatically creates C-code which can be compiled to run on an embedded target.Additionally, a Python interface to the generated C-code is also created.This Python interface is used by the LMPC.optimize()method to obtain the input that minimizes 9.The basic use of the Embedded Module is exemplified in the following Python code from hilo_mpc import LMPC, Model # The Model class uses the linear system matrices A, B, and # the LMPC class uses the weighting matrices Q, R, P, constraints, etc., # to create the mpc object.Using the solver muaompc triggers the code generation mpc.setup(nlp_solver='muaompc') # the generated MPC code can be used directly on an embedded target using C, # or via the Python interface as HILO-MPC does on the next line u = mpc.optimize(x0=x) EXAMPLES We underline the flexibility of the toolbox considering a series of examples, which can be also found in the repository, as Python files or Jupyter notebooks.Thus, we do not provide implementation details, just a high-level description of the problems and outline some of the results. Learning the System Dynamics -Racing a Minicar We consider autonomous racing of a minicar, based on the results and models presented in Liniger et al. 71 The goal is to use model predictive control to follow a complex track using a path following formulation in presence of disturbances (see Figure 7a).An extended single-track model of the car, see 7a and section 3.1, including nonlinear tire models and drive train models as identified and validated in experiments in Liniger et al. 71 where and are the coordinates of the center of gravity, and are longitudinal and lateral velocities of the center of gravity.The orientation is denoted by and the yaw rate by .The control inputs are the motor duty cycle and steering angle .The two parameters and are the distances from the center of gravity to the front axle and rear axle, respectively, is the mass of the car, and is the inertia.Figure 7a shows the single-track car model.The path is the center of a racing track that has been interpolated using splines.The tire forces are modeled with a simplified Pacejka Tire Model is the drag coefficient, is the air density, is the effective flow surface, and , is the lateral wind velocity.The model used by the MPC does not have the drag effect.The goal is to learn this effect from data using a neural network and then augment the first principles model with a machine learning component that models the drag effect.After discretization, the hybrid model can be written as Learning the System Dynamics -Racing a Minicar where ( , ) is an NN model.The features of the NN are ,wind and , the labels are correction terms for , , , and via the weighting matrix .To show the effectiveness of the learning, we compare the results of MPC using the perfect model (i.e., with known drag force effects), the hybrid model (using the NN), and the model without drag forces.Furthermore, the measurements of position, velocity, and directions are affected by Gaussian noise and estimated using an unscented KF. Figure 7b shows the results of the simulation.While the hybrid model has similar results as the perfectly-known model, the model without drag exits the race area after the fifth curve. X [m] Y [m] (a) Complex single-track/bicycle car model. Learning a Reference -Cooperative Robots Inspired by 73 we consider that a follower robot has to track the position of a leader robot, where the leader moves along a periodic but unknown trajectory (see Figure 8).The trajectory is learned from data using a GP. Learning a Reference -Cooperative Robots The objective is to learn the trajectory of the leader with GPs, which are used in the follower.Hence, in this case the machine learning model enters the cost function.The nonlinear dynamics of the robots are described with the following simple dynamics ODE Learning a Reference -Cooperative Robots Here 1 and 2 are the horizontal and vertical position of the root, 3 its heading angle, 1 is the speed, and 2 the turning rate.The resulting tracking problem takes the form (3) with the objective function (5a), where (⋅) is the mean function of a GP trained on the data set collected from the position of the leader.The trajectory generated by the leader results from applying the time-varying forces 1 ( ) = 2 + 0.1 sin( ) and 2 ( ) = 0.5 + sin( ). Figure 9 shows the results of the reference learning and closed-loop simulations. Learning the Controller -Spring Damper System Solving an MPC requires the solution of a (nonlinear) optimization problem online.For embedded applications with low computational power or applications that can use only a limited amount of energy (for example battery powered systems) this is often not possible.Hence, methods that provide at least a close-to-optimal solution without solving the optimization problem at every time step are necessary.This can be done using explicit MPC approaches. 74,75One way to avoid the explicit solution is to learn the solution of an MPC offline, i.e., to learn the map  → ( ) that (approximates) the implicit MPC control law, and then using the learned controller online (see Figure 2). 76,77,78,79,80,81,82In this way, the control action can be found with a simple and fast function evaluation.We consider the control of a mass-spring-damper system using a learned controller.The models is given by Learning the Controller -Spring Damper System where 1 is the vertical position, 2 the vertical velocity, the vertical force, and , the system parameters.The equilibrium point is = (0, 0), = 0.The objective is to maintain the reference ref = [1, 0] using a learned MPC.In total 667 data points, obtained by simulations, are collected.We use the data to train an NN via HILO-MPC with three fully-connected layers, with 10 neurons each.The features of the NN are 1 and 2 , and the label is the input .We test the learned controller starting from a different initial condition (0) = (10, 0).In Figure 10 the simulation results are shown.The learned controller is able to bring the system to the reference like the original controller. Embedded MPC -HIL Simulation using an Arduino We conclude by presenting a hardware-in-the-loop (HIL) simulation based on the code generated by the embedded module (see Subsection 3.5).Figure 6 depicts the code generation and HIL simulation setup.The generated C-code is cross compiled to run on an Arduino microcontroller.The system dynamics are simulated on a laptop computer using the nominal linear model + = + .Using a serial interface (i.e.USB to UART), the state + is transferred to the Arduino, to compute a new sequence u by solving the parametric QP ( ).Only the first part 0 of this sequence is transferred by the Arduino to the computer via the serial interface. Embedded MPC -HIL Simulation using an Arduino The system to be controlled is the linearized lateral dynamics of the race car.The input is the steering angle = .The state is defined as = [ ] , where is the lateral position of the center of mass of the car, and is the orientation of the car with respect to the -axis and = ̇ (refer to Figure 7a).The input is constrained to −0.1 ≤ ≤ 0.1, and the state 1 = must satisfy −0.1 ≤ 1 ≤ 0.1. Embedded MPC -HIL Simulation using an Arduino For the HIL simulation, we used an Arduino Nano 33 BLE. 83 5We use a discretization time of 15 ms, and a horizon length of 20 steps.The Arduino requires around 10 ms to find (an approximate) solution to the MPC problem on each iteration.The compiled C-code takes about 20 kB of flash memory. Embedded MPC -HIL Simulation using an Arduino Figure 11 shows the compared trajectories of states and input for the HIL simulation (approximate solution on Arduino using single precision float) and the exact solution computed by a laptop using HILO-MPC's interface to CPLEX.Note that neither the input nor the state constraints are violated.The main differences are due to the early termination of the embedded algorithm, and the use of single precision float. CONCLUSIONS AND OUTLOOK While the use of machine learning approaches for model-based optimal control, such as predictive control and estimation are becoming increasingly important, currently there is no easy-to-use open-source tool available to support the researcher and developer.We outlined the concept and ideas behind HILO-MPC, a toolbox for fast development of optimal and predictive control and estimation methods that facilitates the use of machine learning models trained using PyTorch and TensorFlow for simulations and embedded applications.The concept is easily expandable and we underlined the simple use considering four examples.The toolbox allows to consider different methods, spanning from model predictive and optimal control, moving horizon estimation, and Kalman filters to particle filters.We believe that it is a flexible, yet easy-to-use tool for research and teaching.Future developments will allow using extended machine learning models such as recurrent neural networks, Bayesian neural networks and reinforcement learning, as well as extended control formulations, such as tube-based MPC, stochastic MPC, 84 and multi-mode MPC. 85,86Furthermore, we are expanding the toolbox towards code generation for embedded nonlinear MPC using the Al'brekht's method. 87,88,89 FIGURE 1 FIGURE 1Core elements of HILO-MPC. FIGURE 3 FIGURE 3Simple single-track/bicycle car model. FIGURE 4 FIGURE 4Simple feedforward neural network with four features (inputs), one hidden layer and one label (output). FIGURE 4 from hilo_mpc import ANN, Dense # Initialize NN ann = ANN(features, labels) ann.add_layers(Dense(10, activation='sigmoid')) ann.add_layers(Dense(10, activation='sigmoid')) # Add training data set ann.add_data_set(df) # Set up NN ann.setup() # Train the NN batch_size = 64 epochs = 1000 ann.train(batch_size, epochs, validation_split=.2, patience=100, scale_data=True) 3 − 2 0 2 MeasurementsFIGURE 5 FIGURE 5 Simple example of a GP fitting to a sinusoidal function.The left figure shows a non-zero prior mean with 1 standard deviation.The right figure shows the posterior of the GP conditioned on the measurements with optimal hyperparameters.The measurements are affected by a zero-mean white noise. 0 ( , ( ), ( ), ( ), )d + ( 0 + , ( 0 + ), ( 0 + ), ), (3a) s.t.̇ ( ) = ( , ( ), ( ), ( ), ), ( 0 ) = ̂ ( 0 ), (3b) 0 = ( , ( ), ( ), ( ), ), 0 ( from hilo_mpc import NMPC nmpc = NMPC(model) nmpc.horizon= 20 nmpc.quad_stage_cost.add_states(names=['v'],ref=2, weights=10) nmpc.quad_term_cost.add_states(names=['v'],ref=2, weights=10) nmpc.setup()The resulting MPC controller can be easily used in a control loop # Choose number of steps n_steps = 100 # Begin simulation loop for step in range(n_steps): # find optimal input u = nmpc.optimize(x0)# Simulate the plant model.simulate(u=u)# Get the current states x0 = sol['xf'] 0 ( from hilo_mpc import NMPC nmpc = NMPC(model) nmpc.horizon= 20 theta = nmpc.create_path_variable()traj_x = 30 -14 * cos(theta) traj_y = 30 -16 * sin(theta) nmpc.quad_stage_cost.add_states(names=['px','py'], ref=[traj_x, traj_y], weights=[10, 10], path_following=True) → nmpc.quad_term_cost.add_states(names=['px','py'], ref=[traj_x, traj_y], weights=[10, 10], path_following=True) → nmpc.setup() FIGURE 6 A FIGURE6 A scheme of the Embedded module.Left, the typical used of the module, including automatic code generation provided by AO-MPC.Right, a hardware-in-the-loop simulation used as example. FIGURE 6 A is used.We extend the model adding a component describing the effect of lateral drag forces due to, for example, a strong wind.The overall model is represented by the following system of nonlinear differential equations ̇ = cos( ) − sin( ), ̇ = sin( ) + cos( ), ̇ = , ̇ = 1 , − , − ( , − , ) sin( ) + , ̇ = 1 , − , − ( , − , ) cos( FIGURE 6 A Race track and results. FIGURE 7 FIGURE 7Example of a racing car driving on a racetrack following a given path. FFIGURE 8 FIGURE 8Cooperative robot example.The follower should track the leader, who follows a periodic, yet unknown trajectory.The trajectory is learned from data using a GP. FIGURE 9 FIGURE 9Left column: learned GP.Right column: states of the follower robot following the learned references. FIGURE 10 FIGURE 10Comparison of the learned and exact MPC. FIGURE 11 FIGURE 11 Comparison of HIL simulation and exact simulation Table 2 summarizes some of the main differences between existing open-source toolboxes. TABLE 1 Components and formulations imtegrated in HILO-MPC. TABLE 1 2The full documentation and toolbox are available under http://www.ccps.tu-darmstadt.de/hilo_mpc.FIGURE 2Schematic diagram of the interactions between the components of the toolbox.The machine learning component can be used to learn model parts (see Section 4.1), cost functions, constraints, or references/disturbances (see Section 4.2) from real or simulation data, that can then be used in the controller or estimator.It can also be used to learn an approximated solution of an optimal controller/MPC controller (seeSection 4.3).It is also possible to generate embedded code for the controller (see Section 4.4).In principle, similarly, the same holds for learning components of the estimator. TABLE 2 Comparison of different freely accessible MPC tools.ML: machine learning, MHE: TABLE 3 46lected, non-extensive overview of learned components of MPC and optimal control problems in the literature.Matschek et al.45, Carron et al.46, . . .terminal constraints (3e) Rosolia et al. 47 , Rosolia and Borrelli 48 , Brunner et al. 49 , . . .path constraints (3d) Bujarbaruah et al. 50, Armesto et al. 51 , Holzmann et al. 52 , . . .objective function (3a) Tamar et al. 53 , Beckenbach et al. 54 , Bradford and Imsland 55 , . . . TABLE 3 Solving Problem (3) directly is challenging, since (⋅) and the constraints are infinite-dimensional.HILO-MPC uses direct approaches to transform the problem into an equivalent finite-dimensional optimization problem.These approaches parameterize the input with a finite number of parameters, for example, using piece-wise constant inputs, and enforce the constraints only on a finite number of points.The resulting problem becomes min ∑ TABLE 3 After this setup, it can be deployed for estimation simply by

섹션 본문 108문단 · 43,729자

(제목 없음)

1Model-based optimization approaches for monitoring and control, such as model predictive control and optimal state and parameter estimation, have been used successfully for decades in many engineering applications.Models describing the dynamics, constraints, and desired performance criteria are fundamental to modelbased approaches.Thanks to recent technological advancements in digitalization, machine learning methods such as deep learning, and computing power, there has been an increasing interest in using machine learning methods alongside modelbased approaches for control and estimation.The number of new methods and theoretical findings using machine learning for model-based control and optimization is increasing rapidly.However, there are no easy-to-use, flexible, and freely available open-source tools that support the development and straightforward solution to these problems.This paper outlines the basic ideas and principles behind an easy-to-use Python toolbox that allows to quickly and efficiently solve machinelearning-supported optimization, model predictive control, and estimation problems.The toolbox leverages state-of-the-art machine learning libraries to train components used to define the problem.It allows to efficiently solve the resulting optimization problems.Machine learning can be used for a broad spectrum of problems, ranging from model predictive control for stabilization, setpoint tracking, path following, and trajectory tracking to moving horizon estimation and Kalman filtering.For linear systems it enables quick generation of code for embedded MPC applications.HILO-MPC is flexible and adaptable, making it especially suitable for research and fundamental development tasks.Due to its simplicity and numerous already implemented examples, it is also a powerful teaching tool.The usability is underlined, presenting a series of application examples.

INTRODUCTION

2Advanced optimal control and estimation problems such as model predictive control, moving horizon estimation, and Kalman filters require models representing, e.g., the system dynamics, constraints, reference values, and objective functions.Based on these models, the inputs, the estimates of the states, or parameters are found based on the minimization of an objective function 1,2 Often obtaining accurate models is challenging.For example, dynamical models can be constructed with first principles, such as conservation of energy, matter, and thermodynamics laws.However, underlying unknown nonlinearities, parameters, or coupling effects, often results in complex dynamics, which is challenging to model, thus rendering it difficult to employ such model-based methods for process control or numerical simulations.

3Alternatively, if only data is used to derive a model, one generally talks about data-driven or machine learning models. 1,3achine learning has recently obtained much attention since it allows to model and to simulate complex, not well-understood phenomena or efficiently simulate complex, large-scale systems, provided that a sufficiently large amount of data is available.For many decades the scarcity of data, features selection, and computational power have been the main bottlenecks to the widespread use of machine learning for modeling and control.The situation is rapidly changing due to the rapid digitization and interconnection (e.g., Internet of Things and Industry 4.0 initiatives), advances in machine learning, and cloud computing. 4,5Hence, machine learning is finding more and more applications, not only in research but in everyday life.In recent years, the number of machine learning applications, publications, new methods, and theoretical findings has increased rapidly.Furthermore, opensource libraries for machine learning such as TensorFlow 6 and PyTorch 7 offer a low entry barrier to this technology and allow fast development of machine learning solutions.The combination of these factors boosted the quality and quantity of results in many fields such as medicine, 8 autonomous driving, 9 transportation, 10 Internet of Things, 11 image recognition 12 and many others.The control and optimization community also recognized the usefulness of machine learning for control, e.g., for efficient and safe optimal control and model predictive control (MPC), motivating many contributions. 2,13,14,15hile machine learning libraries are powerful tools to build machine learning models, using these models in a control strategy requires typically ad-hoc solutions, which are complicated, prone to bugs, and not easily transferable to other applications.In the frame of this work, we outline an approach to interconnect machine learning methods and tools with methods from optimizationbased control and estimation using Python.The resulting open-source Python library, named HILO-MPC 1 aims at providing a way to easily implement machine learning models into a wide variety of control, optimization and estimation problems, tailored towards fundamental research and basic development tasks (see Fig. 1).It interfaces with PyTorch and TensorFlow to train neural networks and uses in-house code to train Gaussian processes.The trained models can be used in a large variety of control or estimation problems for example, in the system's dynamics, the constraints, the cost functions, or even the controller itself (see Figure 2).

4To speed up the development time, HILO-MPC provides a way to define and solve a broad spectrum of optimal control and estimation problems quickly and with minimum effort.Table 1 summarizes the different problems that can be solved.The philosophy followed is the ease of use and modularity.Ease of use is achieved by providing an intuitive high-level interface for the problem definition.At the same time, modularity is obtained by ensuring effortless interfaces between the different tools (see Figure 2).This allows using the toolbox both for research and for teaching.Table 1 summarizes the main tools and methods available.

5The main contribution of this paper is the presentation of a modular way to fuse modeling, simulation, estimation, control, machine learning approaches, and optimization, resulting in a flexible yet easy-to-use open-source toolbox.The usability is underlined, presenting a series of application examples, spanning from the problem to learn the dynamic model of a car for racing, learning references to be tracked, learning the solution of an MPC controller, and the embedded implementation of a MPC controller.Note that, while we focus on the integration of machine learning into control and estimation problems, most of the parts can also be used without any machine learning component.

6The remainder of this paper is structured as follows.Section 3 provides a brief overview of toolboxes available for optimal and predictive control, with a specific focus on open-source toolboxes.In Section 3 the different modules of the toolbox are described.Furthermore, we show example code snippets to illustrate the required syntax.In Section 4 we apply the toolbox in four examples.Finally, in Section 5 we conclude and give an outlook on current and future developments.

7Note that this paper only provides a glimpse of the principles and main ideas and the usability via some example applications.It is not a manual, as providing a comprehensive description of the toolbox is outside the scope of this work.For this, the reader is referred to the documentation. 2

A GLIMPSE REVIEW OF OPEN-SOURCE MPC TOOLS

8By now a wide variety of toolboxes for MPC exist.We ocus on freely available, open-source toolboxes.The software ACADO 17 and ACADOS 18 aim at efficiency and fast solution keeping embedded applications in mind.Note that, although interfaces to embedded MPC libraries are offered, embedded MPC is not the main focus of the toolbox.MPT3 focuses on computational geometry, which is particularly useful for some classes of robust MPC approaches. 23YALMIP instead offers a broad spectrum of optimization problems, such as bilevel optimization and mixed-integer programming, and some MPC schemes. 24The toolbox do-mpc implements robust multi-stage MPC and moving horizon estimation (MHE). 20MPCTools offers some interfaces that help build MPC and MHE control problems in CasADi. 21,22 Using machine learning models in the previously mentioned toolboxes is often not straightforward.We tackle this challenge by providing wrappers for machine learning libraries and some in-house learning libraries.Furthermore, compared to the other toolboxes, it focuses on a simple and intuitive interface that makes it easy to use also for beginners.

BASIC CONCEPTS AND COMPONENTS

9To provide flexibility five main components are tightly integrated -in the following denoted as modules named dynamic model, control, estimator, machine learning, and embedded (see Figure 1).The dynamic model module is used to generate dynamic models which are used in all other modules.The control module allows to setup and formulate controllers, solve and apply them.It focuses, but is not limited to predictive and optimal controllers.The estimator module focuses on state and parameter estimation using the dynamic models.The machine learning module is responsible for defining and training machine learning models that can be used in any of the previous modules.Finally, the embedded module currently interfaces with embedded linear MPC software ( AO-MPC 16 ) that allows to easily deploy the code for embedded applications.In the next sections, we will briefly describe the different modules in more detail. 3he backbone of HILO-MPC is CasADi. 25CasADi is a flexible and widely used tool for algorithmic differentiation and optimization.It has interfaces with a wide range of solvers for linear and quadratic programming (CLP, 26 qpOASES 27 ), nonlinear programming such as IPOPT, 28 quadratic mixed-integer programming (CPLEX, 29 GUROBI 30 ), for non quadratic nonlinear mixed-integer problems (BONMIN, 31 KNITRO 32 ) and large nonlinear problems WORHP. 33asADI is used to build the models, optimization, and estimation problems.TensorFlow or PyTorch are interfaced by automatically translating the models into CasADi-compatible structures.Hence, a CasADi problem is defined and solved.

10In the following, we briefly outline the core modules and provide insights in the formulations and solution approaches.

Dynamic Model Module

11The dynamic model module forms the foundation for all other components.It is a high-level interface to generate representations of dynamical systems that can be used for model-based controllers and estimators, like MPC or MHE, or inside simulations to reproduce the behavior of a plant (or a controller) in a control loop.The module currently supports linear and nonlinear, timeinvariant and time-variant, discrete-time systems described in discrete time by difference equations, continuous-time systems described by ordinary differential equations (ODEs), and differential algebraic equations (DAEs).For example, the module allows to describe a general time-variant continuous-time nonlinear model given by a DAE of the form ̇ ( ) = ( , ( ), ( ), ( ), ), 0 = ( , ( ), ( ), ( ), ),

12( ) = ℎ( , ( ), ( ), ( ), ).Here ( ) ∈ ℝ is the differential state vector, ( ) ∈ ℝ the vector of algebraic states, ( ) ∈ ℝ is the input vector and ∈ ℝ is a vector of parameters.The function ∶ ℝ × ℝ × ℝ × ℝ × ℝ → ℝ represents the ODEs of the model, and the function ∶ ℝ × ℝ × ℝ × ℝ × ℝ → ℝ describes the algebraic equations forming a semi-explicit DAE system overall. 4he function ℎ ∶ ℝ × ℝ × ℝ × ℝ × ℝ → ℝ describes the measurement equations mapping to some measurable quantity of the system.If these measurement equations are not defined during the setup of the model, the controllers and estimators using the model assume that all states are measured.

13When necessary, continuous-time models can be easily discretized using the model.discretize(...) method.Available discretization methods are explicit Runge-Kutta methods up to the 4th order and implicit collocation schemes. 35For the explicit Runge-Kutta methods, a series of Butcher tableaus is available, while the implicit collocation schemes only support Gauss-Legendre polynomials and Gauss-Radau polynomials for the calculation of the collocation points.

14For some applications and control and estimation methods a linear model might be necessary.The direct creation of linear models is also possible by supplying the required matrices during model setup.If only a nonlinear model is available, this can be easily linearized with respect to an equilibrium point using model.linearize(...).

15To underline the simplicity of defining a model, we consider a simple single-track car/bicycle (see Fig. 3) model which will be used as an example model in the following sections

16Here, x and y are the -and -coordinates of the vehicle center of mass, is the norm of the velocity of the center of mass, and is the orientation angle of the vehicle with respect to the -coordinate.The inputs are the acceleration of the center of Note that the model equations are supplied in the form of a string.HILO-MPC is able to parse the most common functions and operations in this format, while it also provides the flexibility to use other input formats, e.g., by explicitly defining the inputs and states of the system.Units, labels and descriptions of all variables can also be set for convenience and for use in the plotting functionality.For a more in-depth description of available functionalities, refer to the documentation.Once the initial conditions are set, the model can be used for simulation by running model.simulate(u=u,p=p).Note that, for every integration interval given by the sampling time d the input for the continuous times system is kept constant, as it is commonly done.One can easily store, access, and plot solutions generated by simulations.Every time the method model.simulate(...) is executed, the solution is saved in the model.solutionobject.This can be accessed similarly to a Python dictionary.To plot the solution, i.e., the evolution of states, inputs, and parameters with time, the user can use the method model.solution.plot().

Machine Learning Module

17The machine learning module is responsible for defining and training machine learning models.Machine learning models are data-driven models that are used to map selected inputs ∈ ℝ , also called features, to outputs ∈ ℝ , also called labels.The machine learning models can be used to describe dynamical systems, unknown functions, constraints, cost functions, or a controller (see Fig. 2).

18Two machine learning approaches/models are currently integrated: artificial feedforward fully connected neural networks and Gaussian processes.Further approaches are under development.

Artificial Neural Networks

19We briefly review artificial neural networks (ANNs) to introduce the required notation and concepts.Inspired by the neural circuits in brains, 36 ANNs can be represented as a collection of interconnected nodes, the so-called neurons, that are usually organized into layers.We focus on feedforward fully connected ANNs (Figure 4).Each layer of the ANN is mathematically represented by

20where ∈ ℝ is the output vector of layer with the features being the input to the first layer (i.e., = 0 ) and the labels being the output of the last layer.The function ∶ ℝ → ℝ is the activation function.Common nonlinear activation functions are the sigmoid function, hyperbolic tangent, or the ReLU function. 37The training of the ANN is achieved by iteratively adapting the weight matrices ∈ ℝ × −1 and the bias vectors ∈ ℝ , so that a user-defined loss function is minimized.For regression problems, one of the most commonly used loss functions is the mean squared error (MSE)

21where ̂ are the values of the labels predicted by the ANN.Other loss functions supported by HILO-MPC include the mean absolute error (MAE) or the Huber loss.Optimization algorithms like gradient descent or stochastic gradient descent are used to minimize the loss.A number of minimization algorithms can be interfaced in HILO-MPC, e.g., the Adam algorithm, a modification of stochastic gradient descent.These minimization algorithms return a gradient vector of the loss with respect to the output of the ANN.By applying the backpropagation algorithm, this gradient vector can then be used to update the weight matrices and the bias vectors throughout the ANN. 38The training is stopped when there is no significant change in the loss over a defined number of iterations or if the number of maximum iterations is reached.

22In HILO-MPC, the training of the ANNs itself is performed by the respective machine learning libraries, i.e., currently TensorFlow or PyTorch.The specific parameters and characteristics for the training of the ANN (e.g., epochs, batch size, loss function, etc.) as well as the training data are automatically processed and forwarded to the chosen machine learning library.After the training of the ANN is completed, all relevant information is extracted, and an equivalent CasADi graph is created for later use in the model or model-based controllers and estimators.

23The following example shows how to define an ANN consisting of two layers with 10 neurons each, using a sigmoid function as activation function, and how to train the resulting model where Dense(...) creates a fully connected layer.One can simply replace specific variables of a model with the predictions of the ANN by the command model.substitute_from(ann).The variables to be replaced will be automatically detected and exchanged with the corresponding predictions of the ANN.Alternatively, it is also possible to directly add the ANN to the model via summation or subtraction.

Gaussian Processes

24A Gaussian process (GP) is a probability distribution over a function in which any finite subset of random variables has a joint Gaussian distribution. 39Besides being less prone to overfitting, one key advantage of using a GP is that it naturally measures the output uncertainty by estimating the variance of the predictions.GPs can be used to approximate input-output mappings = ( ) + , where the output ∈ ℝ is affected by some zero-mean normally distributed measurement noise ∼  (0, 2 ) with variance 2 .Starting from a given prior distribution, described by a mean function and a covariance function, the GP is trained on observed data (see Figure 5).

25In general, both the prior mean function and the prior covariance function depend on so-called hyperparameters.During the training, the hyperparameters are obtained via optimization, i.e., the hyperparameters are chosen such that the resulting GP can be used to infer the input-output mapping given available training data.Typically, the prior mean function is assumed to be zero, 40 but HILO-MPC also supports other prior mean functions.The covariance function, or kernel, is often assumed to be a smooth function that is infinitely differentiable.A number of covariance functions that meet this criterion are provided, e.g., the stationary squared exponential and rational quadratic kernels.The prior means, as well as the kernels, can be combined with each other through summation or multiplication.

26The objective of the optimization problem that underlies the training step is usually to maximize the log marginal likelihood 39 log ( (

27where ∈ ℝ × describes the matrix containing the training inputs, ∈ ℝ × is the covariance matrix resulting from the used kernel and the supplied training data, and is the identity matrix of corresponding size.The element ( , ) of is ( , ), where ∶ ℝ × ℝ → ℝ is the kernel.The predictive mean ̄ and variance 2 of the trained GP can be obtained for test data as follows

28where the -th element of ̃ ∈ ℝ is ( , ).The following example outlines how GPs can be setup Similarly to ANNs, the GPs can be integrated in models.

Control Module

29The control module realizes feedback controllers of proportional-integral-derivative (PID) type, linear quadratic regulators (LQR), as well as optimal and MPC controllers.The latter are outlined in the following.

Model Predictive Control

30Model predictive control repeatedly solves a finite-horizon optimal control problem (OCP). 41,42,43Optimal control problems and MPC problems for continuous-time systems are realized in sampled-data fashion in HILO-MPC as outlined in the following. 44quivalent formulations for discrete-time nonlinear system are also possible.At a sampling time 0 the optimal control problem

310 ≥ ( , ( ), ( ), ( ), ), (3d)

32for

33Here, (⋅) is the optimal input function,

34cost, is the prediction horizon, and the control horizon.The vector ̂ ( 0 ) contains the measured or estimated states at the current sampling time 0 and is the time variable.The equation

35Remark 1.In principle any of the equations in (3) could be completely or partially learned from data (see Figure 2), using the learning approaches outlined in Section 3.2.Table 3 gives an overview of other works where different components are learned.These cases can be handled using the machine learning module.

360 ≥ ( , ( ), ( ), , ), (4e)

37where Δ is the sampling time, = ceil( ∕Δ ) is the control horizon and = … is the sequence of piece-wise constant inputs applied to the plant, i.e., ( ) = , ∀ ∈ [ , + Δ ) ⊂ ℝ.The function ceil ∶ ℝ → ℤ is the ceiling function, i.e., a function that returns the smallest integer that is larger than a given real number.HILO-MPC also implements the multiple shooting approach. 56The integration of the system model in between the shooting points can be done with Runge-Kutta methods of various order, orthogonal collocation, 57 or the dynamics can be integrated with CVODES or IDAS solvers. 58The default method is orthogonal collocation, while any other method can be selected if needed.Note that for simplicity piece-wise, constant inputs are assumed at every control interval, which can be generalized to introducing virtual inputs.Hence, the real formulation of Problem (3) depends on which method is used for the discretization.Here, no further details of the formulation of the approximated problem are provided.See the cited papers for more information.

38Remark 2. Note that it is also possible to optimize the sampling intervals.This will add to Problem (4) the vector Δ … Δ as optimization variable.This allows the solution of minimum time problems, and optimal sampling time problems.This frequently appears for example in network controlled systems. 59,5e stage cost (⋅) and arrival cost (⋅) depend on the type of optimal control formulation/MPC formulation implemented.In the following we sketch different MPC formulations contained in the toolbox.For simplicity of explanation, we focus on quadratic cost functions; however, HILO-MPC is not limited to those.

MPC for set point tracking

39In set point tracking MPC 60 the variables , and are desired to track a known reference, which can be formulated in terms of the cost function and terminal cost, for example, as

40Here , , and are fixed references and ∈ ℝ × , ∈ ℝ × , ∈ ℝ × , T ∈ ℝ × , and T ∈ ℝ × are weighting matrices.To outline the simplicity to formulate MPC problems, consider the one-track car model as discussed in section 3.1.The goal is that the car should track a set point reference speed r = 2 m∕s.We consider a prediction horizon of 20 steps.The corresponding MPC controller can be formulated as The solution of the MPC (e.g., input and state sequences) are stored in the mpc.solution() object.

MPC for trajectory-tracking

41For trajectory tracking problems the variables need to track a time-varying reference. 60Considering a quadratic cost function, this can be formulated as

42Here ∶ ℝ → ℝ , ∶ ℝ → ℝ , and ∶ ℝ → ℝ are time-varying references.For example, a trajectory tracking problem for a single-track car model can be defined by

MPC for path following

43While in the MPC for trajectory tracking both the value of the reference and time are fixed simultaneously, MPC for path following exploits additional degrees of freedom by choosing when to be where on the path. 60,61Do do so, we augment the model with a virtual path state min (⋅), pf (⋅) 0 + ∫ 0 ( , ( ), ( ), ( ), )d + ( 0 + , ( 0 + ), ( 0 + ), ), (5a) s.t.̇ ( ) = ( , ( ), ( ), ( ), ), ( 0 ) = ̂ ( 0 ), (5b) 0 = ( , ( ), ( ), ( ), ), (5c)

440 ≥ ( , ( ), ( ), ( ), , ), (5e)

45for

46Here ∈ ℝ is a virtual path state vector and pf ∈ ℝ , is the virtual input that the controller can choose.Hence, the objective function becomes

47To force the controller to move only in the direction of the path usually a lower bound on pf is added, i.e., pf > pf,min with pf,min ∈ ℝ , + .It is also possible to track a constant pf , so that the MPC tries to maintain a constant speed of the virtual state

48In comparison to other toolboxes, path following MPC/optimal control problems can be easily formulated.The user needs to activate the path following mode for the desired variables, as shown in the following Note that the toolbox allows to mix the previous problem formulations with minimum effort, e.g., the user can track some constant references for some of the variables, while performing path tracking for the other variables.

Soft constraints

49Soft constraints are typically used in optimal control/MPC to avoid infeasibility, conservative solutions due to active constraints, or to speed up computations. 62,63When soft constraints are selected, slack variables p ∈ ℝ and T ∈ ℝ ,T are automatically added to the path and terminal constraints, respectively, as follows

50p ≥ ( , ( ), ( ), ( ), ),

51T ≥ ( 0 + , ( 0 + ), ( 0 + ), ),

52( ) = ℎ( , ( ), ( ), ( ), ), (6f)

53for

54where and p ∈ ℝ × and T ∈ ℝ ,T × ,T are weighting matrices that limit the increase of the slack variables and can be chosen by the user, and p,max and T,max are the maximum constraint violations of path and terminal constraints, respectively.

Estimator Module

55Estimating states and parameters from measurements is indispensable in control if not all variables can be accessed directly.

56The estimator module provides access to a moving horizon estimator, Kalman filters, and particle filters.

Moving Horizon Estimation

57Moving horizon estimators (MHE) obtain state estimates based on the solution of an optimization problem similar to the MPC problem. 42,64,65We focus on moving horizon estimators operating on equidistant sampling times.At these sampling times measurements are taken.Due to the discrete measurements, the objective function in an MHE is usually given in discrete form.

58For simplicity we indicate with (⋅)

59| the variable at time , i.e., for the MHE problem solved at time we obtain

60for

61where ̄ is the horizon length, ̂ the output measurements, and ̂ the input measurements at time .The first term of the objective function is the arrival cost, while the second and third weigh the measurement and state noise, respectively. 42,66he matrices ∈ ℝ × , ∈ ℝ × and ∈ ℝ ( + )×( + ) are the weighting matrices for the outputs, state noise, and arrival cost.The optimization variables are: the state − ̄ | , i.e., the state at the beginning of the horizon, the state noise

62]} and the system parameters .Note that the parameters are considered constant in the horizon, but can be updated every time the optimization is run, to adapt to the new measurements.For the single-track car model, an MHE with = = = 10 (where is the identity matrix of appropriate dimensions) can be easily defined as follows Similar to other objects, the solution of the MHE is stored in mhe.solution().

Kalman Filters and Particle Filters

63Besides an MHE, Kalman filters (KFs) and particle filters (PFs) are provided for estimation.KFs allow for the estimation of observable states via available measurement data.Generally, a KF consists of two steps: the prediction step and the update step.

64In the prediction step, the estimated states from the previous iteration are propagated through the model dynamics to obtain preliminary values for the states at the current time step, the so-called a priori estimates.These a priori estimates are then updated in the update step using the measurement data to obtain a posteriori estimates.HILO-MPC contains KFs in various formulations.An unscented KF 67 can simply be integrated by

65In a similar fashion particle filters can be formulated and used.

Embedded Module

66Implementing optimization-based controllers/MPC controllers on embedded systems requires a tailored implementation.By now, a series of tailored automatic code generation tools for MPC exist. 17,19,16,68ILO-MPC provides an interface for the code generation of MPC for linear time-invariant discrete-time model predictive control, tailored for small embedded systems, like microcontrollers. 16he code generation is limited to discrete-time linear time-invariant systems of the form

67subject to input and state constraints ≤ ≤ , ≤ ≤ , where and denote the state and input at the current sampling time, and + denotes the state at the next sampling time.The considered linear MPC problem formulation is

68where the integer ≥ 2 is the prediction horizon, the matrices ∈ ℝ × , ∈ ℝ × and ∈ ℝ × are the state, input, and terminal weighting matrix, respectively.The input sequence u = 0 … −1 is the optimization variable.For automatic code generation of the problem (9) tailored towards microcontrollers, we rely on AO-MPC, 16 a code generation tool that uses an augmented Lagrangian and Nesterov's fast gradient method. 69,70By design, the algorithm's implementation is simple and relies only on matrix-vector operations (i.e., no divisions), it can easily be warm started and computes good MPC inputs in very few iterations of the algorithm.For well-behaved problems, the computations can be made more efficient by using fixed-point arithmetic (instead of floating-point).

69The code generation reformulates the MPC optimization problem (9) as a condensed parametric QP ( )

70where the constant Hessian matrix = > 0 ∈ ℝ × and the gradient vector ( ) depend on the system (8) and the objective function in (9).Additionally, ( ) depends on the current state (i.e., the parameter).The set  = {u | ≤ ≤ , = 0, ..., − 1} defines the input constraints.The constant matrix and the constraint vectors z( ) and z( ) depend on the constraints in (9).

71The generated code is highly portable C-code.It is split into the data for the QP ( ) (e.g., the constant matrix and the parametric vector ( )) and the implementation of the optimization algorithm to solve the QP. 69,70igure 6 depicts an overview of the embedded module.Similarly to other modules, the LMPC class is initialized using a Model object.In this case, a linear time-invariant discrete-time model is used.Calling the LMPC.setup()method, specifying the solver 'muaompc', will trigger the code generation procedure.The code generation automatically creates C-code which can be compiled to run on an embedded target.Additionally, a Python interface to the generated C-code is also created.This Python interface is used by the LMPC.optimize()method to obtain the input that minimizes 9.The basic use of the Embedded Module is exemplified in the following Python code from hilo_mpc import LMPC, Model # The Model class uses the linear system matrices A, B, and # the LMPC class uses the weighting matrices Q, R, P, constraints, etc., # to create the mpc object.Using the solver muaompc triggers the code generation mpc.setup(nlp_solver='muaompc') # the generated MPC code can be used directly on an embedded target using C, # or via the Python interface as HILO-MPC does on the next line u = mpc.optimize(x0=x)

EXAMPLES

72We underline the flexibility of the toolbox considering a series of examples, which can be also found in the repository, as Python files or Jupyter notebooks.Thus, we do not provide implementation details, just a high-level description of the problems and outline some of the results.

Learning the System Dynamics -Racing a Minicar

73We consider autonomous racing of a minicar, based on the results and models presented in Liniger et al. 71 The goal is to use model predictive control to follow a complex track using a path following formulation in presence of disturbances (see Figure 7a).An extended single-track model of the car, see 7a and section 3.1, including nonlinear tire models and drive train models as identified and validated in experiments in Liniger et al. 71 where and are the coordinates of the center of gravity, and are longitudinal and lateral velocities of the center of gravity.The orientation is denoted by and the yaw rate by .The control inputs are the motor duty cycle and steering angle .The two parameters and are the distances from the center of gravity to the front axle and rear axle, respectively, is the mass of the car, and is the inertia.Figure 7a shows the single-track car model.The path is the center of a racing track that has been interpolated using splines.The tire forces are modeled with a simplified Pacejka Tire Model is the drag coefficient, is the air density, is the effective flow surface, and , is the lateral wind velocity.The model used by the MPC does not have the drag effect.The goal is to learn this effect from data using a neural network and then augment the first principles model with a machine learning component that models the drag effect.After discretization, the hybrid model can be written as

74where ( , ) is an NN model.The features of the NN are ,wind and , the labels are correction terms for , , , and via the weighting matrix .To show the effectiveness of the learning, we compare the results of MPC using the perfect model (i.e., with known drag force effects), the hybrid model (using the NN), and the model without drag forces.Furthermore, the measurements of position, velocity, and directions are affected by Gaussian noise and estimated using an unscented KF. Figure 7b shows the results of the simulation.While the hybrid model has similar results as the perfectly-known model, the model without drag exits the race area after the fifth curve.

X [m] Y [m]

75(a) Complex single-track/bicycle car model.

Learning a Reference -Cooperative Robots

76Inspired by 73 we consider that a follower robot has to track the position of a leader robot, where the leader moves along a periodic but unknown trajectory (see Figure 8).The trajectory is learned from data using a GP.

77The objective is to learn the trajectory of the leader with GPs, which are used in the follower.Hence, in this case the machine learning model enters the cost function.The nonlinear dynamics of the robots are described with the following simple dynamics ODE

78Here 1 and 2 are the horizontal and vertical position of the root, 3 its heading angle, 1 is the speed, and 2 the turning rate.The resulting tracking problem takes the form (3) with the objective function (5a), where (⋅) is the mean function of a GP trained on the data set collected from the position of the leader.The trajectory generated by the leader results from applying the time-varying forces 1 ( ) = 2 + 0.1 sin( ) and 2 ( ) = 0.5 + sin( ). Figure 9 shows the results of the reference learning and closed-loop simulations.

Learning the Controller -Spring Damper System

79Solving an MPC requires the solution of a (nonlinear) optimization problem online.For embedded applications with low computational power or applications that can use only a limited amount of energy (for example battery powered systems) this is often not possible.Hence, methods that provide at least a close-to-optimal solution without solving the optimization problem at every time step are necessary.This can be done using explicit MPC approaches. 74,75One way to avoid the explicit solution is to learn the solution of an MPC offline, i.e., to learn the map  → ( ) that (approximates) the implicit MPC control law, and then using the learned controller online (see Figure 2). 76,77,78,79,80,81,82In this way, the control action can be found with a simple and fast function evaluation.We consider the control of a mass-spring-damper system using a learned controller.The models is given by

80where 1 is the vertical position, 2 the vertical velocity, the vertical force, and , the system parameters.The equilibrium point is = (0, 0), = 0.The objective is to maintain the reference ref = [1, 0] using a learned MPC.In total 667 data points, obtained by simulations, are collected.We use the data to train an NN via HILO-MPC with three fully-connected layers, with 10 neurons each.The features of the NN are 1 and 2 , and the label is the input .We test the learned controller starting from a different initial condition (0) = (10, 0).In Figure 10 the simulation results are shown.The learned controller is able to bring the system to the reference like the original controller.

Embedded MPC -HIL Simulation using an Arduino

81We conclude by presenting a hardware-in-the-loop (HIL) simulation based on the code generated by the embedded module (see Subsection 3.5).Figure 6 depicts the code generation and HIL simulation setup.The generated C-code is cross compiled to run on an Arduino microcontroller.The system dynamics are simulated on a laptop computer using the nominal linear model + = + .Using a serial interface (i.e.USB to UART), the state + is transferred to the Arduino, to compute a new sequence u by solving the parametric QP ( ).Only the first part 0 of this sequence is transferred by the Arduino to the computer via the serial interface.

82The system to be controlled is the linearized lateral dynamics of the race car.The input is the steering angle = .The state is defined as = [ ] , where is the lateral position of the center of mass of the car, and is the orientation of the car with respect to the -axis and = ̇ (refer to Figure 7a).The input is constrained to −0.1 ≤ ≤ 0.1, and the state 1 = must satisfy −0.1 ≤ 1 ≤ 0.1.

83For the HIL simulation, we used an Arduino Nano 33 BLE. 83 5We use a discretization time of 15 ms, and a horizon length of 20 steps.The Arduino requires around 10 ms to find (an approximate) solution to the MPC problem on each iteration.The compiled C-code takes about 20 kB of flash memory.

84Figure 11 shows the compared trajectories of states and input for the HIL simulation (approximate solution on Arduino using single precision float) and the exact solution computed by a laptop using HILO-MPC's interface to CPLEX.Note that neither the input nor the state constraints are violated.The main differences are due to the early termination of the embedded algorithm, and the use of single precision float.

CONCLUSIONS AND OUTLOOK

85While the use of machine learning approaches for model-based optimal control, such as predictive control and estimation are becoming increasingly important, currently there is no easy-to-use open-source tool available to support the researcher and developer.We outlined the concept and ideas behind HILO-MPC, a toolbox for fast development of optimal and predictive control and estimation methods that facilitates the use of machine learning models trained using PyTorch and TensorFlow for simulations and embedded applications.The concept is easily expandable and we underlined the simple use considering four examples.The toolbox allows to consider different methods, spanning from model predictive and optimal control, moving horizon estimation, and Kalman filters to particle filters.We believe that it is a flexible, yet easy-to-use tool for research and teaching.Future developments will allow using extended machine learning models such as recurrent neural networks, Bayesian neural networks and reinforcement learning, as well as extended control formulations, such as tube-based MPC, stochastic MPC, 84 and multi-mode MPC. 85,86Furthermore, we are expanding the toolbox towards code generation for embedded nonlinear MPC using the Al'brekht's method. 87,88,89

FIGURE 1

86FIGURE 1Core elements of HILO-MPC.

FIGURE 3

87FIGURE 3Simple single-track/bicycle car model.

FIGURE 4

88FIGURE 4Simple feedforward neural network with four features (inputs), one hidden layer and one label (output).

89from hilo_mpc import ANN, Dense # Initialize NN ann = ANN(features, labels) ann.add_layers(Dense(10, activation='sigmoid')) ann.add_layers(Dense(10, activation='sigmoid')) # Add training data set ann.add_data_set(df) # Set up NN ann.setup() # Train the NN batch_size = 64 epochs = 1000 ann.train(batch_size, epochs, validation_split=.2, patience=100, scale_data=True)

3 − 2 0 2 MeasurementsFIGURE 5

90FIGURE 5 Simple example of a GP fitting to a sinusoidal function.The left figure shows a non-zero prior mean with 1 standard deviation.The right figure shows the posterior of the GP conditioned on the measurements with optimal hyperparameters.The measurements are affected by a zero-mean white noise.

0 (

91, ( ), ( ), ( ), )d + ( 0 + , ( 0 + ), ( 0 + ), ), (3a) s.t.̇ ( ) = ( , ( ), ( ), ( ), ), ( 0 ) = ̂ ( 0 ), (3b) 0 = ( , ( ), ( ), ( ), ),

92from hilo_mpc import NMPC nmpc = NMPC(model) nmpc.horizon= 20 nmpc.quad_stage_cost.add_states(names=['v'],ref=2, weights=10) nmpc.quad_term_cost.add_states(names=['v'],ref=2, weights=10) nmpc.setup()The resulting MPC controller can be easily used in a control loop # Choose number of steps n_steps = 100 # Begin simulation loop for step in range(n_steps): # find optimal input u = nmpc.optimize(x0)# Simulate the plant model.simulate(u=u)# Get the current states x0 = sol['xf']

93from hilo_mpc import NMPC nmpc = NMPC(model) nmpc.horizon= 20 theta = nmpc.create_path_variable()traj_x = 30 -14 * cos(theta) traj_y = 30 -16 * sin(theta) nmpc.quad_stage_cost.add_states(names=['px','py'], ref=[traj_x, traj_y], weights=[10, 10], path_following=True) → nmpc.quad_term_cost.add_states(names=['px','py'], ref=[traj_x, traj_y], weights=[10, 10], path_following=True) → nmpc.setup()

FIGURE 6 A

94FIGURE6 A scheme of the Embedded module.Left, the typical used of the module, including automatic code generation provided by AO-MPC.Right, a hardware-in-the-loop simulation used as example.

95is used.We extend the model adding a component describing the effect of lateral drag forces due to, for example, a strong wind.The overall model is represented by the following system of nonlinear differential equations ̇ = cos( ) − sin( ), ̇ = sin( ) + cos( ), ̇ = , ̇ = 1 , − , − ( , − , ) sin( ) + , ̇ = 1 , − , − ( , − , ) cos(

96Race track and results.

FIGURE 7

97FIGURE 7Example of a racing car driving on a racetrack following a given path.

FFIGURE 8

98FIGURE 8Cooperative robot example.The follower should track the leader, who follows a periodic, yet unknown trajectory.The trajectory is learned from data using a GP.

FIGURE 9

99FIGURE 9Left column: learned GP.Right column: states of the follower robot following the learned references.

FIGURE 10

100FIGURE 10Comparison of the learned and exact MPC.

FIGURE 11

101FIGURE 11 Comparison of HIL simulation and exact simulation

Table 2

102summarizes some of the main differences between existing open-source toolboxes.

TABLE 1

103Components and formulations imtegrated in HILO-MPC.

1042The full documentation and toolbox are available under http://www.ccps.tu-darmstadt.de/hilo_mpc.FIGURE 2Schematic diagram of the interactions between the components of the toolbox.The machine learning component can be used to learn model parts (see Section 4.1), cost functions, constraints, or references/disturbances (see Section 4.2) from real or simulation data, that can then be used in the controller or estimator.It can also be used to learn an approximated solution of an optimal controller/MPC controller (seeSection 4.3).It is also possible to generate embedded code for the controller (see Section 4.4).In principle, similarly, the same holds for learning components of the estimator.

TABLE 2

105Comparison of different freely accessible MPC tools.ML: machine learning, MHE:

TABLE 3

10646lected, non-extensive overview of learned components of MPC and optimal control problems in the literature.Matschek et al.45, Carron et al.46, . . .terminal constraints (3e) Rosolia et al. 47 , Rosolia and Borrelli 48 , Brunner et al. 49 , . . .path constraints (3d) Bujarbaruah et al. 50, Armesto et al. 51 , Holzmann et al. 52 , . . .objective function (3a) Tamar et al. 53 , Beckenbach et al. 54 , Bradford and Imsland 55 , . . .

107Solving Problem (3) directly is challenging, since (⋅) and the constraints are infinite-dimensional.HILO-MPC uses direct approaches to transform the problem into an equivalent finite-dimensional optimization problem.These approaches parameterize the input with a finite number of parameters, for example, using piece-wise constant inputs, and enforce the constraints only on a finite number of points.The resulting problem becomes min ∑

108After this setup, it can be deployed for estimation simply by

참고문헌 75건

  1. A Survey on Explicit Model Predictive Control Lecture notes in control and information sciences · Springer Science+Business Media · 2009 10.1007/978-3-642-01094-1_29
  2. Nonlinear Predictive Control and Moving Horizon Estimation — An Introductory Overview Springer eBooks · Springer Nature · 1999 10.1007/978-1-4471-0853-5_19
  3. Learning representations by back-propagating errors Nature · Nature Portfolio · 1986 10.1038/323533a0
  4. A Multiple Shooting Algorithm for Direct Solution of Optimal Control Problems * IFAC Proceedings Volumes · Elsevier BV · 1984 10.1016/s1474-6670(17)61205-9
  5. Optimization‐based autonomous racing of 1:43 scale RC cars Optimal Control Applications and Methods · Wiley · 2014 10.1002/oca.2123
  6. The unscented Kalman filter for nonlinear estimation 2002 10.1109/asspcc.2000.882463
  7. Knitro: An Integrated Package for Nonlinear Optimization Nonconvex optimization and its applications · Springer Nature · 2006 10.1007/0-387-30065-1_4
  8. Tyre Modelling for Use in Vehicle Dynamics Studies SAE technical papers on CD-ROM/SAE technical paper series · 1987 10.4271/870421
  9. ACADO toolkit—An open‐source framework for automatic control and dynamic optimization Optimal Control Applications and Methods · Wiley · 2010 10.1002/oca.939
  10. Robust model predictive control of constrained linear systems with bounded disturbances Automatica · Elsevier BV · 2004 10.1016/j.automatica.2004.08.019
  11. A logical calculus of the ideas immanent in nervous activity Bulletin of Mathematical Biology · Springer Science+Business Media · 1943 10.1007/bf02478259
  12. μAO-MPC: A free code generation tool for embedded real-time linear model predictive control American Control Conference · 2013 10.1109/acc.2013.6580668
  13. State and Output Feedback Nonlinear Model Predictive Control: An Overview European Journal of Control · Elsevier BV · 2003 10.3166/ejc.9.190-206
  14. Provably safe and robust learning-based model predictive control Automatica · Elsevier BV · 2013 10.1016/j.automatica.2013.02.003
  15. qpOASES: a parametric active-set algorithm for quadratic programming Mathematical Programming Computation · Springer Science+Business Media · 2014 10.1007/s12532-014-0071-1
  16. From model-based control to data-driven control: Survey, classification and perspective Information Sciences · Elsevier BV · 2012 10.1016/j.ins.2012.07.014
  17. Explicit MPC-Based RBF Neural Network Controller Design With Discrete-Time Actual Kalman Filter for Semiactive Suspension IEEE Transactions on Control Systems Technology · Institute of Electrical and Electronics Engineers · 2015 10.1109/tcst.2014.2382571
  18. A receding-horizon regulator for nonlinear systems and a neural approximation Automatica · Elsevier BV · 1995 10.1016/0005-1098(95)00044-w
  19. Fast predictive control of linear systems combining Nesterov's gradient method and the method of multipliers 2011 10.1109/cdc.2011.6160688
  20. Use of orthogonal collocation method in optimal control problems International Journal of Control · Taylor & Francis · 1977 10.1080/00207177708922339
  21. A New Approach to Linear Filtering and Prediction Problems Journal of Basic Engineering · American Society of Mechanical Engineers · 1960 10.1115/1.3662552
  22. Predictive control with Gaussian process models 2004 10.1109/eurcon.2003.1248042
  23. On the implementation of an interior-point filter line-search algorithm for large-scale nonlinear programming Mathematical Programming · Springer Science+Business Media · 2005 10.1007/s10107-004-0559-y
  24. Networked Control Systems With Communication Constraints: Tradeoffs Between Transmission Intervals, Delays and Performance IEEE Transactions on Automatic Control · Institute of Electrical and Electronics Engineers · 2010 10.1109/tac.2010.2042352
  25. Explicit MPC for LPV Systems: Stability and Optimality IEEE Transactions on Automatic Control · Institute of Electrical and Electronics Engineers · 2012 10.1109/tac.2012.2187400
  26. SUNDIALS ACM Transactions on Mathematical Software · Association for Computing Machinery · 2005 10.1145/1089014.1089020
  27. Predictive control, embedded cyberphysical systems and systems of systems – A perspective Annual Reviews in Control · Elsevier BV · 2016 10.1016/j.arcontrol.2016.04.002
  28. Deep Learning in Medical Image Analysis Annual Review of Biomedical Engineering · Annual Reviews · 2017 10.1146/annurev-bioeng-071516-044442
  29. YALMIP : a toolbox for modeling and optimization in MATLAB 2005 10.1109/cacsd.2004.1393890
  30. Nonlinear Model Predictive Control Communications and control engineering/Communications and control engineering series · 2016 10.1007/978-3-319-46024-6
  31. Rapid development of modular and sustainable nonlinear model predictive control solutions Control Engineering Practice · Elsevier BV · 2016 10.1016/j.conengprac.2016.12.009
  32. UKACC International Conference on CONTROL 2000 2000
  33. Efficient learning of constraints and generic null space policies 2017 10.1109/icra.2017.7989181
  34. Repetitive learning model predictive control: An autonomous racing example 2017 10.1109/cdc.2017.8264027
  35. Deep Learning for Computer Vision: A Brief Review Computational Intelligence and Neuroscience · Hindawi Publishing Corporation · 2018 10.1155/2018/7068349
  36. Efficient Representation and Approximation of Model Predictive Control Laws via Deep Learning IEEE Transactions on Cybernetics · Institute of Electrical and Electronics Engineers · 2020 10.1109/tcyb.2020.2999556
  37. CasADi: a software framework for nonlinear optimization and optimal control Mathematical Programming Computation · Springer Science+Business Media · 2018 10.1007/s12532-018-0139-4
  38. Activation functions and their characteristics in deep neural networks 2018 10.1109/ccdc.2018.8407425
  39. Deep learning methods in transportation domain: a review IET Intelligent Transport Systems · Institution of Engineering and Technology · 2018 10.1049/iet-its.2018.0064
  40. Approximating Explicit Model Predictive Control Using Constrained Neural Networks 2018 10.23919/acc.2018.8431275
  41. Nonlinear Predictive Control for Trajectory Tracking and Path Following: An Introduction and Perspective Control engineering · Springer International Publishing · 2018 10.1007/978-3-319-77489-3_8
  42. A Deep Learning Architecture for Predictive Control IFAC-PapersOnLine · Elsevier BV · 2018 10.1016/j.ifacol.2018.09.373
  43. Multi-Mode Learning Supported Model Predictive Control with Guarantees IFAC-PapersOnLine · Elsevier BV · 2018 10.1016/j.ifacol.2018.11.037
  44. Addressing infinite-horizon optimization in MPC via Q-learning IFAC-PapersOnLine · Elsevier BV · 2018 10.1016/j.ifacol.2018.10.175
  45. Towards a modular software package for embedded optimization IFAC-PapersOnLine · Elsevier BV · 2018 10.1016/j.ifacol.2018.11.062
  46. A Survey on 3D Object Detection Methods for Autonomous Driving Applications IEEE Transactions on Intelligent Transportation Systems · Institute of Electrical and Electronics Engineers · 2019 10.1109/tits.2019.2892405
  47. Multi-mode Model Predictive Control and Estimation for Uncertain Biotechnological Processes IFAC-PapersOnLine · Elsevier BV · 2019 10.1016/j.ifacol.2019.06.146
  48. Learning from the hindsight plan — Episodic MPC improvement 2017 10.1109/icra.2017.7989043
  49. Autonomous racing using learning Model Predictive Control 2022 American Control Conference (ACC) · 2017 10.23919/acc.2017.7963748
  50. Learning Model Predictive Control for Iterative Tasks. A Data-Driven Control Framework IEEE Transactions on Automatic Control · Institute of Electrical and Electronics Engineers · 2017 10.1109/tac.2017.2753460
  51. Data-Driven Model Predictive Control for Trajectory Tracking With a Robotic Arm IEEE Robotics and Automation Letters · Institute of Electrical and Electronics Engineers · 2019 10.1109/lra.2019.2929987
  52. Deep Learning for IoT Big Data and Streaming Analytics: A Survey IEEE Communications Surveys & Tutorials · Institute of Electrical and Electronics Engineers · 2018 10.1109/comst.2018.2844341
  53. 2013 European Control Conference (ECC) 2022 European Control Conference (ECC) · 2013 10.23919/ecc31304.2013
  54. Learning-Based Model Predictive Control: Toward Safe Learning in Control Annual Review of Control Robotics and Autonomous Systems · Annual Reviews · 2019 10.1146/annurev-control-090419-075625
  55. Hybrid Modeling in Process Industries CRC Press eBooks · Informa · 2018 10.1201/9781351184373
  56. Fast Model Predictive Control with soft constraints European Journal of Control · Elsevier BV · 2015 10.1016/j.ejcon.2015.05.003
  57. Learning References with Gaussian Processes in Model Predictive Control applied to Robot Assisted Surgery 2022 European Control Conference (ECC) · 2020 10.23919/ecc51009.2020.9143600
  58. Fallback Approximated Constrained Optimal Output Feedback Control Under Variable Parameters Lecture notes in electrical engineering · Springer Science+Business Media · 2020 10.1007/978-3-030-58653-9_39
  59. Implementation of Nonlinear Model Predictive Path-Following Control for an Industrial Robot IEEE Transactions on Control Systems Technology · Institute of Electrical and Electronics Engineers · 2016 10.1109/tcst.2016.2601624
  60. Online learning‐based model predictive control with Gaussian process models and stability guarantees International Journal of Robust and Nonlinear Control · Wiley · 2021 10.1002/rnc.5361
  61. Learning to Satisfy Unknown Constraints in Iterative MPC 2021 60th IEEE Conference on Decision and Control (CDC) · 2020 10.1109/cdc42340.2020.9303765
  62. Deep Neural Network Approximation of Nonlinear Model Predictive Control IFAC-PapersOnLine · Elsevier BV · 2020 10.1016/j.ifacol.2020.12.538
  63. A Neural Network Architecture to Learn Explicit MPC Controllers from Data IFAC-PapersOnLine · Elsevier BV · 2020 10.1016/j.ifacol.2020.12.546
  64. Approximated Constrained Optimal Control subject to Variable Parameters IFAC-PapersOnLine · Elsevier BV · 2020 10.1016/j.ifacol.2020.12.2385
  65. Continuous-Time Approximated Parametric Output-Feedback Nonlinear Model Predictive Control IFAC-PapersOnLine · Elsevier BV · 2021 10.1016/j.ifacol.2021.08.553
  66. Constrained reference learning for continuous-time model predictive tracking control of autonomous systems IFAC-PapersOnLine · Elsevier BV · 2021 10.1016/j.ifacol.2021.08.565
  67. Data-Driven Science and Engineering 2019 10.1017/9781108380690
  68. (제목 없음) Directory of Open access Books (OAPEN Foundation) · 2022 10.7551/mitpress/3206.001.0001
  69. Advances in neural information processing systems 7 Computers & Mathematics with Applications · Elsevier BV · 1996 10.1016/s0898-1221(96)90463-0
  70. Nonlinear Programming 2010 10.1137/1.9780898719383
  71. 13th AIAA/ISSMO Multidisciplinary Analysis Optimization Conference 13th AIAA/ISSMO Multidisciplinary Analysis Optimization Conference · 2010 10.2514/mmao10
  72. Differential-Algebraic Equations EMS Textbooks in mathematics · EMS Press · 2006 10.4171/017
  73. Learning secure corridors for model predictive path following control of autonomous systems in cluttered environments 2022 European Control Conference (ECC) · 2022 10.23919/ecc55457.2022.9838219
  74. Mathematics in Science and Engineering Mathematics in Science and Engineering/Mathematics in science and engineering · Elsevier BV · 1971 10.1016/s0076-5392(08)61091-7
  75. 2012 American Control Conference (ACC) 2022 American Control Conference (ACC) · 2012 10.1109/acc19473.2012