4

我用来计算scipy.linalg.solve_discrete_lyapunov矩阵P

M T PM - P = -Q其中M = A - BKQ = I

(见下文,另见 李雅普诺夫方程)。然而,对于计算出的P ,我得到M T PM - P ≠ - Q

这是代码:

import numpy as np
import scipy as sp 

A = np.array([[-1.86194971, 3.49237959],[-2.34245904, 3.86194971]])
B = np.array([[ 3000., 2500.5], [ 2000.2, 3000.]])
K = np.array([[ 0.0001367, -0.00016844], [-0.00069637, 0.0009627]])
I = np.array([[1., 0.],[0., 1.]])

# Eigenvalues of A are (0.9, 1.1)
# Eigenvalues of A-BK are (0.29, 0.49) (i.e. A-BK is Schur)

P = sp.linalg.solve_discrete_lyapunov(A-np.dot(B,K), I)

# P= [[ 6.61311138  4.32497891]
#     [ 4.32497891  4.36910499]]

# But after checking (A-BK)^TP(A-BK)-P, that is 

J = np.dot((A.transpose()-np.dot(K.transpose(),B.transpose())),np.dot(P,A-np.dot(B,K)))-P

# I get the following
# J = (A-BK)^TP(A-BK)-P = [[ -1.11929701 -19.5567893 ]
#                          [-19.5567893   37.89911723]]
#                   
# Not equal to -I?
4

1 回答 1

3

M = A - np.dot(B,K). 然后solve_discrete_lyapunov(M, I)是解决

np.dot(M, np.dot(P, M.T)) - P = -I

In [64]: M = A - np.dot(B,K)

In [65]: np.dot(M, np.dot(P,M.T)) - P
Out[65]: 
array([[ -1.00014927e+00,  -9.93418066e-05],
       [ -9.93418066e-05,  -1.00006419e+00]])

In [66]: np.allclose(np.dot(M, np.dot(P,M.T)) - P, -I, atol=0.001)
Out[66]: True

如果你想解决

np.dot(M.T, np.dot(P, M)) - P + I = 0

然后打电话

P = solve_discrete_lyapunov(M.T, I)
于 2013-05-01T10:20:16.033 回答