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

Neural Contraction Metrics for Robust Estimation and Control: A Convex Optimization Approach

Hiroyasu Tsukamoto, , and Soon-Jo Chung This work was in part funded by the Jet Propulsion Laboratory, California Institute of Technology and the Raytheon Company.The authors are with the Graduate Aerospace Laboratories, California Institute of Technology, Pasadena, CA, USA. E-mail: {htsukamoto, sjchung}@caltech.edu), Code: https://github.com/astrohiro/ncm
Abstract

This paper presents a new deep learning-based framework for robust nonlinear estimation and control using the concept of a Neural Contraction Metric (NCM). The NCM uses a deep long short-term memory recurrent neural network for a global approximation of an optimal contraction metric, the existence of which is a necessary and sufficient condition for exponential stability of nonlinear systems. The optimality stems from the fact that the contraction metrics sampled offline are the solutions of a convex optimization problem to minimize an upper bound of the steady-state Euclidean distance between perturbed and unperturbed system trajectories. We demonstrate how to exploit NCMs to design an online optimal estimator and controller for nonlinear systems with bounded disturbances utilizing their duality. The performance of our framework is illustrated through Lorenz oscillator state estimation and spacecraft optimal motion planning problems.

Index Terms:
Machine learning, Observers for nonlinear systems, Optimal control.

I Introduction

Provably stable and optimal state estimation and control algorithms for a class of nonlinear dynamical systems with external disturbances are essential to develop autonomous robotic explorers operating remotely on land, in water, and in deep space. In these next generation missions, these robots are supposed to intelligently perform complex tasks with their limited computational resources, which are not necessarily powerful enough to run optimization algorithms in real-time.

Our main contribution is to introduce a Neural Contraction Metric (NCM), a global representation of optimal contraction metrics sampled offline by using a deep Long Short-Term Memory Recurrent Neural Network (LSTM-RNN) (see Fig. 1), and thereby propose a new framework for provably stable and optimal online estimation and control of nonlinear systems with bounded disturbances, which only requires one function evaluation at each time step. A deep LSTM-RNN [1, 2] is a recurrent neural network with an improved memory structure proposed to circumvent gradient vanishing [3] and is a universal approximator of continuous curves [4]. Contrary to previous works, the convex optimization-based sampling methodology in our framework allows us to obtain a large enough dataset of the optimal contraction metric without assuming any hypothesis function space. These sampled metrics, the existence of which is a necessary and sufficient condition for exponential convergence [5], can be approximated with arbitrary accuracy due to the high representational power of the deep LSTM-RNN. We remark that this approach can be used with learned dynamics [6] as a nominal model is assumed to be given. Also, this is distinct from Lyapunov neural networks designed to estimate a largest safe region for deterministic systems [7, 8]: the NCM provides provably stable estimation and control policies, which have a duality in their differential dynamics and are optimal in terms of disturbance attenuation. The NCM construction is summarized as follows.

Refer to caption
Figure 1: Illustration of the NCM: M(x,t)M(x,t) denotes the optimal contraction metric; x(t)x(t) and xd(t)x_{d}(t) denote perturbed and unperturbed system trajectories; hih_{i} and cic_{i} denote the hidden states of the deep LSTM-RNN, respectively.

In the offline phase, we sample contraction metrics by solving an optimization problem with exponential stability constraints, the objective of which is to minimize an upper bound of the steady-state Euclidean distance between perturbed and unperturbed system trajectories. In this paper, we present a convex optimization problem equivalent to this problem, thereby exploiting the differential nature of contraction analysis that enables Linear Time-Varying (LTV) systems-type approaches to Lyapunov function construction. For the sake of practical use, the sampling methodology is reduced to a much simpler formulation than those of [9, 10, 11] derived for Itô stochastic nonlinear systems. These optimal contraction metrics are sampled using the computationally efficient numerical methods for convex programming [12, 13, 14] and then modeled by the deep LSTM-RNN as depicted in Fig. 1. In the online phase, contraction metrics at each time instant are computed by the NCM to obtain the optimal feedback estimation and control gain or a bounded error tube for robust motion planning [15, 16].

We illustrate how to design an optimal NCM-based estimator and controller for nonlinear systems with bounded disturbances, utilizing the estimation and control duality in differential dynamics analogous to the one of the Kalman filter and Linear Quadratic Regulator (LQR) in LTV systems. Their performance is demonstrated using Lorenz oscillator state estimation and spacecraft optimal motion planning problems.

Related Work

Contraction analysis, as well as Lyapunov theory, is one of the most powerful tools in analyzing the stability of nonlinear systems [5]. It studies the differential (virtual) dynamics for the sake of incremental stability by means of a contraction metric, the existence of which leads to a necessary and sufficient characterization of exponential stability of nonlinear systems. Finding an optimal contraction metric for general nonlinear systems is, however, almost as difficult as finding an optimal Lyapunov function.

Several numerical methods have been developed for finding contraction metrics in a given hypothesis function space. A natural application of this concept is to represent their candidate as a linear combination of some basis functions [17, 18, 19, 20]. In  [21, 22], a tractable framework to construct contraction metrics for dynamics with polynomial vector fields is proposed by relaxing the stability conditions to the sum of squares conditions. Although it is ideal to use a larger number of basis functions seeking for a more optimal solution, the downside of this approach is that the problem size grows exponentially with the number of variables and basis functions [23].

We could thus alternatively rely on numerical schemes for sampling data points of a Lyapunov function without assuming any hypothesis function space. This includes the state-dependent Riccati equation method [24, 25] and it is proposed in [9, 10, 11] that this framework can be improved to obtain an optimal contraction metric, which minimizes an upper bound of the steady-state mean squared tracking error for nonlinear stochastic systems. However, solving a nonlinear system of equations or an optimization problem at each time instant is not suitable for systems with limited online computational capacity. The NCM addresses this issue by approximating the sampled solutions by the LSTM-RNN.

II Preliminaries

