Reinforcement Learning Lab

Eight reinforcement-learning labs: classical, deep, policy optimisation, bandits, planning and multi-agent, with experiments trained for real in your browser.

39interactive experiments

The Bellman equation

RL Fundamentals · basics

Learning objectives

  • Write the Bellman expectation and optimality equations.
  • See that algorithms solve these equations approximately.

The idea

A state's value equals the expected reward now plus the discounted value of the next state.

Explanation

This recursion underlies dynamic programming (value iteration), temporal-difference learning (Q-learning) and most later algorithms.

Equations

V^\pi(s)=\sum_a\pi(a|s)\sum_{s'}P(s'|s,a)\,[R+\gamma V^\pi(s')]\\ Q^*(s,a)=\sum_{s'}P(s'|s,a)\,[R+\gamma\max_{a'}Q^*(s',a')]

The second is the optimality equation: Q* is its fixed point.

Worked example

Value iteration on GridWorld applies the right-hand side repeatedly until the values stop changing.

Common mistakes

Giving a terminal state a non-zero value.

Forgetting the discount.

Summary

The Bellman equation expresses value recursively, and every algorithm approaches its solution.

Related experiments

Assessment questions

References

  1. Sutton, R. S.; Barto, A. G. (1998). Reinforcement learning: an introduction (first-edition record; the second edition is free at the author's page). IEEE Transactions on Neural Networks 9(5):1054. doi:10.1109/tnn.1998.712192