CPCLAB-UNIPI / SIPPY

Systems Identification Package for PYthon
GNU Lesser General Public License v3.0
269 stars 92 forks source link

Not able to Simulate Identified System [ARMAX] #13

Closed mzahana closed 4 years ago

mzahana commented 4 years ago

Greetings.

I was able to identify a system using ARMAX using the following command

sys_id_roll = system_identification(y_debiased.T, u_debiased[0], method, IC='BIC', na_ord=[2, 5], nb_ord=[1, 5], nc_ord=[0, 2], delays=[0, 0], ARMAX_max_iterations=300, tsample=dt, centering='MeanVal')

with the following result,

Armax model:
- Params:
  na: 5 (2, 5)
  nb: 5 (1, 5)
  nc: 1 (0, 2)
  delay: 0 (0, 0)
  dt: 0.001 
  method: BIC 
  max iterations: 300 
- Output:
  G: 
   -0.2609 z^4 - 0.2886 z^3 + 0.6313 z^2 + 2.767 z - 2.718
------------------------------------------------------------
z^5 - 1.002 z^4 - 0.3068 z^3 + 0.325 z^2 + 0.6365 z - 0.6526

dt = 0.001

  H: 
                      z^5 + 0.7202 z^4
------------------------------------------------------------
z^5 - 1.002 z^4 - 0.3068 z^3 + 0.325 z^2 + 0.6365 z - 0.6526

dt = 0.001

  Variance: 0.00754123994461 
  Max reached: False

However, when I try to simulate the identified system using the following command,

Y_id, T, Xsim = cnt.lsim(sys_id_roll.G, u_debiased[0], t)

It gives the following error,

Traceback (most recent call last):
  File "prep_data.py", line 147, in <module>
    Y_id, T, Xsim = cnt.lsim(sys_id_roll.G, u_debiased[0], t)
  File "/home/labuser/.local/lib/python2.7/site-packages/control/matlab/timeresp.py", line 273, in lsim
    T, yout, xout = forced_response(sys, T, U, X0, transpose = True)
  File "/home/labuser/.local/lib/python2.7/site-packages/control/timeresp.py", line 344, in forced_response
    raise ValueError("Time steps ``T`` must be multiples of " \
ValueError: Time steps ``T`` must be multiples of sampling time

Any ideas on what the problem could be?

Thanks

CPCLAB-UNIPI commented 4 years ago

Hi, can you detail which version of Python and control package you are using, and in which OS?

mzahana commented 4 years ago

@CPCLAB-UNIPI I am using

Thanks.

CPCLAB-UNIPI commented 4 years ago

ok, it may be a problem not related to our Sippy package, but to python-control package.

How is your time vector "t" defined? Is a vector imported from an external source? from a physical device? Note that it seems to be a not perfectly equispaced vector.

When using control.lsim, the time step within time vector t must an exact multiple of the sampling time dt (0.001 in the case of your identified system).

Note that there is also an Issues on the Control repository concerning this error: "ValueError: Time steps T must be multiples of sampling time": https://github.com/python-control/python-control/issues/332

For further info you may also contact the control support repository: https://github.com/python-control/python-control

We also recommend you switching to Python 3.x since Python 2.7 official support stops on January 1, 2020: https://www.python.org/dev/peps/pep-0373/

mzahana commented 4 years ago

Thanks. I will try to switch to Python3 and check.