Model-Free RL Algorithms
Learning outcomes
- Compute a value function by value iteration on a grid and explain why it converges.
- Write the policy gradient theorem and explain how an actor-critic method estimates each part of it.
- Compare a learned policy with the explicit MPC law, a policy computed offline from a model.
Book chapter: Model Predictive Control and Economic Optimization (Volume 9), Chapter 12, Automatic Train Operation Simulator Where the Timetable Decides Where to Coast (PDF).
Practice in 15 minutes: 14 · Dynamic Programming and the Four Driving Regimes, 19 · Explicit MPC: The Optimizer Solved in Advance
Model: Model-free methods use only sampled transitions; dynamic programming and explicit MPC use a model of the transitions.
Decision: Each method produces a policy, a rule that maps the current state to an action.
Learning: Value iteration and explicit MPC compute the policy from a model; Q-learning and policy gradients learn it from experience.
Model-free RL algorithms learn optimal policies directly from interaction data without explicit environment models. Five popular model-free RL algorithms are highlighted with key ideas, mathematic objectives, and engineering applications.
0. Value Iteration: Dynamic Programming on a Grid
When the transition model is known and the states can be gridded, the Bellman equation is solved by repeating its right-hand side until the values stop changing:
$$\begin{gathered} V_{i+1}(s) = \max_{a \in \mathcal{A}} \sum_{s'} P(s' \mid s, a) \Big[ R(s, a, s') + \gamma\, V_i(s') \Big], \\ \text{until } \max_s \left| V_{i+1}(s) - V_i(s) \right| < \text{tol} \end{gathered}$$
The update shrinks the distance between any two value functions by the factor `\gamma`, so it converges to `V^*` from any start. The cost is one sweep over every state and action per iteration, which grows exponentially with the number of state variables. For a finite horizon, the recursion runs once, backward from the end. The train-ato app does this over 50 m stages and 1 km/h speed nodes, with the energy `e` and running time `t` of each decision `d` (traction, hold, coast or brake) and a price `\lambda` on time:
$$V_N(0) = 0, \qquad V_i(v) = \min_{d} \Big[ e(v, d) + \lambda\, t(v, d) + V_{i+1}(v') \Big]$$
where `v'` is the speed at the end of the stage. Q-learning, below, estimates the same values from sampled transitions when `P` is not known.
1. Q-Learning
Overview: Q-Learning learns the optimal action-value function `Q^*(s,a)` through experience. It is an off-policy, value-based method, capable of learning from exploratory actions.
Update Rule: $$ Q_{new}(s_t,a_t) \leftarrow Q(s_t,a_t) + \alpha \left[r_{t+1} + \gamma \max_{a'} Q(s_{t+1},a') - Q(s_t,a_t)\right] $$
Applications: Equipment scheduling, discrete process control (e.g., valves, simple robotics).
2. Deep Q-Networks (DQN)
Overview: DQN extends Q-learning with neural networks for approximating Q-values, suitable for large-scale state spaces.
Key Innovations:
- Experience Replay: Stores experiences to reduce correlation and improve training stability.
- Target Network: Stabilizes training by periodically updating target network parameters.
Loss Function: $$ L(\theta) = \left(Q_\theta(s,a) - [r + \gamma \max_{a'}Q_{\theta^-}(s',a')]\right)^2 $$
Applications: Autonomous driving, discrete robotic control, power systems management.
3. Policy Gradient Methods
Overview: Policy gradient methods directly optimize the policy parameters `\theta` by maximizing expected rewards.
REINFORCE Update: $$ \theta \leftarrow \theta + \alpha \nabla_{\theta}\log \pi_\theta(a_t|s_t)G_t $$
Variance Reduction: Use baseline `b(s)` or advantage `A(s,a)` to improve stability.
Applications: Continuous control in robotics, process parameter tuning, network optimization.
4. Proximal Policy Optimization (PPO)
Overview: PPO improves policy gradient stability by preventing overly aggressive updates.
Clipped Objective: $$ J^{CLIP}(\theta) = \mathbb{E}_t\left[\min\left(r_t(\theta)\hat{A}_t,\text{clip}\{r_t(\theta),1-\epsilon,1+\epsilon\}\hat{A}_t\right)\right] $$
Applications: Robotic locomotion, drone control, continuous industrial parameter optimization.
5. Deep Deterministic Policy Gradient (DDPG)
Overview: DDPG combines policy gradients and Q-learning for continuous action spaces using actor-critic methods.
Updates:
- Critic Loss:
$$ L(\theta_Q) = \left(Q_{\theta_Q}(s,a) - [r + \gamma Q_{\theta_Q^-}(s',\mu_{\theta_\mu^-}(s'))]\right)^2 $$
- Actor Update:
$$ \nabla_{\theta_\mu} J \approx \mathbb{E}_{s}\left[\nabla_a Q_{\theta_Q}(s,a)|_{a=\mu(s)}\nabla_{\theta_\mu}\mu_{\theta_\mu}(s)\right] $$
Applications: Robotics (pendulum balancing), chemical process control, portfolio management, voltage regulation in power systems.
The Policy Gradient and Actor-Critic in Outline
REINFORCE above is a sample of the policy gradient theorem. For the expected return `J(\theta)` of a policy `\pi_\theta` with action-value function `Q^{\pi_\theta}`:
$$\nabla_\theta J(\theta) = \mathbb{E}_{s, a \sim \pi_\theta} \Big[ \nabla_\theta \log \pi_\theta(a \mid s)\; Q^{\pi_\theta}(s, a) \Big]$$
REINFORCE replaces `Q` with the sampled return `G_t`, which is unbiased but noisy. An actor-critic method trains a second network, the critic `V_w(s)`, and uses the one-step advantage `\hat A_t = r_{t+1} + \gamma V_w(s_{t+1}) - V_w(s_t)` in place of `Q`. The critic is trained to reduce that temporal-difference error, and the actor follows the gradient with `\hat A_t`. DDPG and PPO are both built this way.
A Policy Computed, Not Learned: Explicit MPC
For a linear model with quadratic cost and linear constraints, the MPC law is a piecewise affine policy `u^*(x) = F_i x + g_i` on polyhedral regions of the state space, computed offline by multiparametric programming (see Control Tuning). It is a policy like those above: a lookup from state to action, fast to evaluate. The difference is that it is computed exactly from a model and satisfies the constraints by construction, rather than learned from trials and checked by testing.
Definition of Symbols
- `Q(s,a)`: Action-value function.
- `\alpha`: Learning rate.
- `\gamma`: Discount factor.
- `r`: Reward.
- `\theta`: Parameters of neural network or policy.
- `\pi_{\theta}(a|s)`: Policy distribution parameterized by `\theta`.
- `G_t`: Return (cumulative discounted reward from time `t` onwards).
- `\hat{A}_t`: Advantage estimate at time `t`.
- `\epsilon`: PPO clip range hyperparameter.
- `\mu(s)`: Deterministic policy function.
Generative AI Learning
Check the answer: Code it in Python and iterate until the values stop changing. The cell next to the goal has value 1, and each step farther multiplies by 0.9, so the left end has 0.9^8 ≈ 0.43. If the assistant's values do not fall by 0.9 per cell, it has mishandled the terminal state or the discount.