最优控制问题(Optimal Control Problem)的数值求解方法主要有间接法和直接法。间接法是根据极大值原理或者动态规划得到最优性的一阶必要条件,然后使用数值求解得到最优控制和轨迹。
间接法的优点是解的精度高,满足最优性的一阶必要条件。 缺点是收敛域很小,对初值估计要求高,且难以估计协态变量初值。而且需要求解状态方程和协态方程,增加了计算量, 算法鲁棒性较差。 对于复杂的系统, 推导一阶必要条件特别困难。
直接法是将原最优控制问题转化为非线性规划问题,然后采用非线性规划算法求解。由于不需要推导一阶必要条件,所以应用方便。直接法根据离散化变量的不同,主要可以分为只离散控制变量、只离散状态变量和同时离散控制变量和状态变量三类。第一类方法由于需要进行数值积分,计算量较大,这种算法的代表是打靶法和多段打靶法;第二类方法是微分包含法,它只离散状态变量,将控制约束转化为状态约束,可以降低变量个数,但是对于非线性比较复杂的状态方程,难以求出控制变量关于状态的显式表达式;第三类方法同时将状态变量和控制变量进行离散化,微分方程转化为代数约束条件, 这一类算法收敛速度较快,并且收敛半径大。[1]
配点法也是一种直接法,其包括欧拉法、Runge-Kutta法、Hermit-Simpson法和伪谱法。其中伪谱法包括Chebyshev伪谱法、Legendre伪谱法、Gauss伪谱法和Radau伪谱法。伪谱法因其计算效率和计算精度上的优势、良好的收敛性以及较低的初值敏感度在最优控制领域求解算法中倍受关注[2]。
Pseudospectral methods are a class of direct collocation where the optimal control problem is transcribed to a nonlinear programming problem (NLP) by parameterizing the state and control using global polynomials and collocating the differential-algebraic equations using nodes obtained from a Gaussian quadrature.[3]
1. 数学基本理论
1.1 Lagrange Polynomials
假设给定 N + 1 N+1 N+1个数据点 ( x 0 , y 0 ) , ( x 1 , y 1 ) , ⋯ , ( x N , y N ) (x_0, y_0),(x_1, y_1),\cdots,(x_N, y_N) (x0,y0),(x1,y1),⋯,(xN,yN),可以得到一个显示的,阶次为 N N N插值多项式,称为Lagrange Polynomials(拉格朗日多项式)。
P ( x ) = ∑ i = 0 N y i L i ( x i ) (1-1) P(x) = \sum_{i=0}^{N} y_i L_i(x_i) \tag{1-1} P(x)=i=0∑NyiLi(xi)(1-1)
其中, L i ( x ) L_i(x) Li(x)是Lagrange Polynomial的基函数。
L i ( x ) = ∏ j = 0 j ≠ i N x − x j x i − x j , i = 0 , 1 , 2 , ⋯ , N (1-2) L_i(x) = \prod_{j=0 \\ j \neq i}^{N} {\frac{x - x_j}{x_i - x_j}}, i = 0, 1, 2, \cdots, N \tag{1-2} Li(x)=j=0j=i∏Nxi−xjx−xj,i=0,1,2,⋯,N(1-2)
1.2 Legendre Polynomials
Legendre Polynomials(勒让德多项式)是勒让德微分方程的解,勒让德多项式 P n ( x ) P_n(x) Pn(x)是 n n n阶多项式,可用罗德里格公式表示为:
P n ( x ) = 1 2 n n ! d n d x n [ ( x 2 − 1 ) n ] (1-3) P_n(x) = \frac{1}{2^n n!} \frac{d^n}{dx^n} [(x^2 - 1)^n] \tag{1-3} Pn(x)=2nn!1dxndn[(x2−1)n](1-3)
相邻三个Legendre Polynomials具有递推关系:
( n + 1 ) P n + 1 = ( 2 n + 1 ) x P n − n P n − 1 (1-4) (n+1)P_{n+1} = (2n+1)xP_n - n P_{n-1} \tag{1-4} (n+1)Pn+1=(2n+1)xPn−nPn−1(1-4)
Legendre Polynomials的微分递推关系可以用来计算Legendre Polynomials积分:
( 2 n + 1 ) P n = d d x [ P n + 1 − P n − 1 ] (1-5) (2n + 1) P_n = \frac{d}{dx}[P_{n+1} - P_{n-1}] \tag{1-5} (2n+1)Pn=dxd[Pn+1−Pn−1](1-5)
1.3 Collocation Points
有三种常用的配点:Legendre-Gauss(LG),Legendre-Gauss-Radau(LGR)和Legendre-Gauss-Lobatto(LGL) 。这些配点是Legendre Polynomials的根或者是Legendre Polynomials和其微分的根的线性组合。LG、LGR和LGL的配点分别分布在 τ ∈ ( − 1 , 1 ) \tau \in (-1, 1) τ∈(−1,1), τ ∈ [ − 1 , 1 ) \tau \in [-1, 1) τ∈[−1,1)或者 τ ∈ ( − 1 , 1 ] \tau \in (-1, 1] τ∈(−1,1]、 τ ∈ [ − 1 , 1 ] \tau \in [-1, 1] τ∈[−1,1]。假设 N N N是配点的数目, P N ( τ ) P_N(\tau) PN(τ)是 N N N阶Legendre Polynomial多项式,则有:
多项式的根 | 分布 | 伪谱法分类 | |
---|---|---|---|
L G LG LG | P N ( τ ) P_N(\tau) PN(τ) | τ ∈ ( − 1 , 1 ) \tau \in (-1, 1) τ∈(−1,1) | L o b a t t o Lobatto Lobatto |
L G R LGR LGR | P N − 1 ( τ ) + P N ( τ ) P_{N-1}(\tau) + P_N(\tau) PN−1(τ)+PN(τ) | τ ∈ [ − 1 , 1 ) \tau \in [-1, 1) τ∈[−1,1)或者 τ ∈ ( − 1 , 1 ] \tau \in (-1, 1] τ∈(−1,1] | G a u s s Gauss Gauss |
L G L LGL LGL | P ˙ N − 1 ( τ ) \dot{P}_{N-1}(\tau) P˙N−1(τ) | τ ∈ [ − 1 , 1 ] \tau \in [-1, 1] τ∈[−1,1] | R a d a u Radau Radau |
1.4 Quadrature
采用高斯型数值积分计算近似计算积分:
∫ τ 0 τ f f ( τ ) d τ ≈ ∑ i = 1 N w i f ( τ i ) (1-6) \int_{\tau_0}^{\tau_f} f(\tau)d{\tau} \approx \sum_{i=1}^{N} w_i f(\tau_i) \tag{1-6} ∫τ0τff(τ)dτ≈i=1∑Nwif(τi)(1-6)
其中, w i w_i wi是quadrature weights, τ i \tau_i τi是quadrature points或者notes。 f ( τ ) f(\tau) f(τ)采用Lagrange Polynomial形式有:
∫ τ 0 τ f f ( τ ) d τ = ∫ τ 0 τ f ∑ i = 0 N L i ( τ i ) f ( τ i ) d τ (1-7) \int_{\tau_0}^{\tau_f} f(\tau)d{\tau} = \int_{\tau_0}^{\tau_f} \sum_{i=0}^{N} L_i(\tau_i) f(\tau_i) d{\tau} \tag{1-7} ∫τ0τff(τ)dτ=∫τ0τfi=0∑NLi(τi)f(τi)dτ(1-7)
由公式 ( 1 − 6 ) (1-6) (1−6)和 ( 1 − 7 ) (1-7) (1−7)可以得到:
w i = ∫ τ 0 τ f L i ( τ i ) d τ = ∫ τ 0 τ f ∏ k = 1 , k ≠ i N τ − τ k τ i − τ k d τ , i = 1 , 2 , ⋯ , N (1-8) w_i = \int_{\tau_0}^{\tau_f} L_i(\tau_i) d{\tau} = \int_{\tau_0}^{\tau_f} \prod_{k=1, k \neq i}^{N} {\frac{\tau - \tau_k}{\tau_i - \tau_k}} d{\tau}, i = 1, 2, \cdots, N \tag{1-8} wi=∫τ0τfLi(τi)dτ=∫τ0τfk=1,k=i∏Nτi−τkτ−τkdτ,i=1,2,⋯,N(1-8)
如果 τ i \tau_i τi是Legendre Polynomials的collocation points,可以得到:
w i = 2 1 − τ i 2 [ P ˙ N ( τ i ) ] 2 (1-9) w_i = \frac{2}{1-\tau_i^2}[\dot{P}_N(\tau_i)]^2 \tag{1-9} wi=1−τi22[P˙