We use the notation x\|x\| and A\|A\| for the Euclidean and induced 2-norm, and A0A\succ 0, A0A\succeq 0, A0A\prec 0, and A0A\preceq 0 for positive definite, positive semi-definite, negative definite, and negative semi-definite matrices, respectively. Also, sym(A)=A+AT\operatorname{sym}(A)=A+A^{T} and II denotes the identity matrix. We first introduce some preliminaries that will be used to construct an NCM.

II-A Contraction Analysis for Incremental Stability

Consider the following perturbed nonlinear system:

x˙(t)=f(x(t),t)+d(t)\displaystyle\dot{x}(t)=f(x(t),t)+d(t) (1)

where t0t\in\mathbb{R}_{\geq 0}, x:0nx:\mathbb{R}_{\geq 0}\to\mathbb{R}^{n}, f:n×0nf:\mathbb{R}^{n}\times\mathbb{R}_{\geq 0}\to\mathbb{R}^{n}, and d:0nd:\mathbb{R}_{\geq 0}\to\mathbb{R}^{n} with d¯=supt0d(t)<+\overline{d}=\sup_{t\geq 0}\|d(t)\|<+\infty.

Theorem 1

Let x1(t)x_{1}(t) and x2(t)x_{2}(t) be the solution of (1) with d(t)=0d(t)=0 and d(t)0d(t)\neq 0, respectively. Suppose there exist M(x,t)=Θ(x,t)TΘ(x,t)0M(x,t)=\Theta(x,t)^{T}\Theta(x,t)\succ 0, α>0\alpha>0, and 0<ω¯,ω¯<0<\underline{\omega},\overline{\omega}<\infty s.t.

M˙(x,t)+sym(M(x,t)f(x,t)x)2αM(x,t),x,t\displaystyle\dot{M}(x,t)+\operatorname{sym}{\left(M(x,t)\frac{\partial f(x,t)}{\partial x}\right)}\preceq-2\alpha M(x,t),~{}\forall x,t (2)
(1ω¯)IM(x,t)(1ω¯)I,x,t.\displaystyle\left(\frac{1}{\overline{\omega}}\right)I\preceq M(x,t)\preceq\left(\frac{1}{\underline{\omega}}\right)I,~{}\forall x,t. (3)

Then the smallest path integral is exponentially bounded, thereby yielding a bounded tube of states:

x1x2δxR(0)ω¯eαtd¯αω¯ω¯d¯ω¯αω¯\displaystyle\int^{x_{2}}_{x_{1}}\|\delta x\|-{R(0)}{\sqrt{\overline{\omega}}}e^{-\alpha t}\leq\frac{\overline{d}}{\alpha}\sqrt{\frac{\overline{\omega}}{\underline{\omega}}}\leq\frac{\overline{d}\overline{\omega}}{\alpha\underline{\omega}} (4)

where R(t)=x1x2Θ(x,t)δx(t),tR(t)=\int_{x_{1}}^{x_{2}}\|\Theta(x,t)\delta x(t)\|,\forall t.

Proof:

Differentiating R(t)R(t) yields R˙(t)+αR(t)Θ(x(t),t)d(t)\dot{R}(t)+\alpha R(t)\leq\|\Theta(x(t),t)d(t)\| (see [5]). Since we have Θ(x(t),t)d(t)d¯/ω¯\|\Theta(x(t),t)d(t)\|\leq\overline{d}/\sqrt{\underline{\omega}}, applying the comparison lemma [26] results in R(t)R(0)eαt+d¯/(αω¯)R(t)\leq R(0)e^{-\alpha t}+\overline{d}/(\alpha\sqrt{\underline{\omega}}). Rewriting this inequality using the relations ω¯R(t)x1x2δx\sqrt{\overline{\omega}}R(t)\geq\int^{x_{2}}_{x_{1}}\|\delta x\| and 1ω¯/ω¯ω¯/ω¯1\leq\sqrt{\overline{\omega}/\underline{\omega}}\leq\overline{\omega}/\underline{\omega} due to 0<ω¯ω¯0<\underline{\omega}\leq\overline{\omega} completes the proof. Input-to-state stability and finite-gain p\mathcal{L}_{p} stability follow from (4) (see [15]). ∎

II-B Deep LSTM-RNN

An LSTM-RNN is a neural network designed for processing sequential data with inputs {xi}i=0N\{x_{i}\}_{i=0}^{N} and outputs {yi}i=0N\{y_{i}\}_{i=0}^{N}, and defined as yi=Whyhi+byy_{i}=W_{hy}h_{i}+b_{y} where hi=ϕ(xi,hi1,ci1)h_{i}=\phi(x_{i},h_{i-1},c_{i-1}). The activation function ϕ\phi is given by the following relations: hi=oitanh(ci)h_{i}=o_{i}\tanh(c_{i}), oi=σ(Wxoxi+Whohi1+Wcoci+bo)o_{i}=\sigma(W_{xo}x_{i}+W_{ho}h_{i-1}+W_{co}c_{i}+b_{o}), ci=fici1+ιitanh(Wxcxi+Whchi1+bc)c_{i}=f_{i}c_{i-1}+\iota_{i}\tanh(W_{xc}x_{i}+W_{hc}h_{i-1}+b_{c}), fi=σ(Wxfxi+Whfhi1+Wcfci1+bf)f_{i}=\sigma(W_{xf}x_{i}+W_{hf}h_{i-1}+W_{cf}c_{i-1}+b_{f}), and ιi=σ(Wxixi+Whihi1+Wcici1+bi)\iota_{i}=\sigma(W_{xi}x_{i}+W_{hi}h_{i-1}+W_{ci}c_{i-1}+b_{i}), where σ\sigma is the logistic sigmoid function and WW and bb terms represent weight matrices and bias vectors to be optimized, respectively. The deep LSTM-RNN can be constructed by stacking multiple of these layers [1, 2].

