Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a bug in the example codes? #48

Closed
Bemnet-Won opened this issue Aug 19, 2022 · 5 comments
Closed

a bug in the example codes? #48

Bemnet-Won opened this issue Aug 19, 2022 · 5 comments

Comments

@Bemnet-Won
Copy link

Thanks for sharing the system identification codes. Professor Gabriele Pannocchia introduced the CPCLAB-UNIPI github page in his lectures at the Chinese MPC school.

When I tried to execute the example codes, I found that the majority of them had a common problem with the fset.validation function. Is it a common bug or is it because I am using a different version of some of the packages? An inconsistent shape in line 805 of the fset.validation function is the cause of the issue. The Ex ARMAX, Ex ARMAX MIMO, Ex CST, Ex OPT GEN-INOUT, and Ex RECURSIVE all use fset.validation and all have the same issue.

The Ex ARX MIMO and Ex SS both function well.

Traceback (most recent call last):
File "C:/Users/bemnet/Desktop/First_Model/SIPPY-PYCHRM-master/Examples/Ex_ARMAX.py", line 174, in
Yv_armaxi = fset.validation(Id_ARMAXi,U_valid,Ytotvalid,Time)
File "C:\Users\bemnet\Desktop\First_Model\SIPPY-PYCHRM-master\sippy\functionset.py", line 196, in validation
Y_u, T, Xv = cnt.lsim((1/SYS.H[i,0])*SYS.G[i,:], u, Time)
File "C:\Users\bemnet\anaconda3\envs\SYSID_4PYCHRM\lib\site-packages\control\matlab\timeresp.py", line 297, in lsim
out = forced_response(sys, T, U, X0, return_x=True, transpose=True)
File "C:\Users\bemnet\anaconda3\envs\SYSID_4PYCHRM\lib\site-packages\control\timeresp.py", line 1007, in forced_response
U = _check_convert_array(U, legal_shapes,
File "C:\Users\bemnet\anaconda3\envs\SYSID_4PYCHRM\lib\site-packages\control\timeresp.py", line 805, in _check_convert_array
raise ValueError(err_msg_start + err_msg)
ValueError: Parameter U: Wrong shape (rows, columns): (401, 1). Expected: (401,) or (1, 401).

@Bemnet-Won
Copy link
Author

I used the control-0.9.2 which caused the error

downgrading it to control-0.8.4 solved the problem

@miroslavfikar
Copy link
Contributor

The problem persists with the latest control-0.9.3

@mvaccariunipi
Copy link
Collaborator

mvaccariunipi commented Mar 3, 2023 via email

@miroslavfikar
Copy link
Contributor

It helped to me replace the function lsim with forced_response (in the validation function) and I no longer get the ValueError.
Y_u, T, Xv = cnt.lsim((1/SYS.H[i,0])*SYS.G[i,:], u, Time)
Y_y, T, Xv = cnt.lsim(1 - (1/SYS.H[i,0]), y[i,:] - y_rif[i], Time)
->
Y_u, T = cnt.forced_response((1/SYS.H[i,0])*SYS.G[i,:], Time, u)
Y_y, T = cnt.forced_response(1 - (1/SYS.H[i,0]), Time, y[i,:] - y_rif[i])
HTH

@RBdC
Copy link
Collaborator

RBdC commented Apr 18, 2023

Hi Miroslav,
thank you very much for your comment.
We have just tested your solution on our SIPPY, but it seems still dependent on the control version.
Indeed, with control 0.8.3 we need to swap the output position in cnt.forced_response: Y_y, T --> T, Y_y.
Keep in touch when a definitive solution will be possible!
Best
Riccardo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants