Prof. Dr. Sebastian Peitz
Chair of Safe Autonomous Systems, TU Dortmund
| Chapter | Topic | Content |
|---|---|---|
| Basics & tabular methods | ||
| 1-5 | Bandits, MDPs, Dynamic Programming, Monte Carlo, TD Learning | RL basics in finite dimensions |
| Deep-learning-based methods | ||
| 6-13 | DQN, policy gradients, actor-critic, PPO/SAC, exploration | Deep RL from basics to modern algorithms |
| Model-Based Control | ||
| 14 | Optimal control & feedback control | How to do control when we know the model |
| 15 | Model-based reinforcement learning | RL with known and learned models |
| Advanced Topics |
for \(t=0,1,2,\ldots\)
\(\quad\) Sample action \(a_t \sim \pi(s_t)\)
\(\quad\) Observe \((r_t,s_{t+1})\) from environment
\(\quad\) Update \(Q\) given \((s_t,a_t,r_t,s_{t+1})\): \[Q(s_t,a_t) \gets Q(s_t,a_t) + \alpha \left[r_t + \gamma \max_a Q(s_{t+1},a)- Q(s_t,a_t)\right]\] \(\quad\) Update policy \(\pi = \epsilon\)-greedy\((Q)\)
for \(t=0,1,2,\ldots\)
\(\quad\) Sample action \(a_t \sim \pi(s_t)\)
\(\quad\) Use model to create sample \((r_t,s_{t+1})\)
\(\quad\) Update \(Q\) given \((s_t,a_t,r_t,s_{t+1})\): \[Q(s_t,a_t) \gets Q(s_t,a_t) + \alpha \left[r_t + \gamma \max_a Q(s_{t+1},a)- Q(s_t,a_t)\right]\] \(\quad\) Update policy \(\pi = \epsilon\)-greedy\((Q)\)
Unified view: create experience using a model \(\quad\Rightarrow\quad\) 
Easiest way to create a model: Remember past \(a\), \(s\rightarrow s'\) and \(r\).
loop forever:
\(\quad\) Sample \(a \sim \pi\agivenb{\cdot}{s,Q}\) (e.g. \(\epsilon\)-greedy)
\(\quad\) Take action \(a\), observe reward \(r\) and next state \(s'\)
\(\quad\) \(Q(s,a) \gets Q(s,a) + \alpha \left[r + \gamma \max_{\hat a} Q(s',\hat a)- Q(s,a)\right]\)
\(\quad\) Add transition to our \(\mathsf{model}\) of previous experiences
\(\quad\) for \(i=1,\ldots,n\):
\(\quad\quad\) \(s \gets\) random previous state
\(\quad\quad\) \(a \gets\) random previous action
\(\quad\quad\) \(r,s' \gets\) \(\mathsf{model}(s,a)\)
\(\quad\quad\) \(Q(s,a) \gets Q(s,a) + \alpha \left[r + \gamma \max_{\hat a} Q(s',\hat a)- Q(s,a)\right]\)
Why does this even make sense? Aren’t we just doing the exact same calculation?
\(\Rightarrow\) our approximation of \(Q(s,a)\) may be better later on!
\(\Rightarrow\) sparse rewards get “time to travel” through the environment!
In the previous maze example, the environment was perfect and the transitions deterministic.
\(\textcolor{green}{\mathbf{+}\text{ If the old model is optimistic, there is a good chance!}}\)
\(\textcolor{red}{\mathbf{-}\text{ If the old model is pessimistic, it is very hard to find new opportunities!}}\)
Two changes can help our simple Dyna-\(Q\) algorithm to foster exploration.
loop forever:
\(\quad\qquad\) (Learning / Experience)
\(\quad\) Sample action \(a\) \(\epsilon\)-greedily
\(\quad\) Take action \(a\), observe \(r\) and \(s'\)
\(\quad\) \(Q(s,a) \gets Q(s,a) + \alpha \left[r + \gamma \max_{\hat a} Q(s',\hat a)- Q(s,a)\right]\)
\(\quad\) Add transition to our \(\mathsf{model}\)
\(\quad\qquad\qquad\) (Planning)
\(\quad\) for \(i=1,\ldots,n\):
\(\quad\quad\) \(s \gets\) random previous state
\(\quad\quad\) \(a \gets\) random previous action
\(\quad\quad\) \(\hat r,s' \gets\) \(\mathsf{model}(s,a)\)
\(\quad\quad\) \(Q(s,a) \gets Q(s,a) + \alpha \left[\hat r + \gamma \max_{\hat a} Q(s',\hat a)- Q(s,a)\right]\)
initialize: \(Q(s,a)\), \(\mathsf{model}(s,a)\) for all \(s,a\),
empty queue \(\Qc\), threshold \(\xi>0\).
loop forever:
\(\quad\) \(a \sim \pi\agivenb{\cdot}{s,Q}\) (e.g. \(\epsilon\)-greedy)
\(\quad\) Take action \(a\), observe reward \(r\) and next state \(s'\)
\(\quad\) Add transition to our \(\mathsf{model}\)
\(\quad\) \(P \gets \left[r + \gamma \max_{\hat a} Q(s',\hat a)- Q(s,a)\right]\)
\(\quad\) if \(P>\xi\) then insert \((s,a)\) into \(\Qc\) with priority \(P\)
\(\quad\) loop: Repeat \(n\) times while \(\Qc\) is not empty
\(\quad\quad\) \((s,a) = \arg\max_P \Qc\)
\(\quad\quad\) \(r,s' \gets\) \(\mathsf{model}(s,a)\)
\(\quad\quad\) \(Q(s,a) \gets Q(s,a) + \alpha \left[r + \gamma \max_{\hat a} Q(s',\hat a)- Q(s,a)\right]\)
\(\quad\quad\) for \(\forall(\bar s, \bar a)\) predicted to lead to s:
\(\quad\quad\quad\) \(\bar r \gets\) predicted reward for \((\bar s, \bar a, s)\)
\(\quad\quad\quad\) \(P \gets \left[\bar r + \gamma \max_{\hat a} Q(s,\hat a)- Q(\bar s,\bar a)\right]\)
\(\quad\quad\quad\) if \(P>\xi\) then insert \((\bar s,\bar a)\) into \(\Qc\) with priority \(P\)
When AlphaGo looks at a new board state during a simulation, this is what happens dynamically:
\[ \begin{align*} a_t &= \arg\max_a \cbracket{Q(s, a) + U(s, a)}\\ U(s, a) &= c_{\text{puct}} \cdot P(s, a) \cdot \frac{\sqrt{\sum_b N(s, b)}}{1 + N(s, a)} \end{align*}\]
The AlphaZero framework (Silver et al. 2017) beat AlphaGo 100-0 (!) and can play multiple games (Go, Chess, Shogi).

đź’ˇ \(\alpha_\theta\) represents the final policy (\(f_\theta\) plus MCTS) after training is complete.
If we do not have a model, but still want to use model-based RL, we can try to learn a model from experience.
Wolrd model (Source: Danijar Hafner’s Google Research blog post).
đź’ˇ In the mathematics / dynamical systems communities, world models have been studied for a very long time under the term surrogate models.

Results from (Plotzki and Peitz 2026)
Similar to DPC, we can also use world models in the MPC context: