RL lecture notes (archive)3 / 7

Lesson 3

RL 8-10

These are my original lecture notes, kept as they were. They're being rebuilt into the Reinforcement learning course.

Lecture 8: Generalization in Reinforcement Learning

1. The Need for Generalization

Why Generalization Matters

In standard RL, we treat each state independently. For problems with millions of states, this is impractical because:

  • We can't visit every state infinitely many times
  • Learning is slow—reward information propagates one step at a time
  • Memory requirements become prohibitive

Key Insight: Generalization lets us leverage learning from states we've visited to make predictions about states we haven't visited (or visited rarely).

Analogy

Think of fitting a curve through data points: you have 5 observations (states you've visited), but the curve lets you predict values at any point on the line (states you haven't visited).


2. Features and State Representation

From States to Features

Instead of treating states as opaque identifiers (state 1, state 2, ...), we describe them using features—measurable properties that capture what's important.

Example: Taxi Domain

  • State space: ~500 states
  • Possible features:
    • X-coordinate of taxi
    • Y-coordinate of taxi
    • Is taxi near a wall?
    • Distance to passenger
    • Distance to destination

Inductive Bias

Different feature representations create different inductive biases—they make some states appear more similar than others.

Example: If we use "distance to passenger" as a feature:

  • A taxi 2 steps from a passenger looks the same regardless of absolute position
  • Moving both taxi and passenger together preserves similarity

Critical Point: The choice of features determines what can be learned efficiently. Good features are:

  1. Computationally efficient to extract from states
  2. Value informative — correlated with actual state values

3. What Can We Approximate?

Three main functions in RL that could benefit from function approximation:

FunctionMappingNotes
Policy π\piS→AS \rightarrow ADirect but hard to learn
Value Function V,QV, QS→RS \rightarrow \mathbb{R} or S×A→RS \times A \rightarrow \mathbb{R}Most studied approach
Model T,RT, RS×A→S′S \times A \rightarrow S', S×A→RS \times A \rightarrow \mathbb{R}Natural supervised learning setting

Focus: Most research has focused on value function approximation.


4. Value Function Approximation Framework

General Form

Represent the Q-function using parameters w\mathbf{w}:

Q(s,a)=f(ϕ(s),wa)Q(s, a) = f(\phi(s), \mathbf{w}^a)

Where:

  • ϕ(s)\phi(s) = feature vector for state ss
  • wa\mathbf{w}^a = weight parameters for action aa
  • ff = function combining features and weights

General Update Rule

Given experience tuple (s,a,r,s′)(s, a, r, s'):

wia←wia+α⋅[r+γmax⁡a′Q(s′,a′)−Q(s,a)]⏟TD Error⋅∂Q(s,a)∂wia⏟Gradientw_i^a \leftarrow w_i^a + \alpha \cdot \underbrace{\left[ r + \gamma \max_{a'} Q(s', a') - Q(s, a) \right]}_{\text{TD Error}} \cdot \underbrace{\frac{\partial Q(s,a)}{\partial w_i^a}}_{\text{Gradient}}

Interpretation:

  • TD Error: How wrong was our prediction? (target - prediction)
  • Gradient: How much does this weight influence the Q-value?
  • We move weights to reduce prediction error

Bootstrapping Warning ⚠️

Unlike supervised learning where targets (y∗y^*) are "ground truth," here we're using our own predictions to generate targets. This can cause instability.


5. Linear Value Function Approximation

The Linear Form

The Q-function is a weighted sum of features:

Q(s,a)=∑i=1nwia⋅ϕi(s)=wa⋅ϕ(s)Q(s, a) = \sum_{i=1}^{n} w_i^a \cdot \phi_i(s) = \mathbf{w}^a \cdot \phi(s)

Where:

  • ϕi(s)\phi_i(s) = value of feature ii for state ss
  • wiaw_i^a = weight for feature ii and action aa
  • This is simply a dot product between feature and weight vectors

Gradient for Linear Case

For linear function approximation, the gradient is trivially:

∂Q(s,a)∂wia=ϕi(s)\frac{\partial Q(s,a)}{\partial w_i^a} = \phi_i(s)

Quiz Answer: The derivative of Q(s,a)=∑jwjϕj(s)Q(s,a) = \sum_j w_j \phi_j(s) with respect to wiw_i is just ϕi(s)\phi_i(s) (the coefficient of wiw_i).

Complete Linear Update Rule

wia←wia+α⋅[r+γmax⁡a′Q(s′,a′)−Q(s,a)]⋅ϕi(s)w_i^a \leftarrow w_i^a + \alpha \cdot \left[ r + \gamma \max_{a'} Q(s', a') - Q(s, a) \right] \cdot \phi_i(s)


6. Successes and Failures

Notable Successes

SystemDomainApproach
TD-Gammon (Tesauro)Backgammon3-layer neural network
DQN (DeepMind)Atari gamesDeep convolutional networks
CMAC (Sutton)Various controlTile coding

Why Backgammon Worked: The game's inherent randomness (dice) forces exploration and creates smooth value functions where similar states have similar values.

The Danger of Bootstrapping

Problem: We're using our own predictions as training targets. If predictions start drifting, they can spiral out of control.

Observed Pattern: Systems often learn well initially, then enter "death spirals" where errors compound.


7. Baird's Counterexample (Why Things Can Go Wrong)

The Setup

A deceptively simple MDP designed to break linear function approximation:

States: 7 states (1-6 plus state 7) Actions: One action per state Transitions: States 1-6 all go to state 7; state 7 loops to itself Rewards: Zero everywhere

Optimal Value Function: V(s)=0V(s) = 0 for all states (trivial!)

Feature Representation

Stateϕ0\phi_0ϕ1\phi_1ϕ2\phi_2ϕ3\phi_3ϕ4\phi_4ϕ5\phi_5ϕ6\phi_6ϕ7\phi_7
112000000
210200000
...........................
770000001

Key Properties:

  • Near-tabular (almost one feature per state)
  • The optimal value function (V=0V = 0 everywhere) is representable
  • In fact, infinitely many weight settings give the correct answer

What Goes Wrong

With round-robin updates (γ=0.9\gamma = 0.9, α=0.1\alpha = 0.1):

  1. Updates from states 1-6 → 7 pump up weights (value of 7 is larger)
  2. Update from 7 → 7 brings weights down, but not enough
  3. Weights diverge to infinity!

The Lesson: Even with linear function approximation, convergence is NOT guaranteed. The combination of:

  • Function approximation
  • Bootstrapping
  • Off-policy learning

...creates the "deadly triad" that can cause divergence.


8. Averagers: A Well-Behaved Alternative

Definition

An averager is a function approximator where the value at any state is a convex combination of values at anchor points (basis states).

V(s)=∑sb∈Basisc(s,sb)⋅V(sb)V(s) = \sum_{s_b \in \text{Basis}} c(s, s_b) \cdot V(s_b)

Where:

  • c(s,sb)≥0c(s, s_b) \geq 0 for all s,sbs, s_b
  • ∑sbc(s,sb)=1\sum_{s_b} c(s, s_b) = 1 for all ss

Intuition

Like linear interpolation: values at intermediate points are weighted averages of nearby anchor points.

Example: K-Nearest Neighbors (KNN)

  • Basis = all data points
  • c(s,sb)=1kc(s, s_b) = \frac{1}{k} if sbs_b is one of kk nearest neighbors, else 0

Why Averagers Work

Brilliant Insight (Gordon): An averager can be folded into the MDP itself!

Define a new transition function:

T′(s,a,sb)=∑s′T(s,a,s′)⋅c(s′,sb)T'(s, a, s_b) = \sum_{s'} T(s, a, s') \cdot c(s', s_b)

This is:

  • Non-negative (since T≥0T \geq 0 and c≥0c \geq 0)
  • Sums to 1 over sbs_b (since both TT and cc sum to 1)
  • Therefore, it's a valid transition function!

Result: The value function under the averager IS the optimal value function of an equivalent MDP defined over just the basis states.

Properties

PropertyImplication
Unique fixed pointBellman iteration converges
Contraction mappingConvergence is guaranteed
More anchor pointsBetter approximation

9. Summary: Generalization

ConceptKey Point
FeaturesDescribe states; choice determines what's learnable
Linear VFAQ(s,a)=w⋅ϕ(s)Q(s,a) = \mathbf{w} \cdot \phi(s); simple gradient
BootstrappingUsing predictions as targets—can be unstable
Baird's ExampleShows divergence is possible even with linear
AveragersConvex combinations; guaranteed convergence
Practical MethodsTD-Gammon, DQN work with careful engineering

Lecture 9: Partially Observable MDPs (POMDPs)

1. The Core Problem: You Can't Always See the State

Intuition First

In standard MDPs, we assumed you always know exactly which state you're in. But real life isn't like that:

Example: You're a robot navigating a building. You see "a hallway with blue walls." But there are 3 different hallways with blue walls in this building. Which one are you actually in?

You can't know for certain. But you can maintain a belief—a probability distribution over where you might be.

What Changes from MDPs?

In an MDP, you observe the state directly. In a POMDP, there's an extra layer:

True State (hidden) → generates → Observation (what you see)

Concrete Example - Tiger Problem:

  • Two doors. Behind one is a tiger (bad), behind the other is treasure (good).
  • You can't see which is which.
  • You can "listen" and hear a growl from the left or right, but listening is noisy (85% accurate).
  • What do you do?

Formal POMDP Definition

A POMDP adds one thing to an MDP: observations.

ComponentWhat it isExample (Tiger)
SSHidden states{tiger-left, tiger-right}
AAActions{listen, open-left, open-right}
ZZObservations{growl-left, growl-right}
T(s,a,s′)T(s, a, s')TransitionsAfter opening, reset randomly
R(s,a)R(s, a)Rewards+10 treasure, -100 tiger, -1 listen
O(s,z)O(s, z)P(observation | state)P(growl-left | tiger-left) = 0.85

Key insight: The agent never sees ss directly. It only sees zz, which is a noisy hint about ss.


2. Belief States: Tracking Where You Might Be

The Core Idea

Since you don't know the true state, you track a probability distribution over all possible states.

Belief state bb is a vector: b(s)=b(s) = probability you're in state ss

Tiger Example:

  • Initially: b=(0.5,0.5)b = (0.5, 0.5) — 50% tiger-left, 50% tiger-right
  • After hearing growl-left: b≈(0.85,0.15)b ≈ (0.85, 0.15) — probably tiger-left
  • After hearing growl-left twice: b≈(0.97,0.03)b ≈ (0.97, 0.03) — almost certainly tiger-left

Belief Update Formula

After taking action aa and seeing observation zz:

b′(s′)=O(s′,z)⋅∑sT(s,a,s′)⋅b(s)normalizing constantb'(s') = \frac{O(s', z) \cdot \sum_{s} T(s, a, s') \cdot b(s)}{\text{normalizing constant}}

In plain English:

  1. Start with your old belief b(s)b(s)
  2. For each possible new state s′s', compute: (how likely to transition there) × (how likely to see zz from there)
  3. Normalize so probabilities sum to 1

This is just Bayes' rule: You're updating your belief about hidden states given new evidence.

Worked Example

Tiger problem, starting with b=(0.5,0.5)b = (0.5, 0.5), action = listen, observation = growl-left:

  • P(growl-left∣tiger-left)=0.85P(\text{growl-left} | \text{tiger-left}) = 0.85
  • P(growl-left∣tiger-right)=0.15P(\text{growl-left} | \text{tiger-right}) = 0.15

New belief (before normalizing): (0.5×0.85,0.5×0.15)=(0.425,0.075)(0.5 × 0.85, 0.5 × 0.15) = (0.425, 0.075)

After normalizing: (0.425/0.5,0.075/0.5)=(0.85,0.15)(0.425/0.5, 0.075/0.5) = (0.85, 0.15)


3. The Belief MDP: Converting POMDP to Something Solvable

The Key Insight

Here's the clever trick: A POMDP over hidden states can be converted to a regular MDP over belief states.

Why this works: Even though you don't know the true state, your belief state is something you do know perfectly. And beliefs update deterministically given (action, observation) pairs.

The Belief MDP:

  • States = all possible belief distributions (continuous!)
  • Actions = same as original
  • Transitions = belief updates
  • Rewards = R(b,a)=∑sb(s)R(s,a)R(b, a) = \sum_s b(s) R(s, a) (expected reward under belief)

The Problem: Continuous State Space

With 2 hidden states, your belief is a point in [0,1][0,1] (1D continuous). With nn hidden states, your belief is a point in an (n−1)(n-1)-dimensional simplex.

This is infinite—how do we do value iteration over infinitely many states?


4. Value Iteration for POMDPs: The PWLC Representation

The Problem We Need to Solve

We want to compute V(b)V(b) = value of being in belief state bb.

But bb is continuous! We can't just make a table.

The Beautiful Result: V(b) Has Special Structure

Theorem: For any finite-horizon POMDP, the value function Vt(b)V_t(b) is:

  1. Piecewise Linear — made up of flat surfaces
  2. Convex — bowl-shaped (curving upward)

This means we can represent Vt(b)V_t(b) exactly using a finite set of vectors.

What Does PWLC Actually Mean?

Intuition with 2 states (so belief is just one number, pp = P(state 1)):

Imagine plotting V(p)V(p) for pp from 0 to 1. The theorem says this curve is made of straight line segments joined together, forming a shape like this:

V(b)
  ^
  |     /\
  |    /  \    /
  |   /    \  /
  |  /      \/
  +----------------> p (belief in state 1)
  0                1

Each line segment comes from a different "plan" (sequence of actions). The value function takes the best plan at each belief point.

Alpha-Vectors: How We Store V(b)

Each line segment is defined by an α-vector (alpha-vector).

Definition: An α-vector α\alpha is a vector with one entry per hidden state. It represents the value of a particular policy if you knew the true state.

α(s)="value of following this plan if actually in state s"\alpha(s) = \text{"value of following this plan if actually in state } s\text{"}

To get the value at belief bb: Take the dot product α⋅b=∑sα(s)⋅b(s)\alpha \cdot b = \sum_s \alpha(s) \cdot b(s)

This is the expected value of that plan, averaging over your uncertainty.

The value function is: V(b)=max⁡α∈Γ(α⋅b)V(b) = \max_{\alpha \in \Gamma} (\alpha \cdot b)

where Γ\Gamma is your set of α-vectors (different plans).

Visual: 2-State Example

With 2 states, each α-vector defines a line: V=α1⋅p+α2⋅(1−p)V = \alpha_1 \cdot p + \alpha_2 \cdot (1-p)

V(b)
  ^
  |   α₁ (plan: open left)
  |    \
  |     \  ← V(b) = max over these lines
  |      \/
  |      /\
  |     /  \
  |    /    α₂ (plan: open right)
  +----------------> p

Different plans are best for different beliefs. The value function is the upper envelope.

How Value Iteration Works

Base case (horizon 0): V0(b)=0V_0(b) = 0 everywhere. One α-vector: (0,0,...,0)(0, 0, ..., 0).

Induction: To compute Vt+1V_{t+1} from VtV_t:

  1. For each action aa and observation zz, we create new α-vectors
  2. These come from combining the old α-vectors with the immediate rewards and transitions
  3. Take the max at each belief point

The key operations:

  • Taking max over actions → take union of α-vector sets
  • Different observations → combine α-vectors from different "branches"

The Computational Blow-up

Problem: The number of α-vectors can grow exponentially at each step.

∣Γt+1∣≤∣A∣⋅∣Γt∣∣Z∣|\Gamma_{t+1}| \leq |A| \cdot |\Gamma_t|^{|Z|}

With 2 actions and 3 observations: ∣Γ1∣≤2|\Gamma_1| \leq 2, ∣Γ2∣≤2⋅23=16|\Gamma_2| \leq 2 \cdot 2^3 = 16, ∣Γ3∣≤2⋅163=8192|\Gamma_3| \leq 2 \cdot 16^3 = 8192...

Doubly exponential in horizon!

Pruning: Making It Tractable

Many α-vectors become dominated—they're never the best at any belief point.

Dominated: α is dominated if there's always some other α' with α′⋅b≥α⋅bα' \cdot b ≥ α \cdot b for all bb.

We can safely throw these away. In practice, pruning makes small POMDPs solvable.


5. Approaches When the POMDP is Unknown (RL for POMDPs)

Now we tackle a harder problem: what if you don't know the transition probabilities, observation probabilities, or rewards? This is RL in partially observable environments.

Approach 1: Model-Based Learning with EM

Idea: Learn the POMDP model, then solve it.

EM Algorithm (same as for Hidden Markov Models):

  1. E-step: Given your current model guess, estimate the hidden states from your observed data
  2. M-step: Given those estimated states, update your model parameters

Repeat until convergence.

Problem: No guarantees—works well for some POMDPs, fails on others.

Approach 2: Memoryless Policies

Simplification: What if we just ignore history and pick actions based only on the current observation?

π:Z→A\pi: Z \rightarrow A

"When I see blue hallway, go left. When I see green hallway, go right."

The Problem: Same observation, different states, need different actions.

Example: You're in a hallway. Blue walls = states 1, 2, or 4. State 1 needs "go left", states 2,4 need "go right". But you just see "blue"—what do you do?

Surprising Result: A stochastic memoryless policy can be better than any deterministic one!

If you randomize (go left 30%, right 70%), you'll do the right thing more often on average than always choosing one direction.

Approach 3: Bayesian RL (Elegant but Expensive)

Key insight: "Not knowing which MDP you're in" is itself a form of partial observability!

Setup:

  • You have a prior distribution over possible MDPs
  • The "true MDP" is a hidden state
  • Your observations (states, rewards) give you evidence about which MDP it is

Result: This is just a POMDP where the hidden state includes "which MDP is real."

Magic: Solving this POMDP gives you optimal exploration automatically—no need for separate exploration bonuses. Uncertainty is built into the belief state.

Catch: The belief space is now over MDPs, which is huge. Only practical for tiny problems.


6. Alternative View: Predictive State Representations (PSRs)

Philosophical Question

What is a "state" really? In POMDPs, we postulate hidden states that we can never observe. Is there another way?

PSR Idea

Define state in terms of predictions about the future, not hidden variables.

A test = sequence of actions and expected observations: (do a1a_1, see z1z_1, do a2a_2, see z2z_2, ...)

Predictive state = probabilities of all possible tests from current situation.

Why this is cool: Everything is grounded in observables. No metaphysical hidden states.

Theorem: PSRs and POMDPs are equivalent—any POMDP can be expressed as a PSR and vice versa.


7. Summary: POMDPs

ConceptPlain English
POMDPMDP where you can't see the true state, only noisy observations
Belief stateYour probability distribution over where you might be
Belief updateBayes' rule—update probabilities given new evidence
PWLCValue function is max of linear functions, one per "plan"
α-vectorRepresents value of a plan as function of belief
ComplexityGrows doubly exponentially with horizon (hard!)
MemorylessIgnore history; may need randomization
Bayesian RLTreat unknown MDP as hidden state; auto-explores
PSRsAlternative: define state by predictions, not hidden vars

Lecture 10: Options and Temporal Abstraction

1. The Problem: Actions Are Too Small

Why RL Struggles with Scale

Consider teaching a robot to make coffee. With primitive actions like "move arm 1cm left," you're looking at:

  • Hundreds of steps to complete the task
  • Reward only at the very end
  • Credit assignment nightmare: which of 500 actions mattered?

Key insight from Lecture 8: We used function approximation to handle large state spaces. Can we do something similar for actions?

The Solution: Macro-Actions

Instead of primitive actions (up/down/left/right), use high-level actions like:

  • "Go to the door"
  • "Navigate to room B"
  • "Pick up the cup"

These are called "options"—temporally extended actions that run for multiple time steps.


2. Intuition: Why Options Help

Concrete Example: Room Navigation

Imagine a 4-room gridworld where you need to get from the top-left room to the bottom-right room:

With primitive actions (up/down/left/right):

  • ~60 individual decisions
  • Reward signal travels back 60 steps
  • Planning: consider 4604^{60} possible paths

With options ("go to hallway 1", "go to hallway 2", etc.):

  • ~4 high-level decisions
  • Reward signal only needs to travel 4 steps back
  • Planning: consider 44=2564^4 = 256 possible paths

The savings are exponential: 4604^{60} vs 444^4

What Makes a Good Option?

Options work best when they:

  1. Accomplish meaningful subgoals (reach a doorway, pick up an object)
  2. Are reusable across different tasks
  3. Have clear start and end conditions

3. Options: The Formal Definition

An option bundles three things together:

The Three Components

ComponentWhat it answersType
Initiation set II"Where can I start this option?"Set of states
Policy π\pi"What do I do while executing?"State → Action mapping
Termination β\beta"When do I stop?"State → Probability of stopping

Example: "Go to South Doorway" Option

Initiation set I:     Any state in the northeast room
Policy π:             Navigate toward the south door (e.g., learned via Q-learning)
Termination β:        β(s) = 1 if s is the doorway, else β(s) = 0
                      (Always stop when you reach the door, never stop otherwise)

Primitive Actions Are Just Simple Options

Every regular action aa can be written as an option:

  • II = everywhere aa is valid
  • π\pi = "just do aa"
  • β(s)=1\beta(s) = 1 for all ss (always stop after one step)

So options generalize actions—they don't replace them.

Stochastic Termination

The termination function β(s)\beta(s) gives the probability of stopping in state ss. This allows:

  • β(s)=1\beta(s) = 1: definitely stop here
  • β(s)=0\beta(s) = 0: never stop here
  • β(s)=0.1\beta(s) = 0.1: 10% chance of stopping here (useful for exploration or random duration)

4. The Time Problem: Why We Need SMDPs

The Issue with Regular Bellman Equations

Standard Bellman equation assumes each action takes exactly one time step:

V(s)=max⁡a[R(s,a)+γV(s′)]V(s) = \max_a \left[ R(s,a) + \gamma V(s') \right]

That single γ\gamma assumes one time step of discounting.

But options take variable time:

  • "Go to doorway" from nearby: 3 steps
  • "Go to doorway" from far away: 15 steps

If we just used γ\gamma once, we'd be treating 15-step options the same as 3-step options for discounting. That's wrong!

Semi-Markov Decision Processes (SMDPs)

Key idea: Fold the variable time directly into the reward and transition functions.

SMDP Bellman Equation: V(s)=max⁡o[R(s,o)+∑s′F(s,o,s′)⋅V(s′)]V(s) = \max_o \left[ R(s, o) + \sum_{s'} F(s, o, s') \cdot V(s') \right]

This looks like regular Bellman, but RR and FF are defined differently.

What R(s,o)R(s, o) Means: Time-Adjusted Reward

R(s,o)R(s, o) = expected discounted total reward while executing option oo from state ss

If the option takes kk steps and collects rewards r1,r2,…,rkr_1, r_2, \ldots, r_k:

R(s,o)=E[r1+γr2+γ2r3+…+γk−1rk]R(s, o) = \mathbb{E}\left[ r_1 + \gamma r_2 + \gamma^2 r_3 + \ldots + \gamma^{k-1} r_k \right]

The discounting happens inside RR, not outside.

What F(s,o,s′)F(s, o, s') Means: Time-Adjusted Transition

F(s,o,s′)F(s, o, s') = expected discounted probability of ending in s′s'

F(s,o,s′)=E[γk⋅1[end up in s′]]F(s, o, s') = \mathbb{E}\left[ \gamma^k \cdot \mathbf{1}[\text{end up in } s'] \right]

Why the γk\gamma^k? If an option takes 10 steps to reach s′s', the future value from s′s' should be discounted by γ10\gamma^{10}. This γk\gamma^k handles that.

Concrete Example

Option: "Go to doorway" from state ss

  • Takes 5 steps on average
  • Collects rewards: 0, 0, -1 (hit wall), 0, +1 (reached door)
  • Ends in doorway state sdoors_{\text{door}}

Then:

  • R(s,o)=0+0+γ2(−1)+0+γ4(+1)=γ4−γ2R(s, o) = 0 + 0 + \gamma^2(-1) + 0 + \gamma^4(+1) = \gamma^4 - \gamma^2
  • F(s,o,sdoor)=γ5F(s, o, s_{\text{door}}) = \gamma^5 (discounted by time taken)

Why "Semi-Markov"?

  • Markov property still holds at the base level: given current state, future is independent of past
  • But at the option level: transitions depend on how long the option took (non-Markovian in time)

The "semi" captures this: Markovian in state, non-Markovian in time.

The Payoff

Once you define R(s,o)R(s,o) and F(s,o,s′)F(s,o,s'), everything else works normally:

  • Value iteration works
  • Q-learning works
  • All convergence guarantees apply

You've just changed the "actions" from primitives to options.


5. Bonus: State Abstraction from Options

Different Options Need Different Information

Consider Pac-Man with three options:

  1. "Eat nearest dot": Needs to know where Pac-Man is and where dots are. Doesn't care about ghosts.
  2. "Avoid ghost": Needs to know where Pac-Man is and where ghosts are. Doesn't care about dots.
  3. "Eat ghost" (after power pellet): Needs Pac-Man and ghost positions.
OptionPac-Man pos?Ghost pos?Dot pos?
Eat dot✓✗✓
Avoid ghost✓✓✗
Eat ghost✓✓✗

Implication: Each option effectively operates on a smaller state space. This is "state abstraction"—ignoring irrelevant features.


6. Goal Abstraction and Modular RL

Alternative View: Competing Goals

Instead of thinking "first do option A, then option B," think of options as parallel goals competing for control:

  • "Eat dots" module: always wants you to chase dots
  • "Avoid ghost" module: always wants you to flee
  • "Eat ghost" module: wants you to chase ghosts (when powered up)

At each moment, one module "wins" and picks the action.

Arbitration: How Do Modules Vote?

Method 1: Greatest Mass (Sum the Q-values) Qtotal(s,a)=∑iQi(s,a)Q_{\text{total}}(s, a) = \sum_i Q_i(s, a) Pick action with highest total vote.

  • Pro: Every module gets a say
  • Con: Might pick an action that's no module's first choice (a "compromise" action)

Method 2: Top Q (Max of Q-values) Qtotal(s,a)=max⁡iQi(s,a)Q_{\text{total}}(s, a) = \max_i Q_i(s, a) The module that cares most gets to decide.

  • Pro: At least one module is happy
  • Con: Ignores modules with moderate but consistent preferences

Method 3: W-learning (Who loses most?)

For each module, compute how much it "loses" if we don't take its preferred action: Wi(s,a)=max⁡a′Qi(s,a′)−Qi(s,a)W_i(s, a) = \max_{a'} Q_i(s, a') - Q_i(s, a)

Give priority to modules with high WW—they have the most at stake.


7. Monte Carlo Tree Search (MCTS): Planning with Options

Why We Need Something Beyond Value Iteration

Value iteration requires iterating over all states. With large state spaces, this is impossible.

MCTS is different: it builds a search tree by sampling, focusing computation on promising paths.

The Four Phases of MCTS

Repeat many times:
  1. SELECTION     → Walk down tree using current best guesses
  2. EXPANSION     → Add a new node when you reach the frontier
  3. SIMULATION    → Random rollout to estimate value
  4. BACKPROP      → Update Q-values back up the tree

Phase-by-Phase

Selection: Starting from root (current state), repeatedly pick the action that looks best: a=arg⁡max⁡a[Q(s,a)+exploration bonus]a = \arg\max_a \left[ Q(s,a) + \text{exploration bonus} \right] Continue until you reach a state not yet in the tree.

Expansion: Add this new state to the tree. Try one action to see what happens.

Simulation (Rollout): From the new state, play randomly (or with a simple policy) for many steps. Add up discounted rewards to estimate the value.

Backpropagation: Update Q-values for every (state, action) pair you visited on the way down: Q(s,a)←Q(s,a)+α⋅[rollout return−Q(s,a)]Q(s,a) \leftarrow Q(s,a) + \alpha \cdot [\text{rollout return} - Q(s,a)]

Why MCTS is Powerful

PropertyBenefit
Anytime: More iterations → better answerCan stop whenever time runs out
Sample-based: Doesn't need full state spaceWorks with huge/continuous spaces
Simulator-only: Just need to simulate, not enumerateEasier than building full model

Options + MCTS = Huge Win

Using options as actions in MCTS:

  • Each "action" in the tree is an option (multi-step)
  • Effective depth of tree is much shallower
  • Same computation explores much farther into the future

Example:

  • Primitive actions, horizon 100: tree depth 100
  • Options (avg 20 steps each), horizon 100: tree depth ~5
  • Branching factor bb: b100b^{100} vs b5b^5 — exponential speedup

8. Summary: Options and Temporal Abstraction

ConceptPlain English
OptionsMulti-step "macro-actions" defined by (where to start, what to do, when to stop)
Why options helpReduce effective horizon exponentially; faster learning and planning
SMDPsBellman equations that account for variable-time options
R(s,o)R(s,o)Total discounted reward during option execution
F(s,o,s′)F(s,o,s')Time-discounted probability of ending in state s′s'
State abstractionDifferent options can ignore different features
Modular RLMultiple goal-modules compete for control
MCTSSample-based planning that builds a search tree
Options + MCTSShallow tree explores deep into future

Key Equations Summary

Generalization

Q(s,a)=wa⋅ϕ(s)=∑iwiaϕi(s)Q(s, a) = \mathbf{w}^a \cdot \phi(s) = \sum_i w_i^a \phi_i(s)

wia←wia+α⋅[r+γmax⁡a′Q(s′,a′)−Q(s,a)]⋅ϕi(s)w_i^a \leftarrow w_i^a + \alpha \cdot [r + \gamma \max_{a'} Q(s', a') - Q(s, a)] \cdot \phi_i(s)

POMDPs

Belief Update: b′(s′)=O(s′,z)∑sT(s,a,s′)b(s)normalizing constantb'(s') = \frac{O(s', z) \sum_s T(s, a, s') b(s)}{\text{normalizing constant}}

PWLC Value Function: Vt(b)=max⁡α∈Γt(α⋅b)V_t(b) = \max_{\alpha \in \Gamma_t} (\alpha \cdot b)

Where each α\alpha is a vector with α(s)\alpha(s) = value of that plan if in state ss.

SMDPs (Options)

V(s)=max⁡o[R(s,o)+∑s′F(s,o,s′)V(s′)]V(s) = \max_o \left[ R(s, o) + \sum_{s'} F(s, o, s') V(s') \right]

Time-adjusted reward: R(s,o)=E[∑k=1Kγk−1rk]R(s, o) = \mathbb{E}\left[\sum_{k=1}^{K} \gamma^{k-1} r_k\right]

Time-adjusted transition: F(s,o,s′)=E[γK⋅1[end in s′]]F(s, o, s') = \mathbb{E}\left[\gamma^K \cdot \mathbf{1}[\text{end in } s']\right]


Practice Questions

Generalization

  1. Why does linear function approximation sometimes diverge? What is the "deadly triad"?
  2. What makes averagers "safe" for convergence? (Hint: think about how they relate to equivalent MDPs)
  3. Design features for the taxi problem that would help with generalization.

POMDPs

  1. Tiger Problem: You have belief b=(0.5,0.5)b = (0.5, 0.5). You listen and hear growl-left (85% accurate). Compute the new belief.
  2. What is an α-vector, intuitively? Why is the POMDP value function the max of dot products with α-vectors?
  3. Why might a stochastic memoryless policy outperform a deterministic one in a POMDP?
  4. Explain how Bayesian RL automatically handles the exploration/exploitation tradeoff.

Options

  1. Define the three components of an option. Give an example option for "navigate to nearest power pellet" in Pac-Man.
  2. Why do we need SMDPs for options? What goes wrong if we use the regular Bellman equation?
  3. In the SMDP Bellman equation, explain intuitively what F(s,o,s′)F(s, o, s') represents and why it includes γk\gamma^k.
  4. In Greatest Mass Q-learning, construct an example where the chosen action is no module's first choice.
  5. How does using options with MCTS provide exponential speedup compared to primitive actions?