Skip to content

Commit 1ffc334

Browse files
add suboptimal controller generation option to hinfsyn in control/robust.py
1 parent 2435a6a commit 1ffc334

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

control/robust.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def h2syn(P, nmeas, ncon):
8585
return K
8686

8787

88-
def hinfsyn(P, nmeas, ncon):
88+
def hinfsyn(P, nmeas, ncon, gamTry):
8989
# TODO: document significance of rcond
9090
"""H-infinity control synthesis for plant P.
9191
@@ -97,6 +97,8 @@ def hinfsyn(P, nmeas, ncon):
9797
Number of measurements (input to controller).
9898
ncon : int
9999
Number of control inputs (output from controller).
100+
gamTry : int, optional
101+
Target performance level (default = None).
100102
101103
Returns
102104
-------
@@ -137,7 +139,10 @@ def hinfsyn(P, nmeas, ncon):
137139
>>> P = ct.interconnect([P11, P12, P21, P22], inplist=['w', 'u'], outlist=['z', 'y'])
138140
139141
>>> # Synthesize Hinf optimal stabilizing controller
140-
>>> K, CL, gam, rcond = ct.hinfsyn(P, nmeas=1, ncon=1)
142+
>>> K_opt, CL_opt, gam_opt, rcond_opt = ct.hinfsyn(P, nmeas=1, ncon=1)
143+
144+
>>> # Synthesize suboptimal controller with better numerical properties
145+
>>> K, CL, gam, rcond = ct.hinfsyn(P, nmeas=1, ncon=1, gamTry=1.1*gam_opt)
141146
>>> T = ct.feedback(G, K, sign=1)
142147
>>> all(T.poles() < 0)
143148
True
@@ -156,8 +161,13 @@ def hinfsyn(P, nmeas, ncon):
156161
n = np.size(P.A, 0)
157162
m = np.size(P.B, 1)
158163
np_ = np.size(P.C, 0)
159-
gamma = 1.e100
160-
out = sb10ad(n, m, np_, ncon, nmeas, gamma, P.A, P.B, P.C, P.D)
164+
if gamTry == None:
165+
gamma = 1.e100,
166+
job = 3
167+
else:
168+
gamma = gamTry
169+
job = 4
170+
out = sb10ad(n, m, np_, ncon, nmeas, gamma, P.A, P.B, P.C, P.D, job)
161171
gam = out[0]
162172
Ak = out[1]
163173
Bk = out[2]

0 commit comments

Comments
 (0)