Since contraction analysis for discrete-time systems leads to similar results [5, 11], we define the inputs xix_{i} as discretized states {xi=x(ti)}t=0N\{x_{i}=x(t_{i})\}_{t=0}^{N}, and the outputs yiy_{i} as non-zero components of the unique Cholesky decomposition of the optimal contraction metric, as will be discussed in Sec. III.

III Neural Contraction Metric (NCM)

This section presents an algorithm to obtain an NCM depicted in Fig. 1.

III-A Convex Optimization-based Sampling of Contraction Metrics (CV-STEM)

We derive one approach to sample contraction metrics by using the ConVex optimization-based Steady-state Tracking Error Minimization (CV-STEM) method [10, 11], which could handle the control design of Itô stochastic nonlinear systems. In this section, we propose its simpler formulation for nonlinear systems with bounded disturbances in order to be of practical use in engineering applications.

By Theorem 1, the problem to minimize an upper bound of the steady-state Euclidean distance between the trajectory x1(t)x_{1}(t) of the unperturbed system and x2(t)x_{2}(t) of the perturbed system (1) ((4) as tt\to\infty) can be formulated as follows:

JNL=minω¯>0,ω¯>0,W0d¯ω¯αω¯ s.t. (2) and (3)\displaystyle{J}_{NL}^{*}=\min_{\underline{\omega}>0,\overline{\omega}>0,W\succ 0}\frac{\overline{d}\overline{\omega}}{\alpha\underline{\omega}}\text{ {s}.{t}.{} }\text{(\ref{deterministic_contraction}) and (\ref{Mcon})} (5)

where W(x,t)=M(x,t)1W(x,t)=M(x,t)^{-1} is used as a decision variable instead of M(x,t)M(x,t). We assume that the contraction rate α\alpha and disturbance bound d¯\overline{d} are given in (5) (see Remark 1 on how to select α\alpha). We need the following lemma to convexify this nonlinear optimization problem.

Lemma 1

The inequalities (2) and (3) are equivalent to

W~˙(x,t)sym(f(x,t)xW~(x,t))2αW~(x,t),x,t\displaystyle\dot{\tilde{W}}(x,t)-\operatorname{sym}{\left(\frac{\partial f(x,t)}{\partial x}\tilde{W}(x,t)\right)}\succeq 2\alpha\tilde{W}(x,t),~{}\forall x,t (6)
IW~(x,t)χI,x,t\displaystyle I\preceq\tilde{W}(x,t)\preceq\chi I,~{}\forall x,t (7)

respectively, where χ=ω¯/ω¯\chi=\overline{\omega}/\underline{\omega}, W~=νW\tilde{W}=\nu W, and ν=1/ω¯\nu=1/\underline{\omega}.

Proof:

Since ν=1/ω¯>0\nu=1/\underline{\omega}>0 and W(x,t)0W(x,t)\succ 0, multiplying (2) by ν\nu and then by W(x,t)W(x,t) from both sides preserves matrix definiteness and the resultant inequalities are equivalent to the original ones [27, pp. 114]. These operations yield (6). Next, since M(x,t)0M(x,t)\succ 0, there exists a unique μ(x,t)0\mu(x,t)\succ 0 s.t. M=μ2M=\mu^{2}. Multiplying (3) by μ1\mu^{-1} from both sides gives ω¯IW(x,t)ω¯I\underline{\omega}I\preceq W(x,t)\preceq\overline{\omega}I as we have ω¯,ω¯>0\underline{\omega},\overline{\omega}>0 and (μ1)2=W(\mu^{-1})^{2}=W. We get (7) by multiplying this inequality by ν=1/ω¯\nu=1/\underline{\omega}. ∎

We are now ready to state and prove our main result on the convex optimization-based sampling.

Theorem 2

Consider the convex optimization problem:

JCV=minχ,W~0d¯χα s.t. (6) and (7)\displaystyle{J}_{CV}^{*}=\min_{\chi\in\mathbb{R},\tilde{W}\succ 0}\frac{\overline{d}\chi}{\alpha}\text{~{}~{}{s}.{t}.{} (\ref{deterministic_contraction_tilde}) and (\ref{W_tilde})} (8)

where χ\chi and W~\tilde{W} are defined in Lemma 1, and α>0\alpha>0 and d¯=supt0d(t)\overline{d}=\sup_{t\geq 0}\|d(t)\| are assumed to be given. Then JNL=JCV{J}_{NL}^{*}={J}_{CV}^{*}.

Proof:

By definition, we have d¯ω¯/(αω¯)=d¯χ/α{\overline{d}\overline{\omega}}/{(\alpha\underline{\omega})}={\overline{d}\chi}/{\alpha}. Since (2) and (3) are equivalent to (6) and (7) by Lemma 1, rewriting the objective in the original problem (5) using this equality completes the proof. ∎

Remark 1

Since (6) and (7) are independent of ν=1/ω¯\nu=1/\underline{\omega}, the choice of ν\nu does not affect the optimal value of the minimization problem in Theorem 2. In practice, as we have supx,tM(x,t)1/ω¯=ν\sup_{x,t}\|M(x,t)\|\leq 1/\underline{\omega}=\nu by (3), it can be used as a penalty to optimally adjust the induced 2-norm of estimation and control gains when the problem explicitly depends on ν\nu (see Sec. IV for details). Also, although α\alpha is fixed in Theorem 2, it can be found by a line search as will be demonstrated in Sec. V.

Remark 2

The problem (8) can be solved as a finite-dimensional problem by using backward difference approximation, W~˙(x(ti),ti)(W~(x(ti),ti)W~(x(ti1),ti1))/Δti\dot{\tilde{W}}(x(t_{i}),t_{i})\simeq{({\tilde{W}}(x(t_{i}),t_{i})-{\tilde{W}}(x(t_{i-1}),t_{i-1}))}/{\Delta t_{i}}, where Δt=titi1,i\Delta t=t_{i}-t_{i-1},\forall i with ΔtΔt2>0\Delta t\gg\Delta t^{2}>0, and by discretizing it along a pre-computed system trajectory {x(ti)}i=0N\{x(t_{i})\}_{i=0}^{N}.

