- Notifications
You must be signed in to change notification settings - Fork441
Refactored matrix inversions (see #85 and #91)#101
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
coveralls commentedJul 3, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The original "yottalab" project doesn't exixt anymore. It has been
and
All the other functions of the original yottalab project have migrated Best regards Roberto BTW: For the Swiss Control Association I've prepared a little On 07/03/2016 04:36 PM, Mikhail Pak wrote:
|
coveralls commentedJul 12, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
1fe639c: After some consideration I've also replaced the rank check with both Case in point: importnumpyasnpA=np.matrix("1.0e-3, 0.0; 0.0, 1.0e-3")print(np.linalg.det(A))print(np.linalg.matrix_rank(A)) This changedoes affect unit tests: Fewer systems are skipped in |
coveralls commentedJul 13, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
coveralls commentedJul 13, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
mp4096 commentedJul 13, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
bf6c446: Added singularity check before matrix inversion for DC matching / residualization. I took the liberty to change the unit test slightly, since it does not really matter anyway (see the docstring, it just calls MATLAB-like methods and does not check the results). Instead of eliminating the 2nd and the 3rd state variable, it now eliminates the 1st and the 2nd. 2c25b73: Adds a unit test to check residualization of unstable systems (should throw a 32323d4: Made code more pythonic, in this case list comprehensions instead of for-loops. Also call Edit: Spelling |
Seehttps://travis-ci.org/mp4096/python-control/builds/144536541 for CI results with the correct configuration from#102. |
I will review this tonight. |
coveralls commentedAug 25, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
* The performance remains the same.* The source code is more readable.
Also improved the error message for the singularity check.
* `numpy.linalg.solve` instead of matrix inversion.* Better controllability matrix rank check.
Also made unity elements of the A, B matrices float -- just in case.
And a corresponding unit test
* Changed the unit test in matlab_test.py so that no error is thrown
Mainly list comprehensions instead of for-loops
Faster than converting to a pure Python list.
coveralls commentedNov 21, 2016
1 similar comment
coveralls commentedNov 21, 2016
coveralls commentedNov 21, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
For posterity, the "old TODO" that is referenced in the opening post of this pull request is incontrol/statesp.py at line 127 as of commitc498d3d (current tip of |
slivingston commentedDec 30, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The change in your first commit (4d70d00) refactors some code to use I compared the two alternatives using %timeit of Jupyter for matrices that would correspond to LTI systems with 10 state dimensions, 2 inputs, 2 outputs (so, the A matrix has shape (10, 10), B matrix shape (10,2), etc.), and with 100 state dimensions, 20 inputs, 20 outputs, all using matrices from numpy.random.random((r,c)). The difference in timing performance does not appear significant. However, the case of |
#101Changes are from branch `master` ofhttps://github.com/mp4096/python-control.gitThere was merge conflict in how a for-loop was refactored into`map` (here) vs. list comprehension (from PR#110).I compared the two alternatives using %timeit of Jupyter for matricesthat would correspond to LTI systems with 10 state dimensions, 2inputs, 2 outputs (so, the A matrix has shape (10, 10), B matrix hasshape (10,2), etc.), and with 100 state dimensions, 20 inputs,20 outputs, all using matrices from numpy.random.random((r,c)).The difference in timing performance does not appearsignificant. However, the case of `map` was slightly faster(approximately 500 to 900 ns less in duration), so I decided to usethat one to resolve the merge conflict.
@mp4096 Thanks for these improvements of numerical reliability. As future work, I think that it would be interesting to add more test cases that would fail to be detected if |
Uh oh!
There was an error while loading.Please reload this page.
Continuing work on the issue raised in#85 and partially done in#91:
.I
s andinv
s withnumpy.linalg.solve
ornumpy.linalg.lstsq
. The remaining inversions which I didn't touch are inyottalab.py
. Is it still used?A\B
,A\C
by solvingA\[B, C]
and taking views for the corresponding results. This avoids redundant cubic LU decompositions.compatability
->compatability
I commented out the matrix singularity check inSee comment forbf6c446modelsimp.py
since it correctly raises an error duringtestModred()
inmatlab_test.py
. MatrixA22
is indeed numerically singular in this case (second column is something like[[0.0, 3.0e-16]]
). Should we change the test case?