Type: Object
Data: A, B matrices
Inputs: Input (u)
Outputs: Output (y)
Description: ARX Time Series Model
APMonitor Usage: sys = arx
GEKKO Usage: y,u = m.arx(p,y=[],u=[])
ARX time series models are a linear representation of a dynamic system in discrete time. Putting a model into ARX form is the basis for many methods in process dynamics and control analysis. Below is the time series model with a single input and single output with k as an index that refers to the time step.
Time series models are used for identification and advanced control. It has been in use in the process industries such as chemical plants and oil refineries since the 1980s. Model predictive controllers rely on dynamic models of the process, most often linear empirical models obtained by system identification.
# see https://apmonitor.com/wiki/index.php/Apps/ARXTimeSeries from gekko import GEKKO import numpy as np import pandas as pd import matplotlib.pyplotas 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']
y = data['T1']
m = GEKKO()
# system identification
na =2# output coefficients
nb =2# input coefficients
yp,p,K = m.sysid(t,u,y,na,nb,pred='meas')
from gekko import GEKKO import numpy as np import pandas as pd import matplotlib.pyplotas 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']]
m = GEKKO()
# system identification
na =2# output coefficients
nb =2# input coefficients
yp,p,K = m.sysid(t,u,y,na,nb,pred='meas')
These models are typically in the finite impulse response, time series, or linear state space form. Once in APMonitor form, nonlinear elements can be added to avoid multiple model switching, gain scheduling, or other ad hoc measures commonly employed because of linear MPC restrictions.
import numpy as np from gekko import GEKKO import matplotlib.pyplotas plt
na =2# Number of A coefficients
nb =1# Number of B coefficients
ny =2# Number of outputs
nu =2# Number of inputs
# A (na x ny)
A = np.array([[0.36788,0.36788],\ [0.223,-0.136]]) # B (ny x (nb x nu))
B1 = np.array([0.63212,0.18964]).T
B2 = np.array([0.31606,1.26420]).T
B = np.array([[B1],[B2]])
C = np.array([0,0])
# create parameter dictionary # parameter dictionary p['a'], p['b'], p['c'] # a (coefficients for a polynomial, na x ny) # b (coefficients for b polynomial, ny x (nb x nu)) # c (coefficients for output bias, ny)
p ={'a':A,'b':B,'c':C}
# Create GEKKO model
m = GEKKO(remote=False)
# Build GEKKO ARX model
y,u = m.arx(p)
# load inputs
tf =20# final time
u1 = np.zeros(tf+1)
u2 = u1.copy()
u1[5:]=3.0
u2[10:]=5.0
u[0].value= u1
u[1].value= u2