III-B Deep LSTM-RNN Training

Instead of directly using sequential data of optimal contraction metrics {M(x(ti),ti)}i=0N\{M(x(t_{i}),t_{i})\}^{N}_{i=0} for neural network training, the positive definiteness of M(x,t)M(x,t) is utilized to reduce the dimension of the target output {yi}i=0N\{y_{i}\}_{i=0}^{N} defined in Sec. II.

Lemma 2

A matrix A0A\succ 0 has a unique Cholesky decomposition, i.e., there exists a unique upper triangular matrix Un×nU\in\mathbb{R}^{n\times n} with strictly positive diagonal entries s.t. A=UTUA=U^{T}U.

Proof:

See [28, pp. 441]. ∎

As a result of Lemma 2, we can select Θ(x,t)\Theta(x,t) defined in Theorem 1 as the unique Cholesky decomposition of M(x,t)M(x,t) and train the deep LSTM-RNN using only the non-zero entries of the unique upper triangular matrices {Θ(x(ti),ti)}i=0N\{\Theta(x(t_{i}),t_{i})\}^{N}_{i=0}. We denote these nonzero entries as θ(x,t)12n(n+1)\theta(x,t)\in\mathbb{R}^{\frac{1}{2}n(n+1)}. As a result, the dimension of the target data θ(x,t)\theta(x,t) is reduced by n(n1)/2n(n-1)/2 without losing any information on M(x,t)M(x,t).

The pseudocode to obtain an NCM depicted in Fig. 1 is presented in Algorithm 1. The deep LSTM-RNN in Sec. II is trained with the sequential state data {x(ti)}i=0N\{x(t_{i})\}_{i=0}^{N} and the target data {θ(x(ti),ti)}i=0N\{\theta(x(t_{i}),t_{i})\}^{N}_{i=0} using Stochastic Gradient Descent (SGD). We note these pairs will be sampled for multiple trajectories to increase sample size and to avoid overfitting.

Inputs : Initial and terminal states {xs(t0),xs(tN)}s=1S\{x_{s}(t_{0}),x_{s}(t_{N})\}^{S}_{s=1}
Outputs : NCM and steady-state bound JCVJ_{CV}^{*} in (8)
A. Sampling of Optimal Contraction Metrics
for s1s\leftarrow 1 to SS do
       Generate a trajectory {xs(ti)}i=0N\{x_{s}(t_{i})\}^{N}_{i=0} using xs(t0)x_{s}(t_{0}) (could use xs(tN)x_{s}(t_{N}) for motion planning problems)
       for αAlinesearch\alpha\in A_{\mathrm{linesearch}} do
             Find JCV(α,xs)J_{CV}^{*}(\alpha,x_{s}) and {θ(xs(ti),ti)}i=0N\{\theta(x_{s}(t_{i}),t_{i})\}^{N}_{i=0} by Th. 2
      Find α(xs)=argminαAlinesearchJCV(α,xs)\alpha^{*}(x_{s})=\text{arg}\min_{\alpha\in A_{\mathrm{linesearch}}}J_{CV}^{*}(\alpha,x_{s})
       Save {θ(xs(ti),ti)}i=0N\{\theta(x_{s}(t_{i}),t_{i})\}^{N}_{i=0} for α=α(xs)\alpha=\alpha^{*}(x_{s})
Obtain JCV=maxsJCV(α(xs),xs)J_{CV}^{*}=\max_{s}J_{CV}^{*}(\alpha^{*}(x_{s}),x_{s}) B. Deep LSTM-RNN Training
Split data into a train set 𝒮train\mathcal{S}_{\mathrm{train}} and test set 𝒮test\mathcal{S}_{\mathrm{test}}
for epoch1\mathrm{epoch}\leftarrow 1 to NepochsN_{\mathrm{epochs}} do
       for s𝒮trains\in\mathcal{S}_{\mathrm{train}} do
            Train the deep LSTM-RNN with {xs(ti)}i=0N\{x_{s}(t_{i})\}^{N}_{i=0}, {θ(xs(ti),ti)}i=0N\{\theta(x_{s}(t_{i}),t_{i})\}^{N}_{i=0} using SGD
      Compute the test error for data in 𝒮test\mathcal{S}_{\mathrm{test}}
       if testerror<ϵ\mathrm{test~{}error}<\epsilon then
             break
      
Algorithm 1 NCM Algorithm

IV NCM-Based Optimal Estimation and Control

This section delineates how to construct an NCM offline and utilize it online for state estimation and feedback control.

IV-A Problem Statement

We apply an NCM to the state estimation problem for the following nonlinear system with bounded disturbances:

x˙=f(x,t)+B(x,t)d1(t),y(t)=h(x,t)+G(x,t)d2(t)\displaystyle\dot{x}=f(x,t)+B(x,t)d_{1}(t),~{}y(t)=h(x,t)+G(x,t)d_{2}(t) (9)

where d1:0k1d_{1}:\mathbb{R}_{\geq 0}\to\mathbb{R}^{k_{1}}, B:n×0n×k1B:\mathbb{R}^{n}\times\mathbb{R}_{\geq 0}\to\mathbb{R}^{n\times k_{1}}, y:0my:\mathbb{R}_{\geq 0}\to\mathbb{R}^{m}, d2:0k2d_{2}:\mathbb{R}_{\geq 0}\to\mathbb{R}^{k_{2}}, h:n×0mh:\mathbb{R}^{n}\times\mathbb{R}_{\geq 0}\to\mathbb{R}^{m}, and G:n×0m×k2G:\mathbb{R}^{n}\times\mathbb{R}_{\geq 0}\to\mathbb{R}^{m\times k_{2}} with d¯1=suptd1(t)<+\overline{d}_{1}=\sup_{t}\|d_{1}(t)\|<+\infty and d¯2=suptd2(t)<+\overline{d}_{2}=\sup_{t}\|d_{2}(t)\|<+\infty. Let W=M(x^,t)10W=M(\hat{x},t)^{-1}\succ 0, A(x,t)=(f/x)A(x,t)=(\partial f/\partial x), and C(x,t)=(h/x)C(x,t)=(\partial h/\partial x). We design an estimator as

x^˙=f(x^,t)+M(x^,t)C(x^,t)T(yh(x^,t))\displaystyle\dot{\hat{x}}=f(\hat{x},t)+M(\hat{x},t)C(\hat{x},t)^{T}(y-h(\hat{x},t)) (10)
W˙+WA(x^,t)+A(x^,t)TW2C(x^,t)TC(x^,t)2αW\displaystyle\dot{W}+WA(\hat{x},t)+A(\hat{x},t)^{T}W-2C(\hat{x},t)^{T}C(\hat{x},t)\preceq-2\alpha W (11)

where α>0\alpha>0. The virtual system of (9) and (10) is given as

q˙=\displaystyle\dot{q}= f(q,t)+M(x^,t)C(x^,t)T(h(x,t)h(q,t))+de(q,t)\displaystyle f(q,t)+M(\hat{x},t)C(\hat{x},t)^{T}(h(x,t)-h(q,t))+d_{e}(q,t) (12)

where de(q,t)d_{e}(q,t) is defined as de(x,t)=B(x,t)d1(t)d_{e}(x,t)=B(x,t)d_{1}(t) and de(x^,t)=M(x^,t)C(x^,t)TG(x,t)d2(t)d_{e}(\hat{x},t)=M(\hat{x},t)C(\hat{x},t)^{T}G(x,t)d_{2}(t). Note that (12) has q=xq=x and q=x^q=\hat{x} as its particular solutions. The differential dynamics of (12) with de=0d_{e}=0 is given as

δq˙=\displaystyle\delta\dot{q}= (A(q,t)M(x^,t)C(x^,t)TC(q,t))δq.\displaystyle(A(q,t)-M(\hat{x},t)C(\hat{x},t)^{T}C(q,t))\delta q. (13)

IV-B Nonlinear Stability Analysis

We have the following lemma for deriving a condition to guarantee the local contraction of (12) in Theorem 3.

Lemma 3

If (11) holds for t0t\geq 0, there exists r(t)>0r(t)>0 s.t.

2γW+W˙+sym(WA(q,t))sym(C(x^,t)TC(q,t))0\displaystyle 2\gamma W+\dot{W}+\operatorname{sym}{}(WA(q,t))-\operatorname{sym}(C(\hat{x},t)^{T}C(q,t))\preceq 0 (14)

for all q(t)q(t) with q(t)x^(t)r(t)\|q(t)-\hat{x}(t)\|\leq r(t), where 0<γ<α0<\gamma<\alpha.

Proof:

See Lemma 2 of [29] or Theorem 1 of [9]. ∎

The following theorem along with this lemma guarantees the exponential stability of the estimator (10).

Theorem 3

Suppose that there exist positive constants ω¯\underline{\omega}, ω¯\overline{\omega}, b¯\overline{b}, c¯\bar{c}, g¯\bar{g}, and ρ\rho s.t. ω¯IW(x^,t)ω¯I\underline{\omega}I\preceq W(\hat{x},t)\preceq\overline{\omega}I, B(x,t)b¯\|B(x,t)\|\leq\overline{b}, C(x^,t)c¯\|C(\hat{x},t)\|\leq\bar{c}, G(x,t)g¯\|G(x,t)\|\leq\bar{g}, and r(t)ρ,x^,x,tr(t)\geq\rho,~{}\forall\hat{x},x,t, where r(t)r(t) is defined in Lemma 3. If (11) holds and Re(0)+D¯e/γω¯ρR_{e}(0)+\overline{D}_{e}/{\gamma}\leq\sqrt{\underline{\omega}}\rho, where Re(t)=x^xΘ(x^,t)δq(t)R_{e}(t)=\int_{\hat{x}}^{x}\|\Theta(\hat{x},t)\delta q(t)\| with W=ΘTΘW=\Theta^{T}\Theta and D¯e=d¯1b¯ω¯+d¯2c¯g¯/ω¯\overline{D}_{e}=\overline{d}_{1}\overline{b}\sqrt{\overline{\omega}}+{\overline{d}_{2}\bar{c}\bar{g}}/{\sqrt{\underline{\omega}}}, then the distance between the trajectory of (9) and (10) is exponentially bounded as follows:

x^xδqRe(0)ω¯eγt+d¯1b¯γχ+d¯2c¯g¯γν\displaystyle\int_{\hat{x}}^{x}\|\delta q\|\leq\frac{R_{e}(0)}{\sqrt{\underline{\omega}}}e^{-\gamma t}+\frac{\overline{d}_{1}\overline{b}}{\gamma}\chi+\frac{{\overline{d}_{2}\bar{c}\bar{g}}}{\gamma}\nu (15)

where χ=ω¯/ω¯\chi={\overline{\omega}}/{\underline{\omega}}, ν=1/ω¯\nu={1}/{\underline{\omega}}, and 0<γ<α0<\gamma<\alpha.

Proof:

