This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

Data-driven Koopman Operator-based Prediction and Control
Using Model Averaging

Daisuke Uchida and Karthik Duraisamy
Abstract

This work presents a data-driven Koopman operator-based modeling method using a model averaging technique. While the Koopman operator has been used for data-driven modeling and control of nonlinear dynamics, it is challenging to accurately reconstruct unknown dynamics from data and perform different decision-making tasks, mainly due to its infinite dimensionality and difficulty of finding invariant subspaces. We utilize ideas from a Bayesian inference-based model averaging technique to devise a data-driven method that first populates multiple Koopman models starting with a feature extraction using neural networks and then computes point estimates of the posterior of predicted variables. Although each model in the ensemble is not likely to be accurate enough for a wide range of operating points or unseen data, the proposed weighted linear embedding model combines the outputs of model ensemble aiming at compensating the modeling error of each model so that the overall performance will be improved.

I INTRODUCTION

While conventional systems modeling methods describe the dynamics on a state-space, operator theoretic approaches offer an alternative view of the system behaviors through the lens of functions, often called feature maps or observables. The Koopman operator, a linear operator acting on a space of feature maps, has been widely used in the context of data-driven modeling, analysis, and control of nonlinear dynamical systems[1, 2]. It allows linear evolution of the embedded systems on a function space even if the original dynamics is nonlinear in the state-space. Also, it can be approximated numerically from data using either linear regression or neural network training. The Koopman operator framework is especially appealing when applied to controller synthesis since linear controller designs such as Linear Quadratic Regulator (LQR) and linear Model Predictive Control (MPC) can be utilized with the obtained linear embedding model.

However, obtaining accurate and reliable Koopman operator-based models that can be successfully applied to decision-making tasks is still challenging. Specifically, it is known that the convergence property of EDMD does not hold for control systems[3], which implies that Koopman operator-based models may fail to accurately describe control systems even if the training data is sufficiently rich and unbiased. To overcome the modeling error of such Koopman operator-based models for control applications, several data-driven controller designs have been proposed that take model uncertainty into account[4, 5, 6, 7]. Also, if one restricts the attention to control affine systems instead of general nonlinear dynamics, finite-data error bounds are available and stability guarantees may be established on the basis of robust control theories[8, 9]. While many efforts have been made on the model uncertainty of Koopman operator-based models from a controller design perspective, it is also of great importance to devise a modeling method that can yield accurate and generalizable models for control systems. In [10], a model refinement technique is proposed to incorporate data from closed-loop dynamics into model learning so that the modeling error when applied to controller design problems can be directly mitigated. To improve the generalizability of the Koopman operator-based models for a wide range of applications, [11] develops a two-stage learning method utilizing the oblique projection in the context of linear operator learning in a Hilbert space.

In this paper, we adopt a Bayesian approach to learn unknown control systems with the use of the Koopman operator, which takes into consideration that a single Koopman operator-based model is not likely to be accurate and reliable for a wide range of operating points and it will be beneficial to aggregate an ensemble of models and utilize them to find the most useful output. Ensemble approaches are a popular class of methods that aim to improve the accuracy in learning problems by combining predictions of multiple models[12, 13]. We show that the Bayesian Model Averaging (BMA)[14], a Bayesian inference-based model averaging technique, yields a Koopman operator-based model whose parameters are represented as sums of corresponding parameters of individual models weighted by the posterior model evidence. The proposed Koopman Model Averaging (KMA) first populates multiple models, starting from a base model whose feature maps are parameterized by a neural network. Computing point estimates of the original state and the embedded state then results in the same type of linear embedding model while being model-uncertainty aware. The outputs of the individual models are incorporated into this uncertainty-aware model and the overall performance is expected to be improved.

In Section II, the Koopman operator framework for control systems is reviewed. Model learning with neural networks is formulated in Section III, and the proposed modeling approach is derived in Section IV. Numerical examples are provided in Section V for evaluation of the proposed method.

II Koopman Operator Framework

Consider a discrete-time, non-autonomous dynamical system:

xk+1=f(xk,uk),\displaystyle x_{k+1}=f(x_{k},u_{k}), (1)

where xk𝒳nx_{k}\in\mathcal{X}\subseteq\mathbb{R}^{n}, uk𝒰pu_{k}\in\mathcal{U}\subseteq\mathbb{R}^{p}, and f:𝒳×𝒰𝒳f:\mathcal{X}\times\mathcal{U}\rightarrow\mathcal{X} are the state, the input, and the (possibly nonlinear) state-transition mapping, respectively. It is assumed throughout the paper that the dynamics (1) is unknown while we have access to data of the form {(xk,uk,yk)yk=f(xk,uk)}\{(x_{k},u_{k},y_{k})\mid y_{k}=f(x_{k},u_{k})\}.

We embed the state xkx_{k} into a latent space by applying feature maps, or observables, g:𝒳g:\mathcal{X}\rightarrow\mathbb{R}. Let 𝒢\mathcal{G} denote the function space to which the feature maps gg belong. If the input is constant s.t. uku¯u_{k}\equiv\bar{u}, k\forall k, (1) induces autonomous dynamics:

xk+1=fu¯(xk):=f(xk,u¯).\displaystyle x_{k+1}=f_{\bar{u}}(x_{k}):=f(x_{k},\bar{u}). (2)

The state transition through gg is then represented by

g(xk+1)=(gfu¯)(xk)=:(𝒦u¯g)(xk),\displaystyle g(x_{k+1})=(g\circ f_{\bar{u}})(x_{k})=:(\mathcal{K}_{\bar{u}}g)(x_{k}), (3)

