A Controller That Learns the Patient

A patient monitor showing depth of hypnosis beside a propofol infusion pump

Open the Closed-Loop Anesthesia Depth Control app

Advanced Control Exercise 10 of 30 in Estimation · All exercises · Time: 15 minutes

Before induction nobody knows how sensitive this patient is to propofol, and here the patient needs half of what the population model expects. A PI loop tuned for the average patient overdoses. A model predictive controller starts with the same wrong belief, but it re-estimates the patient's sensitivity from the monitor as it goes. This exercise measures what the learning is worth, and what the learned number does and does not mean.

Learning Outcomes

  • Explain recursive least squares as estimation one sample at a time, with a forgetting factor.
  • Compare a fixed-tuning PI loop, an adaptive MPC and the same MPC without adaptation on a mismatched patient.
  • Explain why an adaptive estimate needs excitation and bounds, and what makes a learned gain move without a real change.

Book Chapter

Control of Biological Systems and Human Performance (Volume 19), Chapter 3, Closed-Loop Anesthesia Simulator for Model Inversion with Feedback Correction. Read the chapter, open the PDF, or watch the lecture slides.

Theory in Brief

Propofol reaches the brain's effect site with a first-order lag, and the monitor's index falls along a Hill curve:

$$\frac{dC_e}{dt} = k_{e0}\left(C_p - C_e\right), \qquad \mathrm{BIS} = E_0 - E_{max} \frac{\left(g\,C_e/C_{50}\right)^{\gamma}}{1 + \left(g\,C_e/C_{50}\right)^{\gamma}}$$

The unknown potency `g` scales the effect-site concentration; the app's "sensitivity" is `1/g`, the multiplier on `C_{50}`. A value of 0.50 means half the population's concentration gives the same effect: a patient twice as sensitive. A rising value means the patient looks less sensitive. Recursive least squares updates the estimate `\hat\theta = \hat g` each sample from the regressor `\varphi_k`, the derivative of the predicted index with respect to `g`:

$$\begin{gathered} K_k = \frac{P_{k-1}\varphi_k}{\lambda + \varphi_k^T P_{k-1}\varphi_k}, \\ \hat\theta_k = \hat\theta_{k-1} + K_k\left(y_k - \hat y_k\right), \\ P_k = \frac{P_{k-1} - K_k\varphi_k^T P_{k-1}}{\lambda} \end{gathered}$$

The forgetting factor `\lambda < 1` gives a memory of about `1/(1-\lambda)` samples. Forgetting only while the input excites the plant, and bounding `\hat g`, keep `P` from growing without limit on quiet data. Every 15 s the MPC plans the infusion over 10 minutes on the curve with `\hat g`, and a fast output bias removes what remains.

Model: Physics-based pharmacokinetics and pharmacodynamics with one patient-specific parameter learned online.
Decision: The propofol infusion rate every 15 s, from an MPC that plans 10 minutes ahead on the learned curve.
Learning: Recursive least squares is online learning of one parameter; the plan uses it immediately.

Exercise

Read 2 min · Predict 1 min · Run 7 min · Explain 3 min · Check your AI 2 min.

Predict. The patient needs half the propofol the model expects. Predict how deep a PI loop tuned for the average patient takes this patient during induction, and whether an MPC that starts with the same wrong model does better. What will its learned sensitivity read after the surgeon makes the incision at 30 min?

Run the Closed-Loop Anesthesia Depth Control app. Use the fastest speed, 20 min/s, and press Run again to pause at the times in each step.

  1. Open 12 · A patient twice as sensitive, and a controller that learns it. Set Control structure to Closed loop, set the speed to 20 min/s, press Run and pause at 30 min. Read In the band and IAE, and the lowest index on the Depth of hypnosis strip.
  2. Press Reset, set Control structure to MPC, and run to 30 min. Read the same, and the learned sensitivity on the MPC strip at 2 min and at 30 min.
  3. Run on to 45 min, past the incision at 30 min, and read the learned sensitivity again.
  4. Press Reset, set Learn the gain to Off (Advanced), and run to 30 min. Read the same tiles.

Explain.

  1. Of the MPC's improvement over the PI loop, how much comes from the plan and how much from the learning? Use the run without learning.
  2. The learned sensitivity rises after the incision although the patient's true sensitivity never changes. What is it learning, and why is that not an error?

Generative AI Learning

"An adaptive controller learns a patient's drug sensitivity with recursive least squares. After a surgical stimulus the learned sensitivity more than doubles, though the patient has not changed. Is the estimator broken?"

Check the answer against your run: A good answer says a one-parameter model absorbs every unmodeled effect into that parameter, here the stimulus raising the index, and that the plan still benefits. Your step 3 reading is the test. The assistant is your tutor and reviewer; you answer for every claim you turn in.

What to Turn In

A three-row table (PI, adaptive MPC, MPC without learning) with In the band, IAE and the lowest index, the learned sensitivity at 2, 30 and 45 min, your written prediction, and three sentences answering the questions.

The PI loop, tuned for a patient twice as hard to put to sleep, takes this one down to an index of 27.7 and spends 4.0 min below 40 in the first half hour; In the band reads 83 % and IAE 164. The adaptive MPC starts with the same wrong model, but its learned sensitivity is already 0.53 at 2 min against the true 0.50. It touches 39.5, spends 0.7 min below 40, and reads 94 % in the band with an IAE of 73.

Without learning, the same plan corrected only by its output bias reaches 33.9, spends 2.4 min below 40, and reads 88 % with an IAE of 94. The plan with its bias removes about 40 % of the PI loop's IAE, and the learned gain about a fifth of the rest; the time below 40 falls from 2.4 to 0.7 min.

At 30 min the learned sensitivity is 0.50; at 45 min, after the incision, it reads 1.25. Stimulation raises the index, and a model with one parameter can only explain a higher index as a less sensitive patient, so the estimate moves. It is not wrong as a description of the patient under stimulation, and the plan uses it to give more drug when more is needed. It is wrong as a measure of the drug's potency, which is why the estimate is bounded and forgets only while the input excites the plant.

Measured with the app build of December 3, 2026 by a scripted replay of the steps above. Numbers that no tile shows come from the replay's record; your readings from the trends will be close. A later app release may move the last digit.

Artificial Pancreas adapts a model in GEKKO. Write a scalar RLS in Python for `y_k = \theta u_k + v_k` with `\theta` stepping from 1 to 2 halfway, and plot `\hat\theta` for `\lambda = 1`, 0.98 and 0.9. Then hold `u_k` constant in the second half and watch `P` grow with `\lambda < 1`: that is why the app forgets only while the input excites.

Related

References

  1. Hedengren, J. D. (ed.), Control of Biological Systems and Human Performance, Volume 19 of Interactive Control Engineering, Chapter 3, "Closed-Loop Anesthesia Simulator for Model Inversion with Feedback Correction", pp. 54–85, Advanced Process Solutions, 2026. PDF (CC BY 4.0).
  2. Åström, K. J., Wittenmark, B., Adaptive Control, 2nd ed., Addison-Wesley, 1995, Chapter 2.
  3. Ionescu, C. M., De Keyser, R., Torrico, B. C., De Smet, T., Struys, M. M. R. F., Normey-Rico, J. E., Robust predictive control strategy applied for propofol dosing using BIS as a controlled variable during anesthesia, IEEE Transactions on Biomedical Engineering 55(9), 2161–2170, 2008.

Course Information

TCLab

Project

Applications

Advanced Control Exercises

Exams

Modeling

Machine Learning

Estimation

Control

Reinforcement Learning

Related Courses

Admin