简体   繁体   English

Python:识别系统的 State 空间 Model

[英]Python: Identifying a State Space Model for a System

I am looking to obtain a state space model for a system I have, using python.我希望使用 python 为我拥有的系统获取 state 空间 model。

I have tested the actual system, so I have the inputs to it and I have measured the outputs.我已经测试了实际的系统,所以我有它的输入并且我已经测量了输出。 so I have sets of corresponding inputs and outputs.所以我有一组相应的输入和输出。

Is there a function somewhere, for python, where I can supply the function with the set of inputs and outputs of the system, and the function will then provide me with a state space model that represents the system? Is there a function somewhere, for python, where I can supply the function with the set of inputs and outputs of the system, and the function will then provide me with a state space model that represents the system?

I tried this package available on GitHub: SIPPY (Systems Identification Package for PYthon).我试过这个 package 在 GitHub 上可用: SIPPY (系统识别 Package for PYthon)。

It works well and it is quite simple to use.它运作良好,使用起来非常简单。 There are many identification algorithms that can be used for state-space models (N4SID, MOESP, CVA, PARSIM methods).有许多识别算法可用于状态空间模型(N4SID、MOESP、CVA、PARSIM 方法)。 I think it's the most complete code available in Python.我认为这是 Python 中可用的最完整的代码。

You want to use the n4sid method, this is the only code I know of in Python: pyN4DIS您想使用 n4sid 方法,这是我在 Python 中知道的唯一代码: pyN4DIS

try reading this article: state space model and this state space model2 the latter uses other py packages to create a model, you can use this as module input for your purpose. try reading this article: state space model and this state space model2 the latter uses other py packages to create a model, you can use this as module input for your purpose. Not sure if there are any packages other than these two sets of scripts不知道除了这两组脚本还有没有其他包

There is also sysid .还有sysid I haven't tried any of these (yet) and am interested in hearing what else you have found or tried out so far.我还没有尝试过这些(还),我很想听听你到目前为止发现或尝试过的其他东西。

Industrial chemical and refining applications are some of the earliest applications of model predictive control.工业化工和炼油应用是 model 预测控制的一些最早应用。 They often use other forms for identification such as ARX (Auto-Regressive eXogenous inputs), FIR (Finite Impulse Response), or Transfer Function models.他们经常使用其他 forms 进行识别,例如ARX (自回归外生输入)、 FIR (有限脉冲响应)或传输 Function 模型。 There are good commercial tools for identifying models such as MATLAB System Identification Toolbox, DMC+ (AspenTech), and RMPCT (Honeywell).有很好的识别模型的商业工具,例如 MATLAB System Identification Toolbox、DMC+ (AspenTech) 和 RMPCT (Honeywell)。 There are some recent developments with Seeq system identification in Python .在 Python 中有一些关于Seeq 系统识别的最新进展。 The SIPPY package is an alternative but installation of dependency Slycot (recently commercialized) can be a challenge with the required Fortran compilers . SIPPY package 是一种替代方案,但安装依赖项 Slycot (最近商业化)对于所需的 Fortran 编译器可能是一个挑战 Here is a simple MIMO identification from another post on Model Predictive Control that uses gekko available with pip install gekko .这是Model 预测控制上的另一篇文章中的简单 MIMO 识别,它使用pip pip install gekko

系统识别

from gekko import GEKKO
import pandas as pd
import matplotlib.pyplot as plt

# load data and parse into columns
url = 'http://apmonitor.com/do/uploads/Main/tclab_dyn_data2.txt'
data = pd.read_csv(url)
t = data['Time']
u = data[['H1','H2']]
y = data[['T1','T2']]

# generate time-series model
m = GEKKO(remote=False) # remote=True for MacOS

# system identification
na = 2 # output coefficients
nb = 2 # input coefficients
yp,p,K = m.sysid(t,u,y,na,nb,diaglevel=1)

plt.figure()
plt.subplot(2,1,1)
plt.plot(t,u)
plt.legend([r'$u_0$',r'$u_1$'])
plt.ylabel('MVs')
plt.subplot(2,1,2)
plt.plot(t,y)
plt.plot(t,yp)
plt.legend([r'$y_0$',r'$y_1$',r'$z_0$',r'$z_1$'])
plt.ylabel('CVs')
plt.xlabel('Time')
plt.savefig('sysid.png')
plt.show()

There are standard methods to exactly convert an ARX model to state space form.有一些标准方法可以将 ARX model 精确转换为 state 空间形式。 If the intended application is a predictive controller then the ARX model can be used instead of converting to state space form.如果预期的应用程序是预测 controller,则可以使用 ARX model 而不是转换为 state 空间形式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM