-
Notifications
You must be signed in to change notification settings - Fork 439
Updates to balred() and gram() #118
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
Conversation
@@ -347,6 +347,9 @@ def gram(sys,type): | |||
#Check for ss system object | |||
if not isinstance(sys,statesp.StateSpace): | |||
raise ValueError("System must be StateSpace!") | |||
gramtypes = ['c', 'o', 'cf', 'of'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you declare gramtypes
as a variable? It only appears to be used in the conditional expression on the next line, so the motivation for allocating a variable with function-level scope is not apparent to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really remember, I wrote that function a few months ago. If you think there is a better way to do things, then by all means change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the reason that I gave above, moving the list into the conditional expression improves code quality, and thus, I recommend the change. However, it is not critical for accepting this pull request.
Just to be clear, I am belatedly providing review of your proposed changes now.
@@ -50,7 +50,7 @@ | |||
from .statesp import StateSpace | |||
from .statefbk import gram | |||
|
|||
__all__ = ['hsvd', 'balred', 'modred', 'era', 'markov', 'minreal'] | |||
__all__ = ['hsvd', 'balred', 'modred', 'era', 'markov', 'minreal',] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you add a trailing ,
in this list expression? It is not a syntax error, but it is not consistent with the current style of the control
package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to delete the trailing ','.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you delete it, then? I am writing additional comments now, so you might want to wait before rebasing until I send them all.
In the first commit (cc4b5c7) of this pull request, the message and author are incorrectly copied from cdd3e73. When I skim the diff, it appears that you applied changes as part of your own work, but then, those were combined with the patch corresponding to commit cdd3e73. Can you clean it up, in particular remove the re-applied pieces of commit cdd3e73? |
It appears that substantial amounts of code are added in the first commit and then deleted or modified in the second. Can you add details in the commit messages to explain this transition? Alternatively, can you squash changes into a single commit? Those are all of my questions and requests for now. I will wait until you respond or rebase before continuing to review. |
I made changes to the code that you recommended, but my git skills might not be good enough for the other things you want me to do. |
@mdclemen Can I have your permission to create a commit that has your changes from this PR and lists you as author (and me as committer)? This way I can make the rebasing adjustments that I requested above. If I do this, how do you prefer your name to be written? E.g., I can use "clementm" as in your commit f74e665, or your name as it appears in your publications. Alternatively, we can arrange to meet in IRC to work through the |
… will accept a list of 'orders'. gram() now does Cholesky factored gramians if desired. Requires slycot routines AB09MD, AB09ND, SB03OD.
@@ -211,26 +218,46 @@ def balred(sys, orders, method='truncate'): | |||
of systems) | |||
method: string | |||
Method of removing states, either ``'truncate'`` or ``'matchdc'``. | |||
alpha: float | |||
Specifies the alpha-stability boundary for the eigenvalues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This text description of alpha
appears to be copied from AB09MD.f of the SLICOT source code. Is that true? SLICOT is under the GNU GPL, whereas we want to keep this control
package under the BSD license.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the text was indeed copied, can you create a new description of the alpha
parameter? An easy solution for now is to write a brief summary and indicate where more information can be found (the documentation of SLICOT).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original text from SLICOT to which I am referring is in lines 89-96 of AB09MD.f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did in fact copy the description of alpha
from AB09MD.f.
""" | ||
Balanced reduced order model of sys of a given order. | ||
States are eliminated based on Hankel singular value. | ||
If sys has unstable modes, they are removed, the | ||
balanced realization is done on the stable part, then | ||
reinserted IAW reference below. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is "IAW"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you write "in accordance with" explicitly? The abbreviation might not be widely recognized.
I can also make the change after merging.
In Accordance With
…On Wed, Jan 18, 2017 at 2:30 PM, Scott C. Livingston < ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In control/modelsimp.py
<#118 (review)>
:
> """
Balanced reduced order model of sys of a given order.
States are eliminated based on Hankel singular value.
+ If sys has unstable modes, they are removed, the
+ balanced realization is done on the stable part, then
+ reinserted IAW reference below.
What is "IAW"?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#118 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHIA6356Dhq1s6a8jG4dZMEYUEh2E077ks5rTpKTgaJpZM4KcvGY>
.
|
I resolved the merge conflicts, but before I apply them here, can you first address my question about the description of the |
Should we keep the original call to The Fortran implementations of these two subroutines are different, so I am motivated to understand them more before removing the one dedicated to the case of stable systems. |
After we decide actions regarding |
I don't know why the SLICOT authors decided to include a user defined boundary for what constitutes unstable eigenvalues but essentially |
…ibe `alpha`. In balred(), if method='truncate' and the system is stable, slycot ab09ab is used, otherwise ab09md is used.
@slivingston let me know what you think of my updates. |
By default for continuous-time systems, alpha <= 0 defines the stability | ||
boundary for the real part of A's eigenvalues and for discrete-time | ||
systems, 0 <= alpha <= 1 defines the stability boundary for the modulus | ||
of A's eigenvalues.See SLICOT routines AB09MD and AB09ND for more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While resolving the merge conflict, I added a space here after the .
. So, now it reads "...eigenvalues. See SLICOT...".
Your updates are good. Thanks for addressing my comments. |
#118 Changes are from branch `master` of https://github.com/mdclemen/python-control.git
testBalredMatchDC, testGramRc, testGramRo which were introduced in PR #118 use functions that depend on Slycot, so the tests should be skipped if it is not found.
testBalredMatchDC, testGramRc, testGramRo which were introduced in PR #118 use functions that depend on Slycot, so the tests should be skipped if it is not found.
balred() now supports "matchdc" and will handle unstable systems and will accept a list of ORDERS, which will return a list of reduced order systems. gram() now does Cholesky factored gramians if desired. Requires my updates to slycot.