where the composition operator 𝒦u¯:𝒢𝒢:ggfu¯\mathcal{K}_{\bar{u}}:\mathcal{G}\rightarrow\mathcal{G}:g\mapsto g\circ f_{\bar{u}} is called the Koopman operator associated with the autonomous dynamics (2). It is obvious from (3) that 𝒦u¯\mathcal{K}_{\bar{u}} is a linear operator and it describes the possibly nonlinear dynamics (2) linearly in the latent space 𝒢\mathcal{G}. Since 𝒦u¯\mathcal{K}_{\bar{u}} is infinite dimensional acting on the function space 𝒢\mathcal{G}, its finite dimensional approximation is often considered for the purpose of dynamical systems modeling. Given NxN_{x} feature maps gi𝒢g_{i}\in\mathcal{G} (i=1,,Nxi=1,\cdots,N_{x}), there exists a matrix KNx×NxK\in\mathbb{R}^{{N_{x}}\times{N_{x}}} s.t.

[𝒦u¯g1𝒦u¯gNx]𝖳=K[g1gNx]𝖳,\displaystyle[\mathcal{K}_{\bar{u}}g_{1}\ \cdots\ \mathcal{K}_{\bar{u}}g_{N_{x}}]^{\mathsf{T}}=K[g_{1}\cdots g_{N_{x}}]^{\mathsf{T}}, (4)

if and only if span(g1,,gNx)\text{span}(g_{1},\cdots,g_{N_{x}}) is an invariant subspace, i.e., 𝒦u¯gspan(g1,,gNx)\mathcal{K}_{\bar{u}}g\in\text{span}(g_{1},\cdots,g_{N_{x}}) for gspan(g1,,gNx)\forall g\in\text{span}(g_{1},\cdots,g_{N_{x}}). Note that finding feature maps gig_{i} that form an invariant subspace may be challenging in practice. In the data-driven setting, one can approximately obtain KK by solving the following linear regression problem:

Kapprox:=argmin𝐾i𝒈(yi)K𝒈(xi)22,\displaystyle K_{\text{approx}}:=\underset{K}{\text{argmin}}\sum_{i}\left\|\bm{g}(y_{i})-K\bm{g}(x_{i})\right\|_{2}^{2}, (5)

where 𝒈(xk):=[g1(xk)gNx(xk)]𝖳\bm{g}(x_{k}):=[g_{1}(x_{k})\cdots g_{N_{x}}(x_{k})]^{\mathsf{T}} and the training data is given as {(xi,yi)yi=fu¯(xi)}\{(x_{i},y_{i})\mid y_{i}=f_{\bar{u}}(x_{i})\}. It admits the unique analytical solution with the use of pseudo inverse and this procedure is called Extended Dynamic Mode Decomposition (EDMD)[15]. Note that the design of the feature maps gig_{i} needs to be pre-specified in EDMD. The finite dimensional approximation KapproxK_{\text{approx}} then yields a linear embedding model of the form:

{g+=Kapprox𝒈(xk),xk+1pred=Wg+,\displaystyle\left\{\begin{array}[]{l}g^{+}=K_{\text{approx}}\bm{g}(x_{k}),\\ x_{k+1}^{\text{pred}}=Wg^{+},\end{array}\right. (8)

where xk+1predx_{k+1}^{\text{pred}} is the predicted state at the next time step and the decoder Wn×NxW\in\mathbb{R}^{n\times{N_{x}}} is similarly obtained by solving linear regression on the given data set. The decoder can be also introduced as a nonlinear mapping depending on the problem.

For general non-autonomous dynamics (1) with control inputs uku_{k}, the corresponding Koopman operator can be defined as follows[3]. For the space of input sequences: l(𝒰):={(u0,u1,)uk𝒰,k}l(\mathcal{U}):=\{(u_{0},u_{1},\cdots)\mid u_{k}\in\mathcal{U},\forall k\}, consider a mapping f^:𝒳×l(𝒰)𝒳×l(𝒰):(x,(u0,u1,))(f(x,u0),(u1,u2,))\hat{f}:\mathcal{X}\times l(\mathcal{U})\rightarrow\mathcal{X}\times l(\mathcal{U}):(x,(u_{0},u_{1},\cdots))\mapsto(f(x,u_{0}),(u_{1},u_{2},\cdots)). Also, let g^:𝒳×l(𝒰)\hat{g}:\mathcal{X}\times l(\mathcal{U})\rightarrow\mathbb{R} be an embedding feature map from an extended space 𝒳×l(𝒰)\mathcal{X}\times l(\mathcal{U}) to \mathbb{R}. Then, the Koopman operator associated with the non-autonomous dynamics (1) is defined as a linear operator 𝒦:𝒢^𝒢^:g^g^f^\mathcal{K}:\hat{\mathcal{G}}\rightarrow\hat{\mathcal{G}}:\hat{g}\mapsto\hat{g}\circ\hat{f} s.t. 𝒢^\hat{\mathcal{G}} is a function space to which feature maps g^:𝒳×l(𝒰)\hat{g}:\mathcal{X}\times l(\mathcal{U})\rightarrow\mathbb{R} belong and the dynamics (1) along with a sequence (uk,uk+1,)(u_{k},u_{k+1},\cdots) of future inputs is represented by

g^(xk+1,(uk+1,uk+2,))\displaystyle\hat{g}(x_{k+1},(u_{k+1},u_{k+2},\cdots)) =(g^f^)(xk,(uk,uk+1,))\displaystyle=(\hat{g}\circ\hat{f})(x_{k},(u_{k},u_{k+1},\cdots))
=(𝒦g^)(xk,(uk,uk+1,)).\displaystyle=(\mathcal{K}\hat{g})(x_{k},(u_{k},u_{k+1},\cdots)).

The argument on the subspace invariance of the Koopman operator (eq. (4)) also holds for the non-autonomous case, which is written as

[𝒦g^1𝒦g^N^]𝖳=K^[g^1g^N^],\displaystyle[\mathcal{K}\hat{g}_{1}\cdots\mathcal{K}\hat{g}_{\hat{N}}]^{\mathsf{T}}=\hat{K}[\hat{g}_{1}\cdots\hat{g}_{\hat{N}}], (9)

where K^N^×N^\hat{K}\in\mathbb{R}^{\hat{N}\times\hat{N}} and N^{\hat{N}} denotes the number of feature maps. In analogous to (8), if we consider N^=Nx+p\hat{N}=N_{x}+p feature maps g^i\hat{g}_{i} (i=1,,Nx+pi=1,\cdots,N_{x}+p) of the form:

[g^1(xk,(uk,uk+1,))g^Nx+p(xk,(uk,uk+1,))]𝖳\displaystyle[\hat{g}_{1}(x_{k},(u_{k},u_{k+1},\cdots))\cdots\hat{g}_{N_{x}+p}(x_{k},(u_{k},u_{k+1},\cdots))]^{\mathsf{T}}
=[g1(xk)gNx(xk)uk𝖳]𝖳,\displaystyle=[g_{1}(x_{k})\cdots g_{N_{x}}(x_{k})\ u_{k}^{\mathsf{T}}]^{\mathsf{T}}, (10)

the first NxN_{x} rows of (9) reads 𝒈(xk+1)=A^𝒈(xk)+B^uk\bm{g}(x_{k+1})=\hat{A}\bm{g}(x_{k})+\hat{B}u_{k}, where [A^B^]Nx×(Nx+p)[\hat{A}\ \hat{B}]\in\mathbb{R}^{{N_{x}}\times(N_{x}+p)} denotes the first NxN_{x} rows of K^\hat{K}. Similar to (8), this yields a linear embedding model:

{g+=A𝒈(xk)+Buk,xk+1pred=Cg+,\displaystyle\left\{\begin{array}[]{l}g^{+}=A\bm{g}(x_{k})+Bu_{k},\\ x_{k+1}^{\text{pred}}=Cg^{+},\end{array}\right. (13)

in which the parameters A,BA,B, and CC may be obtained by EDMD with training data {(xi,ui,yi)yi=f(xi,ui)}\{(x_{i},u_{i},y_{i})\mid y_{i}=f(x_{i},u_{i})\}, i.e.,

[AB]\displaystyle[A\ B] =argmin[AB]i𝒈(yi)[AB][𝒈(xi)ui]22,\displaystyle=\underset{[A\ B]}{\text{argmin}}\sum_{i}\left\|\bm{g}(y_{i})-[A\ B]\left[\begin{array}[]{c}\bm{g}(x_{i})\\ u_{i}\end{array}\right]\right\|_{2}^{2}, (16)
C\displaystyle C =argmin𝐶ixiC𝒈(xi)22.\displaystyle=\underset{C}{\text{argmin}}\sum_{i}\left\|x_{i}-C\bm{g}(x_{i})\right\|_{2}^{2}. (17)

A notable feature of the model (13) is that the model dynamics in the embedded space is given as a linear time-invariant system and linear controller designs can be utilized to control the possibly nonlinear dynamics (1). For instance, with the parameters AA and BB in (13), one can compute an LQR gain that stabilizes the following virtual system:

ξk+1=Aξk+1+Buk,ξkNx.\displaystyle\xi_{k+1}=A\xi_{k+1}+Bu_{k},\ \xi_{k}\in\mathbb{R}^{N_{x}}. (18)

Note that if 𝒈\bm{g} span an invariant subspace, we have the exact relation: 𝒈(xk+1)=A𝒈(xk)+Buk\bm{g}(x_{k+1})=A\bm{g}(x_{k})+Bu_{k}. Since the model (13) has a linear decoder, the quadratic loss 𝒈(xk)𝖳Q𝒈(xk)\bm{g}(x_{k})^{\mathsf{T}}Q\bm{g}(x_{k}) of the LQR problem (QQ is a weight matrix) can be associated with the original state xkx_{k} by 𝒈(xk)𝖳Q𝒈(xk)xk𝖳(C𝖳QC)xk\bm{g}(x_{k})^{\mathsf{T}}Q\bm{g}(x_{k})\approx x_{k}^{\mathsf{T}}(C^{\mathsf{T}}QC)x_{k}.

While we adopt linear embedding models represented in the form (13), which is a common choice in the literature, more expressive ones such as bilinear models are also available if the strict linearity w.r.t. uku_{k} in (13) is not enough to reconstruct the target dynamics[16, 17]. Also, it is noted that in addition to the extension of the Koopman operator framework to control systems reviewed in this section[3], there are other formalisms to utilize the Koopman operator for modeling non-autonomous systems[18].

III Learning Models from Data

The accuracy of the linear embedding model (13) depends on the design of the feature maps 𝒈\bm{g} as well as how the model dynamics parameters AA, BB, and CC are obtained. While EDMD provides a simple model learning procedure with the analytic solution, the design of feature maps needs to be user-specified such as monomials and Fourier basis functions and it may not be sufficiently expressive for complex nonlinear dynamics. Neural networks, on the other hand, are a popular choice of the feature map design since they allow greater expressivity of the model compared to EDMD (e.g., [19, 20, 21]). With the feature maps 𝒈\bm{g} characterized by a neural network, both the model dynamics parameters and the feature maps can be learned simultaneously, which is formulated as the following problem:

Problem 1

Let 𝐠(;θg):𝒳Nx\bm{g}(\cdot;\theta_{g}):\mathcal{X}\rightarrow\mathbb{R}^{N_{x}} be a neural network characterized by parameters θg\theta_{g}. Find θg\theta_{g}, ANx×NxA\in\mathbb{R}^{N_{x}\times N_{x}}, BNx×pB\in\mathbb{R}^{N_{x}\times p}, and Cn×NxC\in\mathbb{R}^{n\times N_{x}} that minimize the loss function:

J(θg,A,B,C):=iλ1A𝒈(xi;θg)+Bui𝒈(yi;θg)22\displaystyle J(\theta_{g},A,B,C):=\sum_{i}\lambda_{1}\left\|A\bm{g}(x_{i};\theta_{g})+Bu_{i}-\bm{g}(y_{i};\theta_{g})\right\|_{2}^{2}
+λ2C(A𝒈(xi;θg)+Bui)yi22,\displaystyle\hskip 42.67912pt+\lambda_{2}\left\|C(A\bm{g}(x_{i};\theta_{g})+Bu_{i})-y_{i}\right\|_{2}^{2}, (19)

where the data set is given in the form {(xi,ui,yi)yi=f(xi,ui)}\{(x_{i},u_{i},y_{i})\mid y_{i}=f(x_{i},u_{i})\} and λ1,λ2\lambda_{1},\lambda_{2}\in\mathbb{R} are hyperparameters.

Although neural network-based models are expected to be more expressive and accurate than EDMD-based ones, Problem 1 is typically a high-dimensional non-convex problem and the resulting models may suffer from overfitting or poor learning. For instance, solving Problem 1 can lead to inaccurate models if the optimization is terminated at a local minimum with a high loss value, or if the quantity and/or quality of training data are not sufficient to reconstruct the target dynamics for a wide range of operating points. Therefore, one may need to repeat the data-collection and learning processes multiple times to obtain a satisfying model in practice, which often takes a long time and consumes a large amount of computational resources.

As the first step of the proposed method, we execute Step 1 to obtain a base model. Considering that the base model may not be perfect, we aim to improve its accuracy further by combining multiple models in the second step. Specifically, an ensemble of linear embedding models (13) is generated using additional data points with the design of feature maps fixed to that of the base model. These models, including the base model, share the same model structure but are trained on different data sets and their predictive capabilities vary. Therefore, even if some model is most accurate for certain unseen data among the model ensemble, others may show better accuracy for different data. To handle this lack of generalizability of individual models, we use all the models so that the accuracy for unknown regimes of dynamics will be improved. Specifically, a Bayesian inference-based model averaging technique is utilized to merge the individual models into a new linear embedding model.

IV Weighted Koopman Operator-based Models

In this section, we first outline the Bayesian Model Averaging (BMA). It is then followed by the formulation of the proposed Koopman operator-based model averaging method.

IV-A Bayesian Model Averaging

Given data 𝒟={(xi,ui,yi)yi=f(xi,ui)}\mathcal{D}=\{(x_{i},u_{i},y_{i})\mid y_{i}=f(x_{i},u_{i})\} and an ensemble of NN models denoted by 𝕄i\mathbb{M}_{i} (i=1,,Ni=1,\cdots,N), the posterior distribution of a quantity of interest qq is represented as

p(q𝒟)=i=1Np(𝕄i𝒟)p(q𝕄i,𝒟),\displaystyle p(q\mid\mathcal{D})=\sum_{i=1}^{N}p(\mathbb{M}_{i}\mid\mathcal{D})p(q\mid\mathbb{M}_{i},\mathcal{D}), (20)

where the posterior model evidence is given by

p(𝕄i𝒟)\displaystyle p(\mathbb{M}_{i}\mid\mathcal{D}) =p(𝒟𝕄i)p(𝕄i)l=1Np(𝒟𝕄l)p(𝕄l).\displaystyle=\cfrac{p(\mathcal{D}\mid\mathbb{M}_{i})p(\mathbb{M}_{i})}{\sum_{l=1}^{N}p(\mathcal{D}\mid\mathbb{M}_{l})p(\mathbb{M}_{l})}. (21)

The marginal likelihood of model 𝕄i\mathbb{M}_{i} is represented by

p(𝒟𝕄i)=p(𝒟θi,𝕄i)p(θi𝕄i)𝑑θi,\displaystyle p(\mathcal{D}\mid\mathbb{M}_{i})=\int p(\mathcal{D}\mid\theta_{i},\mathbb{M}_{i})p(\theta_{i}\mid\mathbb{M}_{i})d\theta_{i}, (22)

where θi\theta_{i} are the parameters of model 𝕄i\mathbb{M}_{i}.

As a point estimate, consider the expectation of qq:

𝔼[q𝒟]\displaystyle\mathbb{E}[q\mid\mathcal{D}] =i=1Np(𝕄i𝒟)qp(q𝕄i,𝒟)𝑑q.\displaystyle=\sum_{i=1}^{N}p(\mathbb{M}_{i}\mid\mathcal{D})\int qp(q\mid\mathbb{M}_{i},\mathcal{D})dq. (23)

The equation (23) may be viewed as a superposition of individual predictions of the model ensemble, each of which is weighted by wi:=p(𝕄i𝒟)w_{i}:=p(\mathbb{M}_{i}\mid\mathcal{D}), so that

(23)𝔼[q𝒟]\displaystyle\eqref{eq. point estimate}\ \Leftrightarrow\ \mathbb{E}[q\mid\mathcal{D}] =i=1Nwi𝔼[q𝕄i,𝒟].\displaystyle=\sum_{i=1}^{N}w_{i}\mathbb{E}[q\mid\mathbb{M}_{i},\mathcal{D}]. (24)

Computing the exact wiw_{i} is difficult in general since it involves the marginalization (22). Therefore, BMA may be approximately implemented in practice, e.g., using the Expectation Maximization (EM) algorithm[22, 23], Markov Chain Monte Carlo (MCMC) methods[24], and Akaike Information Criterion (AIC)-type weighting[25, 26]. In this paper, we adopt an AIC-type weighting method, also called pseudo-BMA, which approximates the weight wiw_{i} as

wi=p(𝕄i𝒟)exp(elpdi)k=1Nexp(elpdk),\displaystyle w_{i}=p(\mathbb{M}_{i}\mid\mathcal{D})\approx\cfrac{\exp(\text{elpd}^{i})}{\sum_{k=1}^{N}\exp(\text{elpd}^{k})}, (25)

where elpdi:=j=1nspt(q~j)log(q~j𝒟,𝕄i)𝑑q~j\text{elpd}^{i}:=\sum_{j=1}^{n_{s}}\int p_{t}(\tilde{q}_{j})\log(\tilde{q}_{j}\mid\mathcal{D},\mathbb{M}_{i})d\tilde{q}_{j} denotes the expected log pointwise predictive density of model 𝕄i\mathbb{M}_{i}, where {q~j}j=1ns\{\tilde{q}_{j}\}_{j=1}^{n_{s}} are unseen new data points and pt(q~j)p_{t}(\tilde{q}_{j}) is the true distribution of the data. In practice, elpdi\text{elpd}^{i} may be also approximated by the Leave-One-Out (LOO) predictor. For details, refer to [25]. To compute the weights wiw_{i}, PyMC[27] is used in the numerical simulations in Section V.

IV-B Koopman Model Averaging

Given a data set 𝒟={(xi,ui,yi)yi=f(xi,ui)}\mathcal{D}=\{(x_{i},u_{i},y_{i})\mid y_{i}=f(x_{i},u_{i})\}, consider an ensemble of NN linear embedding models with the common feature maps zk:=𝒈(xk)Nxz_{k}:=\bm{g}(x_{k})\in\mathbb{R}^{N_{x}}:

z+=Aizk+Biuk,\displaystyle z^{+}=A_{i}z_{k}+B_{i}u_{k}, (26)
xk+1pred=Ciz+,\displaystyle x^{\text{pred}}_{k+1}=C_{i}z^{+}, (27)

where i=1,,Ni=1,\cdots,N. In the proposed algorithm, a base model is trained first by solving Problem 1 on a subset 𝒟1\mathcal{D}_{1} of the entire date set 𝒟\mathcal{D} to obtain the feature maps 𝒈\bm{g} and matrices (A1,B1,C1)(A_{1},B_{1},C_{1}). The remaining model parameters (Ai,Bi,Ci)i=2N(A_{i},B_{i},C_{i})_{i=2}^{N} are obtained by EDMD, each of which is trained on another subset 𝒟i(𝒟𝒟1)\mathcal{D}_{i}\subset(\mathcal{D}\setminus\mathcal{D}_{1}) of the data:

[AiBi]\displaystyle[A_{i}\,B_{i}] :=argmin[AB](xj,uj,yj)𝒟ig(yj)[AB][g(xj)uj]22,\displaystyle:=\underset{[A\ B]}{\text{argmin}}\sum_{(x_{j},u_{j},y_{j})\in\mathcal{D}_{i}}\left\|g(y_{j})-[A\,B]\left[\begin{array}[]{c}g(x_{j})\\ u_{j}\end{array}\right]\right\|_{2}^{2}, (30)
Ci\displaystyle C_{i} :=argmin𝐶(xj,uj,yj)𝒟ixjCg(xj)22,\displaystyle:=\underset{C}{\text{argmin}}\sum_{(x_{j},u_{j},y_{j})\in\mathcal{D}_{i}}\left\|x_{j}-Cg(x_{j})\right\|_{2}^{2}, (31)

where (Ai,Bi,Ci)(A_{i},B_{i},C_{i}) corresponds to the parameters of model 𝕄i\mathbb{M}_{i} in Section IV-A.

Given a state xk𝒳x_{k}\in\mathcal{X} and an input uk𝒰u_{k}\in\mathcal{U}, we assume that both zk+1=𝒈(xk+1)z_{k+1}=\bm{g}(x_{k+1}) and xk+1x_{k+1} have Gaussian distributions conditioned on the ii-th model:

p(zk+1𝕄i,𝒟)=𝒩(zk+1;Aizk+Biuk,Σz),\displaystyle p(z_{k+1}\mid\mathbb{M}_{i},\mathcal{D})=\mathcal{N}(z_{k+1};A_{i}z_{k}+B_{i}u_{k},\Sigma_{z}), (32)
p(xk+1𝕄i,𝒟)=𝒩(xk+1;Ci(Aizk+Biuk),Σ),\displaystyle p(x_{k+1}\mid\mathbb{M}_{i},\mathcal{D})=\mathcal{N}(x_{k+1};C_{i}(A_{i}z_{k}+B_{i}u_{k}),\Sigma), (33)

where Σz\Sigma_{z} and Σ\Sigma are covariance matrices of the distributions.

Taking the expectation (24) w.r.t. zk+1z_{k+1} and xk+1x_{k+1}, we have:

𝔼[zk+1𝒟]\displaystyle\mathbb{E}[z_{k+1}\mid\mathcal{D}] =i=1Nwi(Aizk+Biuk)\displaystyle=\sum_{i=1}^{N}w_{i}(A_{i}z_{k}+B_{i}u_{k})
=(i=1NwiAi)zk+(i=1NwiBi)uk,\displaystyle=\left(\sum_{i=1}^{N}w_{i}A_{i}\right)z_{k}+\left(\sum_{i=1}^{N}w_{i}B_{i}\right)u_{k}, (34)
𝔼[xk+1𝒟]\displaystyle\mathbb{E}[x_{k+1}\mid\mathcal{D}] =(i=1NwiCiAi)zk+(i=1NwiCiBi)uk.\displaystyle=\left(\sum_{i=1}^{N}w_{i}C_{i}A_{i}\right)z_{k}+\left(\sum_{i=1}^{N}w_{i}C_{i}B_{i}\right)u_{k}. (35)

The weight wiw_{i} is then approximately computed according to (25). Finally, equations (34) and (35) yield a new weighted linear embedding model:

zk+1(i=1NwiAi)zk+(i=1NwiBi)uk,\displaystyle z_{k+1}\approx\left(\sum_{i=1}^{N}w_{i}A_{i}\right)z_{k}+\left(\sum_{i=1}^{N}w_{i}B_{i}\right)u_{k}, (36)
xk+1pred=(i=1NwiCiAi)zk+(i=1NwiCiBi)uk.\displaystyle x^{\text{pred}}_{k+1}=\left(\sum_{i=1}^{N}w_{i}C_{i}A_{i}\right)z_{k}+\left(\sum_{i=1}^{N}w_{i}C_{i}B_{i}\right)u_{k}. (37)

The outputs of this model are point estimates of the posterior that take the NN models’ possible outputs into account and are expected to possess a better predictive capability as well as generalizability compared to obtaining a single model only. The proposed method yields a linear embedding model, which can be used for not only prediction but also other decision-making tasks such as controller designs while it is still model-uncertainty aware by computing the point estimates of the posterior. The proposed Koopman Model Averaging (KMA) is summarized in Algorithm 1.

Algorithm 1 Koopman Model Averaging (KMA)
1:Data set 𝒟={(xi,ui,yi)yi=f(xi,ui)}\mathcal{D}=\{(x_{i},u_{i},y_{i})\mid y_{i}=f(x_{i},u_{i})\}
2:Step 1: Training a base model
3:Solve Problem 1 using a subset 𝒟1𝒟\mathcal{D}_{1}\subset\mathcal{D} of the data to obtain the feature maps 𝒈\bm{g} and (A1,B1,C1)(A_{1},B_{1},C_{1}) of the base model
4:Step 2: Model averaging
5:for i=2:Ni=2:N do
6:     Compute (Ai,Bi,Ci)(A_{i},B_{i},C_{i}) in (30) and (31) using a subset 𝒟i(𝒟𝒟1)\mathcal{D}_{i}\subset(\mathcal{D}\setminus\mathcal{D}_{1})
7:end for
8:Extract a subset 𝒟a:=(𝒟i𝒟i)\mathcal{D}_{a}:=(\mathcal{D}\setminus\cup_{i}\mathcal{D}_{i}) of unseen data for the model and compute {wi}i=1N\{w_{i}\}_{i=1}^{N} in (25)
9:Use (37) for state prediction
10:Use (36) for control application

V Numerical evaluations

V-A Duffing Oscillator

We first evaluate the proposed model averaging method using the Duffing oscillator with a control input, which is given by:

x¨(t)=0.5x˙(t)+x(t)4x3(t)+u(t),\displaystyle\ddot{x}(t)=-0.5\dot{x}(t)+x(t)-4x^{3}(t)+u(t), (38)

where the state x(t)x(t) and the input u(t)u(t) are continuous variables. It is assumed that the time-series data x(kΔt)x(k\Delta t), u(kΔt)u(k\Delta t) (k=0,1,k=0,1,\cdots) is available to train models, where Δt\Delta t is the sampling period. Equation (38) yields a difference equation of the same form as (1) with a first-order time discretization so that we can relate the time-series data and the discrete-time dynamics (1) as x(kΔt)=xkx(k\Delta t)=x_{k}, u(kΔt)=uku(k\Delta t)=u_{k}. The sampling period is set to Δt=0.01\Delta t=0.01 in the simulations.

To train a base model, 300 trajectories of the state xkx_{k} are generated, each of which has a length of 50 steps and starts from an initial condition sampled from Uniform[3,3]2\text{Uniform}[-3,3]^{2}. This corresponds to the data 𝒟1\mathcal{D}_{1} in Algorithm 1. Inputs are sampled from a uniform distribution ukUniform[2.5,2.5]u_{k}\sim\text{Uniform}[-2.5,2.5], k\forall k. Following a common practice in the literature, we adopt a specific structure of feature maps of the form:

𝒈(xk)=[xk𝖳g1(xk)g2(xk)]𝖳,\displaystyle\bm{g}(x_{k})=[x_{k}^{\mathsf{T}}\ g_{1}(x_{k})\ g_{2}(x_{k})\cdots]^{\mathsf{T}}, (39)

where the first nn components are the state xkx_{k} itself. This allows an analytic expression of the decoder, i.e., with C=[In 0]C=[I_{n}\ \bm{0}] in (13), we can recover the original state xk=C𝒈(xk)x_{k}=C\bm{g}(x_{k}) without learning the parameter CC. We have one additional feature map g1(xk)g_{1}(x_{k}) in (39), which is a neural network with a single hidden layer consisting of 10 neurons.

To populate the model ensemble, we use 4 data subsets {𝒟i}i=25\{\mathcal{D}_{i}\}_{i=2}^{5} (so that N=5N=5 in Algorithm 1). Each 𝒟i\mathcal{D}_{i} consists of 100 trajectories, each of which is a length of 50 steps. Data set 𝒟a\mathcal{D}_{a} consists of 50 trajectories with a length of 20 steps, each of which is sampled from the same distributions of that of 𝒟i\mathcal{D}_{i}. We use Pytorch to solve Problem 1. PyMC[27] is used to compute wiw_{i} in (25).

To compare with the proposed method, we also train two models: an EDMD model and a neural network-based model obtained by Problem 1. The neural network-based model is labeled normal NN model in the sequel. Pre-specified feature maps for the EDMD model are monomials up to the second order. Both the EDMD and the normal NN models are trained on the entire data set 𝒟={𝒟i}i=15+𝒟a\mathcal{D}=\{\mathcal{D}_{i}\}_{i=1}^{5}+\mathcal{D}_{a} used for learning the proposed model.

We consider two control applications in addition to the state prediction: stabilization by LQR and linear MPC. The objective of the LQR problem is to have the state xkx_{k} converge to 0. In the MPC design, we define a cost function so that the first component of the state xkx_{k} will follow a reference signal:

r(t)={1(t10)1(t>10).\displaystyle r(t)=\left\{\begin{array}[]{r}-1\ (t\leq 10)\\ 1\ (t>10)\end{array}\right.. (42)

The results are shown in Fig. 1. Figures 1(a) and 1(b) are the results of state prediction, where two initial conditions are randomly selected and labeled IC 1 and IC 2, respectively. Since the EDMD model has a simpler feature map design than the other two neural network-based models, it fails to reconstruct the target dynamics. On the other hand, both the normal NN and the proposed models show comparable performance and they successfully predict the future states. Figures 1(c) and 1(d) are the LQR simulation results with randomly selected initial conditions labeled IC 1 and IC 2, respectively. All the controllers designed for the three models achieve the control objective in this task. On the contrary, MPC with the EDMD model fails to track the reference signal as shown in Fig. 1(e). The normal NN model also has a slight steady state error, whereas the proposed weighted model perfectly tracks the reference signal. The validation loss of the normal NN model is 7.60×1067.60\times 10^{-6}, which is smaller by one order of magnitude than that of the base model of the proposed method, which is 1.81×1051.81\times 10^{-5}. However, the proposed model outperforms in the MPC task, which implies the effectiveness of aggregating an ensemble of models to find more accurate model outputs.

Refer to caption
(a) State prediction (IC 1).
Refer to caption
(b) State prediction (IC 2).
Refer to caption
(c) LQR (IC 1).
Refer to caption
(d) LQR (IC 2).
Refer to caption
(e) MPC.
Figure 1: Duffing oscillator.
Refer to caption
(a) State prediction (IC 1).
Refer to caption
(b) State prediction (IC 2).
Refer to caption
(c) LQR (IC 1).
Refer to caption
(d) LQR (IC 2).
Refer to caption
(e) MPC.
Figure 2: Cartpole system.

V-B Cartpole

As a more complex nonlinear system, the cartpole is considered as the second example, whose dynamics is given as follows[2]:

{x˙1=x2,x˙2=m2L2gcosx3sinx3+mL2A(x2,x3,x4)+mL2umL2(M+m(1cos2x3)),x˙3=x4,x˙4=(m+M)mgLsinx3mLcosx3A(x2,x3,x4)+mLcosx3umL2(M+m(1cos2x3)),\displaystyle\left\{\begin{array}[]{l}\dot{x}_{1}=x_{2},\\ \dot{x}_{2}=\cfrac{-m^{2}L^{2}g\cos x_{3}\sin x_{3}+mL^{2}A(x_{2},x_{3},x_{4})+mL^{2}u}{mL^{2}(M+m(1-\cos^{2}x_{3}))},\\ \dot{x}_{3}=x_{4},\\ \dot{x}_{4}=\cfrac{\begin{array}[]{l}(m+M)mgL\sin x_{3}-mL\cos x_{3}A(x_{2},x_{3},x_{4})\\ \hskip 133.72795pt+mL\cos x_{3}u\end{array}}{mL^{2}(M+m(1-\cos^{2}x_{3}))},\end{array}\right. (49)

where A(x2,x3,x4)=mLx42sinx3δx2A(x_{2},x_{3},x_{4})=mL{x_{4}}^{2}\sin x_{3}-\delta x_{2}, m=1m=1, M=5M=5, L=2L=2, g=10g=-10, and δ=1\delta=1. Data collecting procedures and model learning conditions are the same as the first example except for the number of hidden layers of the neural network, which is two for the cartpole system.

The results are shown in Fig. 2. In this example, all the models are successfully applied to the MPC task as in Fig. 2(e). On the other hand, the EDMD model fails in the LQR design problem (Figs. 2(c) and 2(d)), which is considered as a result of too simple feature map design for the four dimensional dynamics of the cartpole. The results of the state prediction are shown in Figs. 2(a) and 2(b). The EDMD model also has difficulty in this task. Both the normal NN and the proposed models show reasonable predictions with the initial condition IC 1 (Fig. 2(a)). However, the prediction of the normal NN model starts deviating from the true values at around t=5t=5 with the second initial condition (Fig. 2(b)). The proposed model, on the other hand, shows better accuracy and its prediction follows the true values until the end of the simulation. It is noted that the validation loss of the normal NN model (1.16×1051.16\times 10^{-5}) is smaller than that of the proposed method (2.82×1052.82\times 10^{-5}). This result implies that the proposed model effectively combines the model ensemble into a new weighted model to acquire high predictive accuracy with respect to wider range of regimes of dynamics than the normal NN model.

VI CONCLUSION

We propose a model averaging method for learning Koopman operator-based models for prediction and control utilizing the Bayesian model averaging. While the Koopman operator framework allows to obtain linear embedding models from data so that linear systems theories can be applied to control possibly nonlinear dynamics, it is challenging to accurately reconstruct the dynamics and deploy the learned model in several applications. Considering that training a single model only may not be sufficient to obtain model predictions that are accurate enough for a wide range of operating points even if the model possesses high accuracy w.r.t. a certain regime of dynamics such as training data, the proposed method first trains a base model with the use of neural networks and then populates an ensemble of models on different data points. Based on the ideas of the Bayesian model averaging, these models are merged into a new weighted linear embedding model, in which individual outputs of the model ensemble are weighted according to the posterior model evidence. This model explicitly takes uncertainty into account and the overall performance is expected to be improved. Using numerical simulations, it is shown that the proposed weighted model achieves better state predictive accuracy as well as greater generalizability to different control applications compared to other Koopman operator-based models.

References

  • [1] A. Mauroy, I. Mezić, and Y. Susuki, The Koopman Operator in Systems and Control. Springer International Publishing, 2020.
  • [2] S. L. Brunton and J. N. Kutz, Data-Driven Science and Engineering: Machine Learning, Dynamical Systems, and Control. Cambridge University Press, 2019.
  • [3] M. Korda and I. Mezić, “Linear predictors for nonlinear dynamical systems: Koopman operator meets model predictive control,” Automatica, vol. 93, pp. 149–160, 2018.
  • [4] X. Zhang, W. Pan, R. Scattolini, S. Yu, and X. Xu, “Robust tube-based model predictive control with Koopman operators,” Automatica, vol. 137, p. 110114, 2022.
  • [5] M. Han, J. Euler-Rolle, and R. K. Katzschmann, “DeSKO: Stability-assured robust control with a deep stochastic Koopman operator,” in The Tenth International Conference on Learning Representations, ICLR, 2022.
  • [6] D. Uchida, A. Yamashita, and H. Asama, “Data-driven Koopman controller synthesis based on the extended 2\mathcal{H}_{2} norm characterization,” IEEE Control Systems Letters, vol. 5, no. 5, pp. 1795–1800, 2021.
  • [7] S. H. Son, A. Narasingam, and J. Sang-Il Kwon, “Handling plant-model mismatch in Koopman Lyapunov-based model predictive control via offset-free control framework,” arXiv e-prints, p. arXiv:2010.07239, 2020.
  • [8] F. Nüske, S. Peitz, F. Philipp, M. Schaller, and K. Worthmann, “Finite-data error bounds for Koopman-based prediction and control,” Journal of Nonlinear Science, vol. 33, no. 14, 2022.
  • [9] R. Strässer, M. Schaller, K. Worthmann, J. Berberich, and F. Allgöwer, “Koopman-based feedback design with stability guarantees,” arXiv e-prints, p. arXiv:2312.01441, 2023.
  • [10] D. Uchida and K. Duraisamy, “Control-aware learning of Koopman embedding models,” in 2023 American Control Conference (ACC), pp. 941–948, 2023.
  • [11] D. Uchida and K. Duraisamy, “Extracting Koopman Operators for Prediction and Control of Non-linear Dynamics Using Two-stage Learning and Oblique Projections,” arXiv e-prints, p. arXiv:2308.13051, 2023.
  • [12] O. Sagi and L. Rokach, “Ensemble learning: A survey,” WIREs Data Mining and Knowledge Discovery, vol. 8, no. 4, p. e1249, 2018.
  • [13] J. a. Mendes-Moreira, C. Soares, A. M. Jorge, and J. F. D. Sousa, “Ensemble approaches for regression: A survey,” ACM Comput. Surv., vol. 45, no. 1, 2012.
  • [14] T. M. Fragoso, W. Bertoli, and F. Louzada, “Bayesian model averaging: A systematic review and conceptual classification,” International Statistical Review, vol. 86, no. 1, pp. 1–28, 2018.
  • [15] M. Williams, I. Kevrekidis, and C. Rowley, “A data driven approximation of the Koopman operator: Extending dynamic mode decomposition,” Journal of Nonlinear Science, vol. 25, no. 6, pp. 1307–1346, 2015.
  • [16] D. Goswami and D. A. Paley, “Global bilinearization and controllability of control-affine nonlinear systems: A Koopman spectral approach,” in 2017 IEEE 56th Annual Conference on Decision and Control (CDC), pp. 6107–6112, 2017.
  • [17] D. Bruder, X. Fu, and R. Vasudevan, “Advantages of bilinear Koopman realizations for the modeling and control of systems with unknown dynamics,” IEEE Robotics and Automation Letters, vol. 6, no. 3, pp. 4369–4376, 2021.
  • [18] M. Haseli and J. Cortés, “Modeling Nonlinear Control Systems via Koopman Control Family: Universal Forms and Subspace Invariance Proximity,” arXiv e-prints, p. arXiv:2307.15368, 2023.
  • [19] S. Pan and K. Duraisamy, “Physics-informed probabilistic learning of linear embeddings of nonlinear dynamics with guaranteed stability,” SIAM Journal on Applied Dynamical Systems, vol. 19, no. 1, pp. 480–509, 2020.
  • [20] N. Takeishi, Y. Kawahara, and T. Yairi, “Learning Koopman invariant subspaces for dynamic mode decomposition,” Advances in Neural Information Processing Systems, vol. 30, pp. 1130–1140, 12 2017.
  • [21] Y. Han, W. Hao, and U. Vaidya, “Deep learning of Koopman representation for control,” in 2020 59th IEEE Conference on Decision and Control (CDC), pp. 1890–1895, 2020.
  • [22] A. E. Raftery, T. Gneiting, F. Balabdaoui, and M. Polakowski, “Using Bayesian model averaging to calibrate forecast ensembles,” Monthly Weather Review, vol. 133, no. 5, pp. 1155–1174, 2005.
  • [23] Q. Duan, N. K. Ajami, X. Gao, and S. Sorooshian, “Multi-model ensemble hydrologic prediction using Bayesian model averaging,” Advances in Water Resources, vol. 30, no. 5, pp. 1371–1386, 2007.
  • [24] G. Li and J. Shi, “Application of bayesian model averaging in modeling long-term wind speed distributions,” Renewable Energy, vol. 35, no. 6, pp. 1192–1202, 2010.
  • [25] Y. Yao, A. Vehtari, D. Simpson, and A. Gelman, “Using Stacking to Average Bayesian Predictive Distributions (with Discussion),” Bayesian Analysis, vol. 13, no. 3, pp. 917 – 1007, 2018.
  • [26] K. Barigou, P.-O. Goffard, S. Loisel, and Y. Salhi, “Bayesian model averaging for mortality forecasting using leave-future-out validation,” International Journal of Forecasting, vol. 39, no. 2, pp. 674–690, 2023.
  • [27] O. Abril-Pla, V. Andreani, C. Carroll, L. Dong, C. Fonnesbeck, M. Kochurov, R. Kumar, J. Lao, C. Luhmann, O. Martin, M. Osthege, R. Vieira, T. Wiecki, and R. Zinkov, “PyMC: A modern and comprehensive probabilistic programming framework in Python,” PeerJ Computer Science, vol. 9, p. e1516, 2023.