Using (13), we have d(Θδq2)/dt=δqT(W˙+sym(WA(q,t))sym(C(x^,t)TC(q,t)))δqd(\|\Theta\delta q\|^{2})/dt=\delta q^{T}(\dot{W}+\operatorname{sym}(WA(q,t))-\operatorname{sym}(C(\hat{x},t)^{T}C(q,t)))\delta q when de=0d_{e}=0. This along with (14) gives R˙e(t)γRe(t)\dot{R}_{e}(t)\leq-{\gamma}R_{e}(t) in the region where Lemma 3 holds. Thus, using the bound Θ(x^(t),t)de(q,t)D¯e\|\Theta(\hat{x}(t),t)d_{e}(q,t)\|\leq\overline{D}_{e}, we have ω¯x^xδqRe(0)eγt+D¯e/γ\sqrt{\underline{\omega}}\int_{\hat{x}}^{x}\|\delta q\|\leq{R_{e}(0)}e^{-\gamma t}+{\overline{D}_{e}}/\gamma by the same proof as for Theorem 1. Rewriting this with χ\chi, ν\nu, and 1χχ1\leq\sqrt{\chi}\leq\chi yields (15). This also implies that ω¯xx^Re(0)+D¯e/γ,t\sqrt{\underline{\omega}}\|x-\hat{x}\|\leq R_{e}(0)+\overline{D}_{e}/{\gamma},~{}\forall t. Hence, the sufficient condition for qx^\|q-\hat{x}\| in Lemma 3 reduces to the one required in this theorem. ∎

IV-C Convex Optimization-based Sampling (CV-STEM)

We have the following proposition to sample optimal contraction metrics for the NCM-based state estimation.

Proposition 1

M(x^,t)M(\hat{x},t) that minimizes an upper bound of limtx^xδq\lim_{t\to\infty}\int_{\hat{x}}^{x}\|\delta q\| is found by the convex optimization problem:

JCVe=minν>0,χ,W~0d¯1b¯γχ+d¯2c¯g¯γν\displaystyle{J}_{CVe}^{*}=\min_{\nu>0,\chi\in\mathbb{R},\tilde{W}\succ 0}\frac{\overline{d}_{1}\overline{b}}{\gamma}\chi+\frac{{\overline{d}_{2}\bar{c}\bar{g}}}{\gamma}\nu (16)
s.t. W~˙+W~A+ATW~2νCTC2αW~\dot{\tilde{W}}+\tilde{W}A+A^{T}\tilde{W}-2\nu C^{T}C\preceq-{2\alpha}\tilde{W} and IW~χII\preceq\tilde{W}\preceq\chi I

where χ=ω¯/ω¯\chi={\overline{\omega}}/{\underline{\omega}}, ν=1/ω¯\nu={1}/{\underline{\omega}}, W~=νW\tilde{W}=\nu W, and 0<γ<α0<\gamma<\alpha. The arguments of A(x^,t)A(\hat{x},t), C(x^,t)C(\hat{x},t), and W~(x^,t)\tilde{W}(\hat{x},t) are omitted for notational simplicity.

Proof:

Multiplying (11) and ω¯IW(x^,t)ω¯I,x^,t\underline{\omega}I\preceq W(\hat{x},t)\preceq\overline{\omega}I,~{}\forall\hat{x},t by ν\nu yields the constraints of (16). Then Theorem 2 with the objective function given in (15) of Theorem 3 as tt\to\infty yields (16). ∎

We have an analogous result for state feedback control.

Corollary 1

Consider the following system and a state feedback controller u(t)u(t) with the bounded disturbance d(t)d(t):

x˙=f(x,t)+B1(x,t)u+B2(x,t)d(t)\displaystyle\dot{x}=f(x,t)+B_{1}(x,t)u+B_{2}(x,t)d(t) (17)
W˙A(x,t)WWA(x,t)T+2B1(x,t)B1(x,t)T2αW\displaystyle\dot{W}-A(x,t)W-WA(x,t)^{T}+2B_{1}(x,t)B_{1}(x,t)^{T}\succeq 2\alpha W (18)

where u=B1(x,t)TM(x,t)xu=-B_{1}(x,t)^{T}M(x,t)x, B1:n×0n×mB_{1}:\mathbb{R}^{n}\times\mathbb{R}_{\geq 0}\to\mathbb{R}^{n\times m}, B2:n×0n×kB_{2}:\mathbb{R}^{n}\times\mathbb{R}_{\geq 0}\to\mathbb{R}^{n\times k}, W=M10W=M^{-1}\succ 0, α>0\alpha>0, and AA is a matrix defined as A(x,t)x=f(x,t)A(x,t)x=f(x,t), assuming that f(x,t)=0f(x,t)=0 at x=0x=0 [24, 25]. Suppose there exist positive constants ω¯\underline{\omega}, ω¯\overline{\omega}, and b¯2\overline{b}_{2} s.t. ω¯IW(x,t)ω¯I\underline{\omega}I\preceq W(x,t)\preceq\overline{\omega}I and B2(x,t)b¯2,x,t\|B_{2}(x,t)\|\leq\overline{b}_{2},~{}\forall x,t. Then M(x,t)M(x,t) that minimizes an upper bound of limt0xδq\lim_{t\to\infty}\int_{0}^{x}\|\delta q\| can be found by the following convex optimization problem:

JCVc=minν>0,χ,W~0b¯2d¯αχ+λν\displaystyle{J}_{CVc}^{*}=\min_{\nu>0,\chi\in\mathbb{R},\tilde{W}\succ 0}\frac{\overline{b}_{2}\overline{d}}{\alpha}\chi+\lambda\nu (19)
s.t. W~˙+AW~+W~AT2νB1B1T2αW~-\dot{\tilde{W}}+A\tilde{W}+\tilde{W}A^{T}-2\nu B_{1}B_{1}^{T}\preceq-{2\alpha}\tilde{W} and IW~χII\preceq\tilde{W}\preceq\chi I

where χ=ω¯/ω¯\chi={\overline{\omega}}/{\underline{\omega}}, ν=1/ω¯\nu={1}/{\underline{\omega}}, W~=νW\tilde{W}=\nu W, and λ>0\lambda>0 is a user-defined constant. The arguments of A(x,t)A(x,t), B1(x,t)B_{1}(x,t), and W~(x,t)\tilde{W}(x,t) are omitted for notational simplicity.

Proof:

