Skip to content

Markov decision processes

Decisions under uncertainty · 1957 · Chapter opener

A Markov decision process is the precise form of the question every planning agent faces: from each state, which action leads to the most reward on average, when the world is partly random?

Decisions under uncertainty

Markov Decision Processes

A robot in a small grid wants to reach the +1 square and avoid the −1 square. Its wheels slip: one move in five goes sideways. Where should it head from each square? A Markov decision process (MDP) is the standard way to write that question down precisely, and the next three pages answer it.

The world-models series used the same pieces informally: the STAR checklist in part 2, and the transition function T that a world model learns. Here they get their formal names, on the classic 4×3 gridworld from the standard AI textbook.

1 · The parts

States, actions, a noisy world, rewards and patience

MDP = ( , , , , )
policy:

Lab 1 · Try a move

tap a square, pick a direction, then take the step

Action

2 · Policies

A plan for every square, judged by its average

Because moves slip, you can't plan a fixed route. You need a policy: an action for every square, so that wherever a slip leaves you, you know what to do next. Two policies are compared by their expected total reward, the average over many runs, because any single run is luck. (The killer-drone lab in part 1 made the same point about value.)

Lab 2 · Race three policies

2,000 runs each from the bottom-left square, at the noise and living reward set above

Average total reward (2,000 runs)

“Best” is the policy value iteration finds (next page). “Straight for +1” takes the shortest route from the start: along the bottom row and up the right side, straight through the −1 square. Runs are capped at 100 steps.

3 · Discounting

Why later rewards count for less

A run's utility adds up its rewards. With a discount γ, a reward t steps away is multiplied by γt:

U = + ≤

Lab 3 · Add up a reward of 1 every step

each bar is γt; the running total approaches the bound

Discounting does three jobs: it keeps values finite when runs can go on forever, it says that sooner is better than later, and it can stand for a small chance that the episode ends at each step. A finite horizon (stop after H steps) is the other way to keep sums finite; then the best action can depend on how many steps are left, not just on the square.

4 · The Markov property

The present is enough

P(St+1 | , ) = P(St+1 | St, At)

Given the current state, the past tells you nothing more about the future. That is what lets a policy depend only on the current square, and it is why T has just three arguments. It is a property of how you define the state. In the grid, the square is everything that matters. For a moving ball, a position alone is not Markov, because the next position also depends on velocity; adding the velocity (or the previous frame, as video world models do in watch first, then practise) makes it Markov again.

5 · Next

Solving it

When T and R are known, the best policy can be computed without ever moving: value iteration and policy iteration. When they are not, the agent can learn from experience with Q-learning, or learn T itself, which is a world model.

Next: Value iteration