Lecture 10.2: MDPs and Reinforcement Learning
Understanding Markov Decision Processes, the Bellman Equation, Value Iteration, and Q-Learning.
Markov Decision Processes (MDPs)
A Markov Decision Process (MDP) provides a mathematical framework for modeling decision-making in environments where outcomes are partly random and partly under the control of an agent.
It relies on the Markov Property: The future state depends only on the current state and action, not on the history of prior states (Memoryless).
An MDP is defined by:
- States (): The set of all possible environmental states.
- Actions (): The set of all possible actions.
- Transition Model (): The probability of transitioning to state after taking action in state .
- Reward Function (): The immediate reward received for being in state .
The Bellman Equation
To balance immediate rewards with future rewards, we discount future rewards using a Discount Factor (). The utility of a state is captured by the Bellman Equation:
This equation states that the long-term utility of a state is its immediate reward plus the discounted expected utility of the next state, assuming the agent acts optimally.
The Value Iteration Algorithm
Because the Bellman equation contains a operator, it is non-linear and cannot be solved directly with linear algebra. Instead, we use Value Iteration, an iterative dynamic programming algorithm:
- Initialize state utilities arbitrarily: for all .
- In each iteration , update the utilities of all states simultaneously using the Bellman Update Equation:
- Repeat until the maximum change in utility across all states is less than a stopping threshold:
Upon convergence, the optimal policy is extracted by choosing the action that maximizes the expected utility:
Reinforcement Learning (RL)
If the transition probabilities and reward function are unknown, the agent cannot use Value Iteration. Instead, it must learn through trial-and-error using Reinforcement Learning.
Classifications of RL Algorithms
1. Model-Based vs. Model-Free
- Model-Based RL: The agent attempts to learn the transition function and reward function from experience, and then uses a planning algorithm (like Value Iteration) to find the optimal policy.
- Model-Free RL: The agent learns the value of actions directly from experience without ever building an explicit model of the environment's physics.
2. Value-Based vs. Policy-Based
- Value-Based RL: Focuses on learning the value of states or state-action pairs (e.g. Q-values). The policy is implicitly derived (e.g., choose the action with the highest Q-value).
- Policy-Based RL: Represents and optimizes the policy parameters directly to maximize expected reward, skipping value estimation entirely.
3. On-Policy vs. Off-Policy
- On-Policy (e.g., SARSA): The agent learns from data gathered by executing the exact policy it is currently optimizing.
- Off-Policy (e.g., Q-Learning): The agent learns the optimal policy (target policy) while acting under a different, exploratory policy (behavior policy, such as taking random movements).
Q-Learning
Q-learning is a Model-Free, Off-Policy, Value-Based reinforcement learning algorithm. It estimates the quality of taking a specific action in a state , denoted as the Q-value .
The Q-Learning Update Equation
The agent updates its Q-values incrementally based on experience tuples :
where:
- is the Learning Rate, controlling how much new information overwrites old estimates.
- is the Discount Factor, controlling the importance of future rewards.
- is the immediate reward received in state after taking action .
- is the estimated optimal future Q-value from the next state .
- is the Temporal Difference (TD) Error.
Concrete Q-Table Example (Grid World)
Suppose a player navigates a grid world.
- States (): 9 distinct grid cells: .
- Actions (): 4 movements: .
The agent maintains a Q-Table of dimensions . Each cell stores the expected future reward for taking that action in that state:
| State | Q(State, Up) | Q(State, Down) | Q(State, Left) | Q(State, Right) |
|---|---|---|---|---|
| (1, 1) | ||||
| (1, 2) | ||||
| ... | ... | ... | ... | ... |
| (3, 2) | ||||
| (3, 3) | (Goal) |
Interpretation: In state , the highest Q-value is (for action Up). Under a greedy policy, the agent will choose Up as its action.
Action Selection: -Greedy Policy
To prevent the agent from getting stuck in local optima, we use an -greedy policy to balance exploration and exploitation:
- With probability , the agent explores by selecting a random action.
- With probability , the agent exploits by choosing the action that maximizes the current Q-value: .
Lecture 10.1: Decision Theory and Utility
How agents make rational decisions under uncertainty using Utility Theory, Expected Utility, and Decision Networks.
Lecture 11.1: Population-Based Approaches and Swarm Intelligence
Exploring Genetic Algorithms, Ant Colony Optimization (ACO), and Particle Swarm Optimization (PSO).