The system with q=x,0q=x,0 as its particular solutions is given by q˙=(A(x,t)B1(x,t)B1(x,t)TM(x,t))q+dc(q,t)\dot{q}=(A(x,t)-B_{1}(x,t)B_{1}(x,t)^{T}M(x,t))q+d_{c}(q,t), where dc(x,t)=B2(x,t)d(t)d_{c}(x,t)=B_{2}(x,t)d(t) and dc(0,t)=0d_{c}(0,t)=0. Since we have dc(q,t)b¯2d¯\|d_{c}(q,t)\|\leq\overline{b}_{2}\overline{d} and the differential dynamics is

δq˙=(A(x,t)B1(x,t)B1(x,t)TM(x,t))δq\displaystyle\delta\dot{q}=(A(x,t)-B_{1}(x,t)B_{1}(x,t)^{T}M(x,t))\delta q (20)

when dc=0d_{c}=0, we get limt0xδqb¯2d¯χ/α\lim_{t\to\infty}\int_{0}^{x}\|\delta q\|\leq\overline{b}_{2}\overline{d}\chi/\alpha by the same proof as for Theorem 3 with (13) replaced by (20), (14) by (18), and Re(t)R_{e}(t) by Rc(t)=0xΘ(x,t)δq(t)R_{c}(t)=\int_{0}^{x}\|\Theta(x,t)\delta q(t)\|, where M=ΘTΘM=\Theta^{T}\Theta. (19) then follows as in the proof of Proposition 1, where λ0\lambda\geq 0 is for penalizing excessively large control inputs through νsupx,tM(x,t)\nu\geq\sup_{x,t}\|M(x,t)\| (see Remark 1). ∎

IV-D NCM Construction and Interpretation

Algorithm 1 along with Proposition 1 and Corollary 1 returns NCMs to compute x^(t)\hat{x}(t) of (10) and u(t)u(t) of (17) for state estimation and control in real-time. They also provide the bounded error tube (see Theorem 1, [15, 16]) for robust motion planning problems as will be seen in Sec. V.

The similarity of Corollary 1 to Proposition 1 stems from the estimation and control duality due to the differential nature of contraction analysis as is evident from (13) and (20). Analogously to the discussion of the Kalman filter and LQR duality in LTV systems, this leads to two different interpretations on the weight of ν\nu (d¯2c¯g¯/γ\overline{d}_{2}\bar{c}\bar{g}/\gamma in (16) and λ\lambda in (19)). As discussed in Remark 1, one way is to see it as a penalty on the induced 2-norm of feedback gains. Since d¯2=0\overline{d}_{2}=0 in (16) means no noise acts on y(t)y(t), it can also be viewed as an indicator of how much we trust the measurement y(t)y(t): the larger the weight of ν\nu, the less confident we are in y(t)y(t). These agree with our intuition as smaller feedback gains are suitable for systems with larger measurement uncertainty.

V Simulation

The NCM framework is demonstrated using Lorentz oscillator state estimation and spacecraft motion planning and control problems. CVXPY [13] with the MOSEK solver [14] is used to solve convex optimization problems. A Python implementation is available at https://github.com/astrohiro/ncm.

V-A State Estimation of Lorenz Oscillator

We first consider state estimation of the Lorentz oscillator with bounded disturbances described as x˙=f(x)+d1(t)\dot{x}=f(x)+d_{1}(t) and y=Cx+d2(t)y=Cx+d_{2}(t), where f(x)=[σ(x2x1),x1(ρx3)x2,x1x2βx3]Tf(x)=[\sigma(x_{2}-x_{1}),x_{1}(\rho-x_{3})-x_{2},x_{1}x_{2}-\beta x_{3}]^{T}, x=[x1,x2,x3]Tx=[x_{1},x_{2},x_{3}]^{T}, σ=10\sigma=10, β=8/3\beta=8/3, ρ=28\rho=28, C=[100]C=[1~{}0~{}0], suptd1(t)=3\sup_{t}\|d_{1}(t)\|=\sqrt{3}, and suptd2(t)=1\sup_{t}\|d_{2}(t)\|=1. We use dt=0.1dt=0.1 for integration, with one measurement yy per dtdt.

V-A1 Sampling of Optimal Contraction Metrics

Using Proposition 1, we sample the optimal contraction metric along 100100 trajectories with uniformly distributed initial conditions (10xi10,i=1,2,3-10\leq x_{i}\leq 10,~{}i=1,2,3). Figure 2 plots JCVe{J}_{CVe}^{*} in (16) for 100100 different trajectories and the optimal α\alpha is found to be α=3.4970\alpha=3.4970. The optimal estimator parameters averaged over 100100 trajectories for α=3.4970\alpha=3.4970 are summarized in Table I.

Refer to caption
Figure 2: Upper bound of steady-state errors as a function of α\alpha: each curve with a different color corresponds to a trajectory with a different initial condition.
TABLE I: NCM Estimator Parameters for α=3.4970\alpha=3.4970 with JCVe{J}_{CVe}^{*} and MSE Averaged over 100100 Trajectories
parameters ν\nu χ\chi JCVe{J}_{CVe}^{*} MSE
values 1.3375×1021.3375\times 10^{2} 9.29779.2977 42.85242.852 1.0190×1031.0190\times 10^{-3}

V-A2 Deep LSTM-RNN Training

