Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Generating transfer functions from NUMERATOR and DENOMINATOR
# you can use directly Id_sys.G for the G*u term, see the arx_MIMO example.
gid11 = cnt.tf(Id_sys.NUMERATOR[0][0], Id_sys.DENOMINATOR[0][0], 1.)
gid12 = cnt.tf(Id_sys.NUMERATOR[0][1], Id_sys.DENOMINATOR[0][1], 1.)
gid13 = cnt.tf(Id_sys.NUMERATOR[0][2], Id_sys.DENOMINATOR[0][2], 1.)
gid21 = cnt.tf(Id_sys.NUMERATOR[1][0], Id_sys.DENOMINATOR[1][0], 1.)
gid22 = cnt.tf(Id_sys.NUMERATOR[1][1], Id_sys.DENOMINATOR[1][1], 1.)
gid23 = cnt.tf(Id_sys.NUMERATOR[1][2], Id_sys.DENOMINATOR[1][2], 1.)
gid14 = cnt.tf(Id_sys.NUMERATOR[0][3], Id_sys.DENOMINATOR[0][3], 1.)
gid24 = cnt.tf(Id_sys.NUMERATOR[1][3], Id_sys.DENOMINATOR[1][3], 1.)
gid31 = cnt.tf(Id_sys.NUMERATOR[2][0], Id_sys.DENOMINATOR[2][0], 1.)
gid32 = cnt.tf(Id_sys.NUMERATOR[2][1], Id_sys.DENOMINATOR[2][1], 1.)
gid33 = cnt.tf(Id_sys.NUMERATOR[2][2], Id_sys.DENOMINATOR[2][2], 1.)
gid34 = cnt.tf(Id_sys.NUMERATOR[2][3], Id_sys.DENOMINATOR[2][3], 1.)
hid1 = cnt.tf(Id_sys.NUMERATOR_H[0][0], Id_sys.DENOMINATOR_H[0][0], 1.)
hid2 = cnt.tf(Id_sys.NUMERATOR_H[1][0], Id_sys.DENOMINATOR_H[1][0], 1.)
hid3 = cnt.tf(Id_sys.NUMERATOR_H[2][0], Id_sys.DENOMINATOR_H[2][0], 1.)
# output of the identified model
Yout_id11, Time, Xsim = cnt.lsim(gid11, Usim[0, :], Time)
Yout_id12, Time, Xsim = cnt.lsim(gid12, Usim[1, :], Time)
Yout_id13, Time, Xsim = cnt.lsim(gid13, Usim[2, :], Time)
Yout_id14, Time, Xsim = cnt.lsim(gid14, Usim[3, :], Time)
Yout_id21, Time, Xsim = cnt.lsim(gid21, Usim[0, :], Time)
Yout_id22, Time, Xsim = cnt.lsim(gid22, Usim[1, :], Time)
Yout_id23, Time, Xsim = cnt.lsim(gid23, Usim[2, :], Time)
Yout_id24, Time, Xsim = cnt.lsim(gid24, Usim[3, :], Time)
Yout_id31, Time, Xsim = cnt.lsim(gid31, Usim[0, :], Time)
Yout_id32, Time, Xsim = cnt.lsim(gid32, Usim[1, :], Time)
Yout_id33, Time, Xsim = cnt.lsim(gid33, Usim[2, :], Time)
Yout_id34, Time, Xsim = cnt.lsim(gid34, Usim[3, :], Time)
Id_sys = system_identification(Ytot, Usim, 'ARMAX',
ARMAX_orders=[ordersna, ordersnb, ordersnc, theta_list],
ARMAX_max_iterations=20) #
# Generating transfer functions from NUMERATOR and DENOMINATOR
# you can use directly Id_sys.G for the G*u term, see the arx_MIMO example.
gid11 = cnt.tf(Id_sys.NUMERATOR[0][0], Id_sys.DENOMINATOR[0][0], 1.)
gid12 = cnt.tf(Id_sys.NUMERATOR[0][1], Id_sys.DENOMINATOR[0][1], 1.)
gid13 = cnt.tf(Id_sys.NUMERATOR[0][2], Id_sys.DENOMINATOR[0][2], 1.)
gid21 = cnt.tf(Id_sys.NUMERATOR[1][0], Id_sys.DENOMINATOR[1][0], 1.)
gid22 = cnt.tf(Id_sys.NUMERATOR[1][1], Id_sys.DENOMINATOR[1][1], 1.)
gid23 = cnt.tf(Id_sys.NUMERATOR[1][2], Id_sys.DENOMINATOR[1][2], 1.)
gid14 = cnt.tf(Id_sys.NUMERATOR[0][3], Id_sys.DENOMINATOR[0][3], 1.)
gid24 = cnt.tf(Id_sys.NUMERATOR[1][3], Id_sys.DENOMINATOR[1][3], 1.)
gid31 = cnt.tf(Id_sys.NUMERATOR[2][0], Id_sys.DENOMINATOR[2][0], 1.)
gid32 = cnt.tf(Id_sys.NUMERATOR[2][1], Id_sys.DENOMINATOR[2][1], 1.)
gid33 = cnt.tf(Id_sys.NUMERATOR[2][2], Id_sys.DENOMINATOR[2][2], 1.)
gid34 = cnt.tf(Id_sys.NUMERATOR[2][3], Id_sys.DENOMINATOR[2][3], 1.)
hid1 = cnt.tf(Id_sys.NUMERATOR_H[0][0], Id_sys.DENOMINATOR_H[0][0], 1.)
hid2 = cnt.tf(Id_sys.NUMERATOR_H[1][0], Id_sys.DENOMINATOR_H[1][0], 1.)
hid3 = cnt.tf(Id_sys.NUMERATOR_H[2][0], Id_sys.DENOMINATOR_H[2][0], 1.)
# output of the identified model
Yout_id11, Time, Xsim = cnt.lsim(gid11, Usim[0, :], Time)
Yout_id12, Time, Xsim = cnt.lsim(gid12, Usim[1, :], Time)
Yout_id13, Time, Xsim = cnt.lsim(gid13, Usim[2, :], Time)
Yout_id14, Time, Xsim = cnt.lsim(gid14, Usim[3, :], Time)
Yout_id21, Time, Xsim = cnt.lsim(gid21, Usim[0, :], Time)
Yout_id22, Time, Xsim = cnt.lsim(gid22, Usim[1, :], Time)
Yout_id23, Time, Xsim = cnt.lsim(gid23, Usim[2, :], Time)
Yout_id24, Time, Xsim = cnt.lsim(gid24, Usim[3, :], Time)
nb32 = 2
nb33 = 1
nb34 = 2
th31 = 0
th32 = 1
th33 = 0
th34 = 2
# transfer function G, H
g_sample11 = cnt.tf(NUM11, DEN1, ts)
g_sample12 = cnt.tf(NUM12, DEN1, ts)
g_sample13 = cnt.tf(NUM13, DEN1, ts)
g_sample14 = cnt.tf(NUM14, DEN1, ts)
g_sample22 = cnt.tf(NUM22, DEN2, ts)
g_sample21 = cnt.tf(NUM21, DEN2, ts)
g_sample23 = cnt.tf(NUM23, DEN2, ts)
g_sample24 = cnt.tf(NUM24, DEN2, ts)
g_sample31 = cnt.tf(NUM31, DEN3, ts)
g_sample32 = cnt.tf(NUM32, DEN3, ts)
g_sample33 = cnt.tf(NUM33, DEN3, ts)
g_sample34 = cnt.tf(NUM34, DEN3, ts)
H_sample1 = cnt.tf(H1, DEN1, ts)
H_sample2 = cnt.tf(H2, DEN2, ts)
H_sample3 = cnt.tf(H3, DEN3, ts)
#
tfin = 400
npts = int(old_div(tfin, ts)) + 1
Time = np.linspace(0, tfin, npts)
##identification parameters
ordersna = [na1, na2, na3]
ordersnb = [[nb11, nb12, nb13, nb14], [nb21, nb22, nb23, nb24], [nb31, nb32, nb33, nb34]]
ordersnc = [nc1, nc2, nc3]
theta_list = [[th11, th12, th13, th14], [th21, th22, th23, th24], [th31, th32, th33, th34]]
# IDENTIFICATION
Id_sys = system_identification(Ytot, Usim, 'ARMAX',
ARMAX_orders=[ordersna, ordersnb, ordersnc, theta_list],
ARMAX_max_iterations=20) #
# Generating transfer functions from NUMERATOR and DENOMINATOR
# you can use directly Id_sys.G for the G*u term, see the arx_MIMO example.
gid11 = cnt.tf(Id_sys.NUMERATOR[0][0], Id_sys.DENOMINATOR[0][0], 1.)
gid12 = cnt.tf(Id_sys.NUMERATOR[0][1], Id_sys.DENOMINATOR[0][1], 1.)
gid13 = cnt.tf(Id_sys.NUMERATOR[0][2], Id_sys.DENOMINATOR[0][2], 1.)
gid21 = cnt.tf(Id_sys.NUMERATOR[1][0], Id_sys.DENOMINATOR[1][0], 1.)
gid22 = cnt.tf(Id_sys.NUMERATOR[1][1], Id_sys.DENOMINATOR[1][1], 1.)
gid23 = cnt.tf(Id_sys.NUMERATOR[1][2], Id_sys.DENOMINATOR[1][2], 1.)
gid14 = cnt.tf(Id_sys.NUMERATOR[0][3], Id_sys.DENOMINATOR[0][3], 1.)
gid24 = cnt.tf(Id_sys.NUMERATOR[1][3], Id_sys.DENOMINATOR[1][3], 1.)
gid31 = cnt.tf(Id_sys.NUMERATOR[2][0], Id_sys.DENOMINATOR[2][0], 1.)
gid32 = cnt.tf(Id_sys.NUMERATOR[2][1], Id_sys.DENOMINATOR[2][1], 1.)
gid33 = cnt.tf(Id_sys.NUMERATOR[2][2], Id_sys.DENOMINATOR[2][2], 1.)
gid34 = cnt.tf(Id_sys.NUMERATOR[2][3], Id_sys.DENOMINATOR[2][3], 1.)
hid1 = cnt.tf(Id_sys.NUMERATOR_H[0][0], Id_sys.DENOMINATOR_H[0][0], 1.)
hid2 = cnt.tf(Id_sys.NUMERATOR_H[1][0], Id_sys.DENOMINATOR_H[1][0], 1.)
hid3 = cnt.tf(Id_sys.NUMERATOR_H[2][0], Id_sys.DENOMINATOR_H[2][0], 1.)
# output of the identified model
nb33 = 1
nb34 = 2
th31 = 0
th32 = 1
th33 = 0
th34 = 2
nc3 = 3
# transfer function G, H
g_sample11 = cnt.tf(NUM11, DEN1, ts)
g_sample12 = cnt.tf(NUM12, DEN1, ts)
g_sample13 = cnt.tf(NUM13, DEN1, ts)
g_sample14 = cnt.tf(NUM14, DEN1, ts)
g_sample22 = cnt.tf(NUM22, DEN2, ts)
g_sample21 = cnt.tf(NUM21, DEN2, ts)
g_sample23 = cnt.tf(NUM23, DEN2, ts)
g_sample24 = cnt.tf(NUM24, DEN2, ts)
g_sample31 = cnt.tf(NUM31, DEN3, ts)
g_sample32 = cnt.tf(NUM32, DEN3, ts)
g_sample33 = cnt.tf(NUM33, DEN3, ts)
g_sample34 = cnt.tf(NUM34, DEN3, ts)
H_sample1 = cnt.tf(H1, DEN1, ts)
H_sample2 = cnt.tf(H2, DEN2, ts)
H_sample3 = cnt.tf(H3, DEN3, ts)
#
tfin = 400
npts = int(old_div(tfin, ts)) + 1
Time = np.linspace(0, tfin, npts)
Ytot[2, :] = (Ytot3 + err_outputH3).squeeze()
##identification parameters
ordersna = [na1, na2, na3]
ordersnb = [[nb11, nb12, nb13, nb14], [nb21, nb22, nb23, nb24], [nb31, nb32, nb33, nb34]]
ordersnc = [nc1, nc2, nc3]
theta_list = [[th11, th12, th13, th14], [th21, th22, th23, th24], [th31, th32, th33, th34]]
# IDENTIFICATION
Id_sys = system_identification(Ytot, Usim, 'ARMAX',
ARMAX_orders=[ordersna, ordersnb, ordersnc, theta_list],
ARMAX_max_iterations=20) #
# Generating transfer functions from NUMERATOR and DENOMINATOR
# you can use directly Id_sys.G for the G*u term, see the arx_MIMO example.
gid11 = cnt.tf(Id_sys.NUMERATOR[0][0], Id_sys.DENOMINATOR[0][0], 1.)
gid12 = cnt.tf(Id_sys.NUMERATOR[0][1], Id_sys.DENOMINATOR[0][1], 1.)
gid13 = cnt.tf(Id_sys.NUMERATOR[0][2], Id_sys.DENOMINATOR[0][2], 1.)
gid21 = cnt.tf(Id_sys.NUMERATOR[1][0], Id_sys.DENOMINATOR[1][0], 1.)
gid22 = cnt.tf(Id_sys.NUMERATOR[1][1], Id_sys.DENOMINATOR[1][1], 1.)
gid23 = cnt.tf(Id_sys.NUMERATOR[1][2], Id_sys.DENOMINATOR[1][2], 1.)
gid14 = cnt.tf(Id_sys.NUMERATOR[0][3], Id_sys.DENOMINATOR[0][3], 1.)
gid24 = cnt.tf(Id_sys.NUMERATOR[1][3], Id_sys.DENOMINATOR[1][3], 1.)
gid31 = cnt.tf(Id_sys.NUMERATOR[2][0], Id_sys.DENOMINATOR[2][0], 1.)
gid32 = cnt.tf(Id_sys.NUMERATOR[2][1], Id_sys.DENOMINATOR[2][1], 1.)
gid33 = cnt.tf(Id_sys.NUMERATOR[2][2], Id_sys.DENOMINATOR[2][2], 1.)
gid34 = cnt.tf(Id_sys.NUMERATOR[2][3], Id_sys.DENOMINATOR[2][3], 1.)
hid1 = cnt.tf(Id_sys.NUMERATOR_H[0][0], Id_sys.DENOMINATOR_H[0][0], 1.)
hid2 = cnt.tf(Id_sys.NUMERATOR_H[1][0], Id_sys.DENOMINATOR_H[1][0], 1.)
hid3 = cnt.tf(Id_sys.NUMERATOR_H[2][0], Id_sys.DENOMINATOR_H[2][0], 1.)
# you can use directly Id_sys.G for the G*u term, see the arx_MIMO example.
gid11 = cnt.tf(Id_sys.NUMERATOR[0][0], Id_sys.DENOMINATOR[0][0], 1.)
gid12 = cnt.tf(Id_sys.NUMERATOR[0][1], Id_sys.DENOMINATOR[0][1], 1.)
gid13 = cnt.tf(Id_sys.NUMERATOR[0][2], Id_sys.DENOMINATOR[0][2], 1.)
gid21 = cnt.tf(Id_sys.NUMERATOR[1][0], Id_sys.DENOMINATOR[1][0], 1.)
gid22 = cnt.tf(Id_sys.NUMERATOR[1][1], Id_sys.DENOMINATOR[1][1], 1.)
gid23 = cnt.tf(Id_sys.NUMERATOR[1][2], Id_sys.DENOMINATOR[1][2], 1.)
gid14 = cnt.tf(Id_sys.NUMERATOR[0][3], Id_sys.DENOMINATOR[0][3], 1.)
gid24 = cnt.tf(Id_sys.NUMERATOR[1][3], Id_sys.DENOMINATOR[1][3], 1.)
gid31 = cnt.tf(Id_sys.NUMERATOR[2][0], Id_sys.DENOMINATOR[2][0], 1.)
gid32 = cnt.tf(Id_sys.NUMERATOR[2][1], Id_sys.DENOMINATOR[2][1], 1.)
gid33 = cnt.tf(Id_sys.NUMERATOR[2][2], Id_sys.DENOMINATOR[2][2], 1.)
gid34 = cnt.tf(Id_sys.NUMERATOR[2][3], Id_sys.DENOMINATOR[2][3], 1.)
hid1 = cnt.tf(Id_sys.NUMERATOR_H[0][0], Id_sys.DENOMINATOR_H[0][0], 1.)
hid2 = cnt.tf(Id_sys.NUMERATOR_H[1][0], Id_sys.DENOMINATOR_H[1][0], 1.)
hid3 = cnt.tf(Id_sys.NUMERATOR_H[2][0], Id_sys.DENOMINATOR_H[2][0], 1.)
# output of the identified model
Yout_id11, Time, Xsim = cnt.lsim(gid11, Usim[0, :], Time)
Yout_id12, Time, Xsim = cnt.lsim(gid12, Usim[1, :], Time)
Yout_id13, Time, Xsim = cnt.lsim(gid13, Usim[2, :], Time)
Yout_id14, Time, Xsim = cnt.lsim(gid14, Usim[3, :], Time)
Yout_id21, Time, Xsim = cnt.lsim(gid21, Usim[0, :], Time)
Yout_id22, Time, Xsim = cnt.lsim(gid22, Usim[1, :], Time)
Yout_id23, Time, Xsim = cnt.lsim(gid23, Usim[2, :], Time)
Yout_id24, Time, Xsim = cnt.lsim(gid24, Usim[3, :], Time)
Yout_id31, Time, Xsim = cnt.lsim(gid31, Usim[0, :], Time)
Yout_id32, Time, Xsim = cnt.lsim(gid32, Usim[1, :], Time)
Yout_id33, Time, Xsim = cnt.lsim(gid33, Usim[2, :], Time)
Yout_id34, Time, Xsim = cnt.lsim(gid34, Usim[3, :], Time)
Yerr1, Time, Xsim = cnt.lsim(hid1, err_inputH[0, :], Time)
H3 = [1., 0., 0., 0., 0.]
na3 = 2
nb31 = 1
nb32 = 2
nb33 = 1
nb34 = 2
th31 = 0
th32 = 1
th33 = 0
th34 = 2
# transfer function G, H
g_sample11 = cnt.tf(NUM11, DEN1, ts)
g_sample12 = cnt.tf(NUM12, DEN1, ts)
g_sample13 = cnt.tf(NUM13, DEN1, ts)
g_sample14 = cnt.tf(NUM14, DEN1, ts)
g_sample22 = cnt.tf(NUM22, DEN2, ts)
g_sample21 = cnt.tf(NUM21, DEN2, ts)
g_sample23 = cnt.tf(NUM23, DEN2, ts)
g_sample24 = cnt.tf(NUM24, DEN2, ts)
g_sample31 = cnt.tf(NUM31, DEN3, ts)
g_sample32 = cnt.tf(NUM32, DEN3, ts)
g_sample33 = cnt.tf(NUM33, DEN3, ts)
g_sample34 = cnt.tf(NUM34, DEN3, ts)
H_sample1 = cnt.tf(H1, DEN1, ts)
H_sample2 = cnt.tf(H2, DEN2, ts)
H_sample3 = cnt.tf(H3, DEN3, ts)
nb34 = 2
th31 = 0
th32 = 1
th33 = 0
th34 = 2
nc3 = 3
# transfer function G, H
g_sample11 = cnt.tf(NUM11, DEN1, ts)
g_sample12 = cnt.tf(NUM12, DEN1, ts)
g_sample13 = cnt.tf(NUM13, DEN1, ts)
g_sample14 = cnt.tf(NUM14, DEN1, ts)
g_sample22 = cnt.tf(NUM22, DEN2, ts)
g_sample21 = cnt.tf(NUM21, DEN2, ts)
g_sample23 = cnt.tf(NUM23, DEN2, ts)
g_sample24 = cnt.tf(NUM24, DEN2, ts)
g_sample31 = cnt.tf(NUM31, DEN3, ts)
g_sample32 = cnt.tf(NUM32, DEN3, ts)
g_sample33 = cnt.tf(NUM33, DEN3, ts)
g_sample34 = cnt.tf(NUM34, DEN3, ts)
H_sample1 = cnt.tf(H1, DEN1, ts)
H_sample2 = cnt.tf(H2, DEN2, ts)
H_sample3 = cnt.tf(H3, DEN3, ts)
#
tfin = 400
npts = int(old_div(tfin, ts)) + 1
Time = np.linspace(0, tfin, npts)
# #INPUT#
ordersnc = [nc1, nc2, nc3]
theta_list = [[th11, th12, th13, th14], [th21, th22, th23, th24], [th31, th32, th33, th34]]
# IDENTIFICATION
Id_sys = system_identification(Ytot, Usim, 'ARMAX',
ARMAX_orders=[ordersna, ordersnb, ordersnc, theta_list],
ARMAX_max_iterations=20) #
# Generating transfer functions from NUMERATOR and DENOMINATOR
# you can use directly Id_sys.G for the G*u term, see the arx_MIMO example.
gid11 = cnt.tf(Id_sys.NUMERATOR[0][0], Id_sys.DENOMINATOR[0][0], 1.)
gid12 = cnt.tf(Id_sys.NUMERATOR[0][1], Id_sys.DENOMINATOR[0][1], 1.)
gid13 = cnt.tf(Id_sys.NUMERATOR[0][2], Id_sys.DENOMINATOR[0][2], 1.)
gid21 = cnt.tf(Id_sys.NUMERATOR[1][0], Id_sys.DENOMINATOR[1][0], 1.)
gid22 = cnt.tf(Id_sys.NUMERATOR[1][1], Id_sys.DENOMINATOR[1][1], 1.)
gid23 = cnt.tf(Id_sys.NUMERATOR[1][2], Id_sys.DENOMINATOR[1][2], 1.)
gid14 = cnt.tf(Id_sys.NUMERATOR[0][3], Id_sys.DENOMINATOR[0][3], 1.)
gid24 = cnt.tf(Id_sys.NUMERATOR[1][3], Id_sys.DENOMINATOR[1][3], 1.)
gid31 = cnt.tf(Id_sys.NUMERATOR[2][0], Id_sys.DENOMINATOR[2][0], 1.)
gid32 = cnt.tf(Id_sys.NUMERATOR[2][1], Id_sys.DENOMINATOR[2][1], 1.)
gid33 = cnt.tf(Id_sys.NUMERATOR[2][2], Id_sys.DENOMINATOR[2][2], 1.)
gid34 = cnt.tf(Id_sys.NUMERATOR[2][3], Id_sys.DENOMINATOR[2][3], 1.)
hid1 = cnt.tf(Id_sys.NUMERATOR_H[0][0], Id_sys.DENOMINATOR_H[0][0], 1.)
hid2 = cnt.tf(Id_sys.NUMERATOR_H[1][0], Id_sys.DENOMINATOR_H[1][0], 1.)
hid3 = cnt.tf(Id_sys.NUMERATOR_H[2][0], Id_sys.DENOMINATOR_H[2][0], 1.)
# output of the identified model
Yout_id11, Time, Xsim = cnt.lsim(gid11, Usim[0, :], Time)
Yout_id12, Time, Xsim = cnt.lsim(gid12, Usim[1, :], Time)
Yout_id13, Time, Xsim = cnt.lsim(gid13, Usim[2, :], Time)
Yout_id14, Time, Xsim = cnt.lsim(gid14, Usim[3, :], Time)