-
Notifications
You must be signed in to change notification settings - Fork 85
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
Update prescale
function
#465
Changes from all commits
bb244e9
880fdcb
4139f2d
a590809
be249d0
e38a79a
c0a1088
ba1cc92
8d31f6a
cac2f60
69f58c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -568,7 +568,7 @@ end | |
syst = similarity_transform(sys, T) | ||
Perform a similarity transform `T : Tx̃ = x` on `sys` such that | ||
``` | ||
à = T⁻¹AT | ||
à = T⁻¹AT | ||
B̃ = T⁻¹ B | ||
C̃ = CT | ||
D̃ = D | ||
|
@@ -585,24 +585,31 @@ end | |
|
||
""" | ||
syst, S = prescale(sys) | ||
Perform a eigendecomposition on system state-transition matrix `sys.A`. | ||
|
||
Balances the metasystem matrix | ||
``` | ||
à = S⁻¹AS | ||
B̃ = S⁻¹ B | ||
C̃ = CS | ||
D̃ = D | ||
M = [A B; | ||
C 0] | ||
``` | ||
Such that `Ã` is diagonal. | ||
Returns a new scaled state-space object and the associated transformation | ||
matrix. | ||
such that their column and row norms are closer. | ||
This results in a system with overall better numerical conditioning. | ||
|
||
Returns a new scaled state-space object. | ||
""" | ||
function prescale(sys::StateSpace) | ||
d, S = eigen(sys.A) | ||
A = Diagonal(d) | ||
B = S\sys.B | ||
C = sys.C*S | ||
normalized_sys = iscontinuous(sys) ? ss(A, B, C, sys.D) : ss(A, B, C, sys.D, sys.Ts) | ||
return normalized_sys, S | ||
function prescale(sys::ST) where ST <: AbstractStateSpace | ||
n, m = size(sys.B) | ||
p = size(sys.C, 1) | ||
|
||
# create an augmented system to balance the whole system at once | ||
metasys = [sys.A sys.B; sys.C zeros(p, m)] | ||
Comment on lines
+603
to
+604
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are using two terms here, both augmented and meta system. I seem to remember that it is instead typically called a packed representation? I think that is the term used in the Essentials of Robust Control by Zhou & Doyle, I think it should be okay to just call the packed system representation |
||
S, P, B = balance(metasys) | ||
|
||
# reconstruct A, B and C by taking slices of the balanced metasystem | ||
bal_metasys = P\B*P # undo permutation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to use |
||
A = bal_metasys[1:n, 1:n] | ||
B = bal_metasys[1:n, n+1:end] | ||
C = bal_metasys[n+1:end, 1:n] | ||
return ST(A, B, C, sys.D, sys.timeevol) | ||
end | ||
|
||
""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,11 +70,13 @@ syst = similarity_transform(sys, Tr) | |
@test sys.B ≈ Tr*syst.B | ||
@test sys.C*Tr ≈ syst.C | ||
|
||
nsys, T = prescale(sys) | ||
@test isdiag(nsys.A) | ||
@test T*nsys.A ≈ sys.A*T | ||
@test T*nsys.B ≈ sys.B | ||
@test nsys.C ≈ sys.C*T | ||
nsys = prescale(sys) | ||
@test pole(nsys) ≈ pole(sys) | ||
n, m = size(sys.B) | ||
p = size(sys.C, 1) | ||
M = [nsys.A nsys.B; nsys.C zeros(p, m)] | ||
M2 = [sys.A sys.B; sys.C zeros(p, m)] | ||
@test cond(M) <= cond(M2) | ||
Comment on lines
+73
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be reasonable with quite a few more tests. For example to see that the system dynamics isn't changed by the prescaling. E.g. by comparing the frequency response of a MIMO systems before and after. |
||
|
||
sys = ss([1 0.1; 0 1], ones(2), [1. 0], 0) | ||
sysi = ControlSystems.innovation_form(sys, I, I) | ||
|
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.
Do you have any reference to where this method is discussed?