A deep LSTM-RNN is trained using Algorithm 1 and Proposition 1 with the sequential data {{(xs(ti),θs(x(ti))}i=0N}s=1S\{\{(x_{s}(t_{i}),\theta_{s}(x(t_{i}))\}_{i=0}^{N}\}_{s=1}^{S} sampled over the 100100 different trajectories (S=100S=100). Note that θs(x(ti))\theta_{s}(x(t_{i})) are standardized and normalized to make the SGD-based learning process stable. Figure 3 shows the test loss of the LSTM-RNN models with different number of layers and hidden units. We can see that the models with more than 22 layers overfit and those with less than 3232 hidden units underfit to the training samples. Thus, the number of layers and hidden units are selected as 22 and 6464, respectively. The resultant MSE of the trained LSTM-RNN is shown in Table I.

Refer to caption
Figure 3: LSTM-RNN test loss with 2 layers (left) and 32 hidden units (right).

V-A3 State Estimation with an NCM

The estimation problem is solved using the NCM, sampling-based CV-STEM [10, 11], and Extended Kalman Filter (EKF) with suptd1(t)=203\sup_{t}\|d_{1}(t)\|=20\sqrt{3}, and suptd2(t)=20\sup_{t}\|d_{2}(t)\|=20. We use x(0)=[1.0,2.0,3.0]Tx(0)=[-1.0,2.0,3.0]^{T} and x^(0)=[150.1,1.5,6]T\hat{x}(0)=[150.1,-1.5,-6]^{T} for the actual and estimated initial conditions, respectively. The EKF weight matrices are selected as R=20IR=20I and Q=10IQ=10I.

Figure 4 shows the smoothed estimation error x(t)x^(t)\|x(t)-\hat{x}(t)\| using a 1515-point moving average filter. The errors of the NCM and CV-STEM estimators are below the optimal upper bound while the EKF has a larger error compared to the other two. As expected from the small MSE of Table I, the estimation error of the NCM estimator shows a trend similar to that of the sampling-based CV-STEM estimator without losing its estimation performance.

Refer to caption
Figure 4: Lorentz oscillator state estimation error smoothed using a 1515-point moving average filter.

V-B Spacecraft Optimal Motion Planning

We consider an optimal motion planning problem of the planar spacecraft dynamical system, given as x˙=Ax+B(x)u+d(t)\dot{x}=Ax+B(x)u+d(t), where u8u\in\mathbb{R}^{8}, suptd(t)=0.15\sup_{t}\|d(t)\|=0.15, and x=[px,py,ϕ,p˙x,p˙y,ϕ˙]Tx=[p_{x},p_{y},\phi,\dot{p}_{x},\dot{p}_{y},\dot{\phi}]^{T} with pxp_{x}, pyp_{y}, and ϕ\phi being the horizontal coordinate, vertical coordinate, and yaw angle of the spacecraft, respectively. The constant matrix AA and the state-dependent actuation matrix B(x)B(x) are defined in [30]. All the parameters of the spacecraft are normalized to 11.

V-B1 Problem Formulation

In the planar field, we have 66 circular obstacles with radius 33 located at (px,py)=(0,11)(p_{x},p_{y})=(0,11), (5,3)(5,3), (8,11)(8,11), (13,3)(13,3), (16,11)(16,11), and (21,3)(21,3). The goal of the motion planning problem is to find an optimal trajectory that avoids these obstacles and minimize 050u(t)2𝑑t\int_{0}^{50}\|u(t)\|^{2}dt subject to input constraints 0ui(t)1,i,t0\leq u_{i}(t)\leq 1,\forall i,\forall t and the dynamics constraints. The initial and terminal condition are selected as x(0)=[0,0,π/12,0,0,0]Tx(0)=[0,0,\pi/12,0,0,0]^{T} and x(tN)=[20,18,0,0,0,0]Tx(t_{N})=[20,18,0,0,0,0]^{T}. Following the same procedure described in the state estimation problem, the optimal control parameters and the MSE of the LSTM-RNN trained using Algorithm 1 with Corollary 1 are determined as shown in Table II.

TABLE II: NCM Control Parameters for α=0.58\alpha=0.58 with JCVc{J}_{CVc}^{*} and MSE Averaged over 100100 Trajectories
parameters ν\nu χ\chi JCVc{J}_{CVc}^{*} MSE
values 6.2090×1026.2090\times 10^{2} 3.01163.0116 8.95248.9524 3.4675×1043.4675\times 10^{-4}

V-B2 Motion Planning with an NCM

Given an NCM, we can solve a robust motion planning problem, where the state constraint is now described by the bounded error tube (see Theorem 1) with radius Rtube=d¯(χ/α)=0.4488R_{\mathrm{tube}}=\overline{d}(\sqrt{\chi}/\alpha)=0.4488. Figure 5 shows the spacecraft motion (px,py)(p_{x},p_{y}) on a planar field, computed using the NCM, sampling-based CV-STEM [10, 11], and baseline LQR control with Q=2.4IQ=2.4I and R=IR=I which does not account for the disturbance.

Refer to caption
Figure 5: Spacecraft motion (px,py)(p_{x},p_{y}) on a planar field.

As summarized in Table III, input constraints 0ui(t)1,i,t0\leq u_{i}(t)\leq 1,\forall i,\forall t are satisfied and the three controllers use a similar amount of control effort. All the controllers except the LQR keep their trajectories within the tube avoiding collision with the circular obstacles, even under the presence of disturbances as depicted in Fig. 5. Also, the NCM controller predicts the computationally-expensive CV-STEM controller with the small MSE as given in the last column of Table II.

TABLE III: Control Performances for Spacecraft Motion Planning Problem
050u(t)2𝑑t\int_{0}^{50}\|u(t)\|^{2}dt mini(inftui(t))\min_{i}(\inf_{t}u_{i}(t)) maxi(suptui(t))\max_{i}(\sup_{t}u_{i}(t))
NCM 4.8959×104.8959\times 10 1.2728×108-1.2728\times 10^{-8} 1.00001.0000
CV-STEM 4.8019×104.8019\times 10 4.1575×108-4.1575\times 10^{-8} 1.00001.0000
LQR 4.9260×104.9260\times 10 0.00000.0000 1.00001.0000

VI Conclusion

In this paper, we present a Neural Contraction Metric (NCM), a deep learning-based global approximation of an optimal contraction metric for online nonlinear estimation and control. The novelty of the NCM approach lies in that: 1) data points of the optimal contraction metric are sampled offline by solving a convex optimization problem, which minimizes an upper bound of the steady-state Euclidean distance between the perturbed and unperturbed trajectories without assuming any hypothesis function space, and 2) the deep LSTM-RNN is constructed to model the sampled metrics with arbitrary accuracy. The superiority of its performance is validated through numerical simulations on state estimation and optimal motion planning problems.

References