Skip to content

Commit 32dd101

Browse files
committed
Add SOC materials for class07 (new folder soc-materials)
1 parent 7b4d171 commit 32dd101

12 files changed

+9930
-0
lines changed

class07/soc-materials/Kalman Filtering.html

Lines changed: 19 additions & 0 deletions
Large diffs are not rendered by default.

class07/soc-materials/Kalman_Filtering.jl

Lines changed: 1400 additions & 0 deletions
Large diffs are not rendered by default.

class07/soc-materials/LQG_Control.jl

Lines changed: 1241 additions & 0 deletions
Large diffs are not rendered by default.

class07/soc-materials/Linear Quadratic Guassian.html

Lines changed: 19 additions & 0 deletions
Large diffs are not rendered by default.

class07/soc-materials/Manifest.toml

Lines changed: 2696 additions & 0 deletions
Large diffs are not rendered by default.

class07/soc-materials/Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[deps]
2+
ControlSystems = "a6e380b2-a6ca-5380-bf3e-84a91bcd477e"
3+
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
4+
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
5+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
6+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

class07/soc-materials/Robust Control.html

Lines changed: 19 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 364 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,364 @@
1+
### A Pluto.jl notebook ###
2+
# v0.20.19
3+
4+
using Markdown
5+
using InteractiveUtils
6+
7+
# ╔═╡ 6527df00-c3c9-11f0-13e2-7d05788e7333
8+
md"""
9+
# Robust Control
10+
### Ensuring stability and performance under **model uncertainty**, **unmodeled dynamics**, and **external disturbances**
11+
12+
In real-world systems including temperature control systems, vehicles, chemical processes, and financial models, our mathematical models are *never* exact.
13+
Parameters drift, sensors degrade, actuators saturate, and disturbances appear in unexpected ways.
14+
15+
**Robust control** is the branch of control theory that explicitly accounts for these uncertainties and guarantees acceptable performance *even under worst-case conditions*.
16+
17+
This notebook walks through:
18+
19+
1. What model uncertainty means and how it is represented
20+
2. Stochastic vs worst-case philosophies
21+
3. LQG and stochastic robustness
22+
4. H∞ (H-infinity) worst-case robustness
23+
5. μ-synthesis and structured uncertainty
24+
6. Robust trajectory optimization
25+
7. A temperature-control example contrasting LQG and H∞ controllers
26+
"""
27+
28+
29+
# ╔═╡ efd5146a-fe33-48fb-9048-e60b9373a461
30+
md"""
31+
# ## 1. What Is Model Uncertainty?
32+
33+
Even if we write a model
34+
35+
$x_{k+1} = A x_k + B u_k$
36+
37+
we know that in reality:
38+
39+
- The matrix **A** is not exact
40+
- The matrix **B** is not exact
41+
- There are disturbances, offsets, nonlinearities, bias, noise
42+
43+
This leads to a more realistic model:
44+
45+
$x_{k+1} = (A + \Delta A)x_k + (B + \Delta B)u_k + w_k$
46+
47+
Where:
48+
49+
- **$ΔA, ΔB$**: unknown deviations from the nominal model
50+
- **$w_k$**: disturbance or process noise
51+
- **$v_k$**: measurement noise (if sensors are used)
52+
53+
The goal of robust control is to design a controller **u_k** that works for all allowed $ΔA, ΔB, w_k$.
54+
55+
Different robust-control frameworks differ by **how uncertainty is assumed to behave**.
56+
"""
57+
58+
59+
# ╔═╡ 3fb8940e-3ef7-43b0-90bc-38bd320120e7
60+
md"""
61+
# 2. Two Philosophies of Robustness
62+
63+
Robust control is centered around two fundamentally different interpretations of uncertainty:
64+
65+
---
66+
67+
## **2.1 Stochastic Approaches (example: LQG)**
68+
These assume that uncertainties behave like **random variables** with known distributions.
69+
70+
Example assumptions:
71+
72+
- Process noise \($w_k \sim \mathcal{N}(0, Q)$\)
73+
- Measurement noise \($v_k \sim \mathcal{N}(0, R)$\)
74+
75+
You design:
76+
77+
- A **Kalman filter** to optimally estimate the state from noisy measurements
78+
- An **LQR** controller to compute optimal control inputs
79+
80+
Together they form the **LQG controller**.
81+
82+
### Strengths
83+
- Optimal when noise statistics are correct
84+
- Very strong performance in predictable environments
85+
86+
### Weaknesses
87+
- Not robust to **worst-case disturbances**
88+
- Sensitive when the real noise distribution deviates from assumptions
89+
90+
---
91+
92+
## **2.2 Worst-Case Approaches (example: H∞)**
93+
Here uncertainty is treated as **an adversary** that tries to degrade performance.
94+
95+
Instead of assuming a distribution, we assume a **bound**:
96+
97+
98+
$\|\Delta A\| \le \bar{\Delta A}, \quad \|\Delta B\| \le \bar{\Delta B}, \quad \|w_k\| \le w_{\max}$
99+
100+
The controller is designed so that:
101+
102+
- Even the **worst choice** of disturbances cannot destabilize the system
103+
- Performance measures remain within acceptable bounds
104+
105+
### Strengths
106+
- Guaranteed performance under worst conditions
107+
- Robust to modeling errors
108+
109+
### Weaknesses
110+
- More conservative
111+
- Can sacrifice performance during nominal conditions
112+
"""
113+
114+
115+
# ╔═╡ bb01c629-ffd9-4d40-b505-0a76f779f500
116+
md"""
117+
# 3. Detailed Stochastic Example: LQG Modeling
118+
119+
We begin with a discrete-time stochastic system:
120+
121+
$x_{k+1} = A x_k + B u_k + w_k,
122+
\quad w_k \sim \mathcal{N}(0, Q)$
123+
124+
and noisy observations:
125+
126+
$y_k = C x_k + v_k,
127+
\quad v_k \sim \mathcal{N}(0, R)$
128+
129+
### Inside LQG:
130+
131+
1. **Kalman filter** produces an optimal state estimate
132+
2. **LQR** computes
133+
$u_k = -K \hat{x}_k$
134+
3. LQG = LQR + Kalman filter
135+
136+
This is conceptually robust to *random* noise, but not robust to **bounded, structured uncertainties** in A or B.
137+
"""
138+
139+
140+
# ╔═╡ fd8746c9-42ca-4ecb-8040-17960982b533
141+
md"""
142+
# 4. Worst-Case Formulation: H∞ Control
143+
144+
### Core idea:
145+
The controller competes against an adversarial disturbance that tries to maximize the output energy.
146+
147+
We want the induced L2 gain from disturbance input \($w$\) to regulated output \($z$\) to satisfy:
148+
149+
150+
$\|T_{zw}\|_\infty < \gamma$
151+
152+
Where:
153+
154+
- \($T_{zw}$\) is the closed-loop transfer function
155+
- \($\gamma$\) is the worst-case amplification bound
156+
157+
Smaller \($\gamma$\) = more robust to disturbances.
158+
159+
---
160+
161+
## State-space model:
162+
163+
$\dot{x} = A x + B_u u + B_w w$
164+
165+
$z = C_z x + D_{zu} u + D_{zw} w$
166+
167+
$y = C_y x + D_{yu} u + D_{yw} w$
168+
169+
The H∞ control problem finds a controller \($u(t)$\) that makes the system robust against the worst possible disturbance input \($w(t)$\).
170+
171+
This yields:
172+
173+
- Guaranteed stability under model uncertainty
174+
- Guaranteed bound on performance degradation
175+
"""
176+
177+
178+
# ╔═╡ 35ae220e-f0e8-407c-b957-5ebf869c0c47
179+
md"""
180+
# ## 5. μ-Synthesis: Handling Structured Uncertainty
181+
182+
### Why H∞ is not enough
183+
H∞ is great for unknown but “norm-bounded” uncertainties (i.e., “anything with size < δ”).
184+
But many real systems have **structured uncertainty**, e.g.:
185+
186+
- Sensor bias
187+
- Actuator saturation
188+
- Temperature-dependent parameters
189+
- Known block-diagonal uncertainty structures
190+
- Gain drift only in one channel
191+
192+
H∞ cannot capture these structures.
193+
194+
---
195+
196+
## μ-synthesis solves:
197+
198+
$\mu < 1$
199+
200+
where **μ** (mu) is the structured singular value.
201+
202+
### What μ measures:
203+
It measures whether structured uncertainty Δ can destabilize the system:
204+
205+
- If μ < 1 → stable under all allowed Δ
206+
- If μ ≥ 1 → system might become unstable
207+
208+
---
209+
210+
## D–K Iteration (the μ-synthesis algorithm)
211+
212+
### Step 1: **D-step**
213+
Compute a scaling matrix \($D$\) that upper-bounds the effect of structured uncertainty.
214+
215+
### Step 2: **K-step**
216+
Design an H∞ controller using that scaling.
217+
218+
### Repeat:
219+
D → K → D → K
220+
until convergence.
221+
222+
μ-synthesis produces controllers that are:
223+
224+
- More robust than H∞
225+
- Less conservative
226+
- Explicitly account for structured uncertainty
227+
"""
228+
229+
230+
# ╔═╡ 82075bd8-4908-4b4e-9f7b-b616386d59a5
231+
md"""
232+
# 6. Robust Trajectory Optimization
233+
234+
Worst-case robust control can be formulated as a **min-max game**:
235+
236+
$\min_{u_{0:T}} \max_{\Delta A, \Delta B, w_{0:T}}
237+
\sum_{t=0}^{T} x_t^\top Q x_t + u_t^\top R u_t$
238+
239+
subject to:
240+
241+
$x_{t+1} = (A + \Delta A)x_t + (B + \Delta B)u_t + w_t$
242+
243+
with bounds:
244+
245+
$\|\Delta A\| \le \bar{\Delta A}, \quad
246+
\|\Delta B\| \le \bar{\Delta B}, \quad
247+
\|w_t\| \le w_{\max}$
248+
249+
Interpretation:
250+
251+
- **Controller (minimizer)** chooses u(t) to keep performance good
252+
- **Nature (maximizer)** chooses worst possible disturbance
253+
254+
This viewpoint unifies many robust control methods:
255+
256+
- Online robust MPC
257+
- H∞ design
258+
- Adversarial learning
259+
- Distributionally-robust optimization
260+
"""
261+
262+
263+
# ╔═╡ 3e1b18e2-06b6-4299-8d58-202c99d399ef
264+
md"""
265+
# 7. Temperature Control Example: LQG vs H∞
266+
267+
We consider a scalar thermal process:
268+
269+
270+
$\frac{dx}{dt} = -a(x - x_\text{set}) + b u + w_{\text{process}}$
271+
272+
where:
273+
274+
- \($x$\): system temperature
275+
- \($x_\text{set}$\): desired temperature
276+
- \($a > 0$\): thermal dissipation rate
277+
- \($b$\): actuator effectiveness (heater/cooler)
278+
- \($w_{\text{process}}$\): external heat disturbances
279+
280+
### Disturbance model:
281+
282+
$w_{\text{process}}(t) = 2\sin(0.5t) + \text{Gaussian noise}$
283+
284+
### Measurement:
285+
$y = x + v_{\text{meas}}, \quad v_{\text{meas}} \sim \mathcal{N}(0, 15^2)$
286+
287+
---
288+
289+
## **LQG Controller**
290+
291+
- Assumes noise is Gaussian with known covariance
292+
- Kalman filter estimates the temperature
293+
- LQR regulates temperature
294+
295+
**Good performance under expected/stochastic conditions**.
296+
297+
---
298+
299+
## **H∞ Controller**
300+
301+
- Assumes worst-case disturbance with bounded magnitude
302+
- Gains chosen to attenuate worst disturbances
303+
- No assumption of sinusoid or Gaussian behavior
304+
305+
**More conservative, but guaranteed to perform well under extreme disturbance conditions.**
306+
307+
---
308+
309+
## Outcome Comparison:
310+
311+
### LQG:
312+
- Excellent tracking when noise is reasonably small
313+
- Vulnerable to persistent sinusoidal disturbances
314+
- Not robust to model mismatch (e.g., actuator weakening)
315+
316+
### H∞:
317+
- Very stable under persistent oscillations
318+
- Handles sudden changes and worst-case heat pulses
319+
- Slightly worse nominal tracking due to conservative nature
320+
"""
321+
322+
323+
# ╔═╡ bcc3e98a-d94d-4d1c-945c-11f770b12bae
324+
md"""
325+
---
326+
# Final Message
327+
This notebook provides an introduction to robust control, covering:
328+
329+
- Stochastic vs worst-case uncertainty
330+
- LQG, H∞, μ-synthesis
331+
- Structured vs unstructured uncertainty
332+
- Min-max robust trajectory optimization
333+
- Realistic temperature control example
334+
"""
335+
336+
337+
# ╔═╡ 00000000-0000-0000-0000-000000000001
338+
PLUTO_PROJECT_TOML_CONTENTS = """
339+
[deps]
340+
"""
341+
342+
# ╔═╡ 00000000-0000-0000-0000-000000000002
343+
PLUTO_MANIFEST_TOML_CONTENTS = """
344+
# This file is machine-generated - editing it directly is not advised
345+
346+
julia_version = "1.11.6"
347+
manifest_format = "2.0"
348+
project_hash = "da39a3ee5e6b4b0d3255bfef95601890afd80709"
349+
350+
[deps]
351+
"""
352+
353+
# ╔═╡ Cell order:
354+
# ╠═6527df00-c3c9-11f0-13e2-7d05788e7333
355+
# ╠═efd5146a-fe33-48fb-9048-e60b9373a461
356+
# ╠═3fb8940e-3ef7-43b0-90bc-38bd320120e7
357+
# ╠═bb01c629-ffd9-4d40-b505-0a76f779f500
358+
# ╠═fd8746c9-42ca-4ecb-8040-17960982b533
359+
# ╠═35ae220e-f0e8-407c-b957-5ebf869c0c47
360+
# ╠═82075bd8-4908-4b4e-9f7b-b616386d59a5
361+
# ╠═3e1b18e2-06b6-4299-8d58-202c99d399ef
362+
# ╠═bcc3e98a-d94d-4d1c-945c-11f770b12bae
363+
# ╟─00000000-0000-0000-0000-000000000001
364+
# ╟─00000000-0000-0000-0000-000000000002

0 commit comments

Comments
 (0)