Markov Decision Processes — From Bandits to Reinforcement Learning
Markov decision processes as bandits whose actions also move a state. Covers the setup (states, actions, transitions, deterministic rewards), histories and policies (memoryless, deterministic, Markov), traps, strong connectivity and the diameter; the average-reward criterion, with gain, stationary transition matrix, differential value function as a Cesàro sum, the Poisson equation, the Bellman optimality equation (existence, optimality of greedy policies, non-uniqueness, span ≤ diameter) and the Bellman operator. Planning with known dynamics uses two linear programs for the optimal gain and an optimal value function, solved in polynomial time by the ellipsoid method with a separation oracle; value and policy iteration are noted. Learning with unknown transitions measures regret nρ* − Σ rewards. UCRL2 combines L1 confidence sets, the extended MDP trick for optimism and doubling phases to get regret O(D S √(An log(nSA/δ))), proved via optimism, Bellman telescoping, Azuma and phase counting. A lower bound of Ω(√(DSAn)) comes from a tree-to-good/bad-state construction reducing MDPs to bandits with about SA arms. Notes cover episodic MDPs, POMDPs, discounting and the vanishing-discount method, traps and maximal end components, unknown rewards, the √(DS) gap, and the reinforcement learning literature.
Corresponds to Lattimore & Szepesvári, Chapter 38, the book’s final chapter.
Motivation: actions with long-term consequences
IntuitionBandits plus state
A brewery’s ingredient orders today shape what it can brew next month. A student’s study choices pay off now and in future job prospects. Bandits can’t express this. A Markov decision process adds a state that the learner observes: rewards depend on (state, action), and actions influence the next state. A bandit is an MDP with one state; a contextual bandit is an MDP whose next state ignores the action (Exercise 38.25).
| Question | Tool |
|---|---|
| What is optimal behaviour in a known MDP? | gain, Bellman optimality equation |
| How do we compute it? | linear programming (polynomial time); value or policy iteration (practical) |
| How do we learn it with unknown dynamics? | UCRL2: optimism over a confidence set of MDPs |
| How well can one learn? | upper bound versus lower bound |
Problem set-up
DefinitionMarkov decision process
- states and actions , of sizes and (finite MDP if both are finite; take );
- transitions : the probability of moving under action , with right-stochastic matrices and rows ;
- deterministic rewards , also viewed as vectors in ;
- initial distribution .
Protocol: . In each round, observe , choose , receive , then .
flowchart LR O["Observe state S_t"] --> C["Choose action A_t"] C --> R["Receive r(A_t, S_t)"] R --> T["Next state drawn from P(A_t, S_t)"] T --> O
NoteActions are per-state labels
The same action set in every state implies no similarity between and . State-dependent action sets change nothing. The colours in the book’s figures (solid = “increment”, dashed = “decrement”) are only for human readability.
DefinitionHistories and policies
The history includes the current state; rewards are recomputable. A policy maps histories to (distributions over) actions.
| Class | Depends on | Notation |
|---|---|---|
| Memoryless (stationary) | current state only, possibly randomised | , |
| Deterministic memoryless | current state, no randomisation | , |
| Markov | time index and current state | a sequence of memoryless policies |
Under a Markov policy the states form a Markov chain, homogeneous if the policy is memoryless. The infinite interaction exists by Ionescu–Tulcea (Exercise 38.1). Markov policies suffice: for any policy there is a Markov policy with the same state–action marginals, hence the same rewards (Exercise 38.2; Strauch 1966).
Traps and the diameter
WarningTraps make learning hopeless
A trap is a set of states with no escape. A learner discovers that an action leads to a trap only by trying it, so competing with an informed agent is impossible: policies with sublinear regret on all strongly connected MDPs suffer linear regret on MDPs with suboptimal traps (Exercise 38.28). Assume no traps.
DefinitionStrong connectivity and diameter (Def. 38.1)
is strongly connected (communicating) if every state can reach every other under some policy with positive probability. The diameter is
the worst-case expected travel time between states, using the best policy for each pair.
| Fact | Detail |
|---|---|
| Different policy per pair | the max is outside the min |
| Deterministic memoryless suffices | travel times satisfy a shortest-path fixed point (Exercise 38.3) |
| iff strongly connected, for finite MDPs (Exercise 38.4) | |
| Lower limit | : at most states are reachable in steps (Exercise 38.5) |
| Meaning | small means mistakes are cheap to recover from |
All MDPs below are strongly connected.
Optimal policies and the Bellman optimality equation
DefinitionGain and optimality (average reward)
is optimal if . Optimal policies exist for strongly connected MDPs, which is far from trivial. Without strong connectivity, the optimal gain is a vector (Note 7).
DefinitionMemoryless-policy quantities
and (38.1).
- Stationary transition matrix , which always exists (Exercise 38.7). Then (38.2).
- Differential value function (Cesàro sum of excess rewards): is the long-run advantage of starting in rather than . is the fundamental matrix, and subtracting gives the deviation matrix.
- Poisson equation: gives , and
NoteWhy Cesàro sums (Notes 9–10)
A Cesàro sum averages the partial sums, which smooths out periodicity: has Cesàro sum . It is used so that exists even for periodic chains. The Abel sum agrees with the Cesàro sum when the latter exists, and is stronger. Approximating average reward by -discounted problems with is the vanishing discount method.
DefinitionSpan, greedy policy, Bellman equation, Bellman operator
- .
- Greedy policy: , with systematic tie-breaking.
- Bellman optimality equation: nonlinear equations in . The -part is an optimal differential value function.
- Bellman operator: , so (38.5) reads .
WarningSolutions are not unique even up to translation (Exercise 38.11)
is always another solution, but there can be more. Two states, “stay” (reward 0) and “go” (reward ): the solutions are exactly with , a whole band. (This breaks a published proof that assumed is a limit of value iteration; Bartlett–Tewari 2009.)
TheoremTheorem 38.2 — Bellman equation characterises optimality
- A solution of (38.5) exists.
- Any solution has , and the greedy policy is optimal.
- Hence a deterministic memoryless optimal policy exists.
ProofProof of (2): telescope against the greedy policy
Greedy achieves : with , the Bellman equation reads , so .
Nothing beats : take any Markov policy (sufficient by Exercise 38.2) with . Greediness gives , so
which telescopes, so .
Existence (1): discounted problems have fixed points (contraction). Choose a deterministic policy greedy along a sequence (finitely many candidates), and pass to the limit with (Exercises 38.8–38.10).
∎
LemmaLemma 38.3 — Value spans are bounded by the diameter
Any Bellman solution has , and more precisely (Exercise 38.13). Intuition: you can travel from the worst state to the best in about steps, losing at most about per step, so values can’t differ by more.
TheoremDiscounted MDPs (Exercise 38.8)
is a -contraction in sup norm. By Banach’s theorem it has a unique fixed point , the greedy policy satisfies , and it is -discount optimal. Compare the discounted Gittins setting, a special discounted MDP.
Finding an optimal policy (planning)
TheoremTheorem 38.4 — LP for the optimal gain
is feasible, and every solution has . However, its need not satisfy the Bellman equation, and its greedy policy need not be optimal (Exercise 38.12).
ProofFeasibility from the Bellman solution; optimality by telescoping
is feasible, so . Conversely, with optimal and feasible, . Multiplying by and averaging telescopes to .
∎
TheoremTheorem 38.5 — LP for an optimal value function
For some state , every solution satisfies the Bellman equation. (Without the anchor , could decrease without bound.)
ProofThe slack vanishes at a recurrent state, then everywhere
Let . With optimal, , so . Pick with for some (a recurrent state), so . Then is also feasible, and minimality gives , so . In practice, try each , or find a recurrent state through the LP dual’s complementary slackness (Note 11).
∎
AlgorithmPolynomial time via the ellipsoid method (§38.3.1)
The ellipsoid method minimises over a convex in time polynomial in and , given (a) a bounding radius , (b) a separation oracle, and (c) an inner ball of radius .
- (a) Bounded: add (Lemma 38.3) and , giving . Use doubling if is unknown.
- (c) Inner ball: add slack to every constraint (38.9). The solution moves by at most .
- (b) Oracle (Algorithm 27): for each compute . If all constraints hold, return “feasible”; otherwise return the violated constraint’s normal . Extra half-space constraints combine easily (Exercise 38.15).
- Approximation is fine (Exercise 38.16): if Bellman holds within , then , and an -greedy policy is -optimal.
WarningPolynomial is not practical
The ellipsoid method “should be avoided at all costs” in practice. Use instead:
- Value iteration: (renormalised because grows like ; the greedy policy is unchanged).
- Policy iteration: alternate evaluating and acting greedily (needs a small modification to converge).
- Other LP methods.
These work well but lack polynomial guarantees under weak assumptions (Bertsekas, vol. 2).
Learning in Markov decision processes
Setting. The rewards are known, the transitions unknown. Unknown stochastic rewards are an easy extension with optimistic reward estimates (Exercise 38.23).
DefinitionRegret
This compares against the asymptotic gain, which is fine because the best -step value satisfies (Exercise 38.17).
TheoremTheorem 38.6 — Upper bound (UCRL2)
An efficiently computable policy achieves, on every MDP with states, actions, rewards in and any initial distribution, with probability ,
and (38.12).
TheoremTheorem 38.7 — Lower bound
For , , and , every policy has some MDP with diameter at most and
The gap to the upper bound is at least .
UCRL2: upper confidence bounds for reinforcement learning
DefinitionConfidence sets for transitions
Empirical transitions . Each state–action pair gets an ball:
with (and , i.e. the whole simplex, when unvisited). . The full set is the product over pairs. The radius is the Bretagnolle–Huber–Carol bound for categorical distributions.
AlgorithmUCRL2 (Algorithm 28; Auer, Jaksch, Ortner)
Proceed in phases . At phase start :
- Optimistic planning: find with solving the Bellman equation in the most optimistic plausible MDP:
- Act: play , greedy with respect to .
- Doubling: end the phase when the visit count of the current state–action pair reaches twice its value at phase start.
ImportantWhy phases are necessary (Exercise 38.19)
Re-planning every round can make an optimistic learner dither. On a two-state MDP where both states pay for staying and switching pays 0, infinite-horizon optimism keeps believing the other state is slightly better and alternates, paying linear regret. Long-term plans should be followed for a while. Doubling phases also mean only re-plans.
The extended MDP
DefinitionOptimism as planning in a bigger MDP
The extended MDP has the same states, enlarged actions , reward , and transition . The agent chooses both an action and a plausible transition law. Its optimal policy is exactly the optimistic policy in (38.16). (The idea first appeared in MBIE; Strehl–Littman 2008.)
TheoremProperties of the extended MDP
- Strongly connected: every confidence ball contains a transition with for any , so (38.16) has constant-gain solutions (Exercise 38.20).
- Finite in effect: each ball is a convex polytope, and restricting to its finitely many vertices doesn’t change the optimum.
- Diameter at most on the good event: the true is among the choices, so span (Lemma 38.3). It is also at most always, since a jump probability is always plausible, which bounds the LP’s radius.
AlgorithmThe inner optimisation is a sort (§38.5.2)
The oracle needs, for each , : maximise a linear function over -ball ∩ simplex. Sort states by , put as much mass as the budget allows on the highest-value state, and take the excess mass from the lowest-value states. Total cost per oracle call. Combined with Algorithm 27 and the ellipsoid method, the optimistic policy is polynomial-time computable. (The original UCRL papers used extended value iteration, which is practical but not polynomial.)
Proof of the upper bound
ProofStep 1: Failure event and optimism
Let be the rounds of phase ( phases) and the event that for some . By the categorical concentration with a union bound over pairs and sample counts (the Markov property makes the samples effectively independent), (Lemma 38.8, Exercise 38.21). On the truth is plausible, so (optimism) and
∎
ProofStep 2: Regret within a phase via the Bellman equation
On , shift so that . For the Bellman equation in gives . Split the optimistic transition into the true one plus an error:
- (A) telescopes plus a martingale: inserting gives , using span for the boundary terms.
- (B) confidence widths: both and lie in the ball, so .
∎
ProofStep 3: Sum over phases
- Martingale: with probability , by Hoeffding–Azuma with a random range.
- Widths: doubling makes (Exercise 38.22, the discrete version of ). Then by Cauchy–Schwarz, .
- Number of phases: each pair’s count can double at most times, so , contributing .
Total: .
∎
IntuitionWhere and come from
- is the scale of value differences, because a transition error of size moves the value by up to .
- One comes from the radius of an -dimensional distribution. The other comes from Cauchy–Schwarz over pairs, giving .
Note 16: removing the spurious means bounding directly, but depends on . This dependence is “pernicious” and has spoiled several attempts.
Proof of the lower bound
DefinitionThe hard MDP
- A tree of states with branching factor at most and deterministic transitions, rooted at , with leaves .
- Two absorbing-ish states (reward 1) and (reward 0). Each stays put with probability and returns to the root with probability .
- From leaf , action goes to with probability , else to . Here except for one leaf–action pair, which has .
The diameter is at most regardless of (Claim 38.9).
IntuitionAn MDP that is secretly a bandit
Each visit to the root lets the learner pick one of leaf–action “meta-arms”, each a Bernoulli coin for entering the good state. Rewards then accrue for about rounds. So there are about decisions with stakes of about each, and the regret is about .
ProofProof of Theorem 38.7 (Assouad-style, as in Exercise 15.2)
Step 1: Setup. has no special pair, and makes pair special. Stop at , when the root has been visited about times. Let count plays of pair before , and . Claims: (Claim 38.10), and the regret in is (Claim 38.11; Exercise 38.24).
Step 2: Divergence. and differ only at pair , so by the stopped chain rule, for (38.22–38.23; Exercise 38.30).
Step 3: Pinsker and summing over . Since , . Summing over with Cauchy–Schwarz, for .
Step 4: some has . Then .
∎
Notes
WarningLarge MDPs are hard (Notes 1–2)
Real MDPs have millions or billions of states, so can be vacuous, and the lower bound says that without structural assumptions learning is genuinely hard. Choosing the state is a trade-off. It must be observable and Markov; enlarging it (the full history always works) improves fidelity but slows learning.
DefinitionVariants (Notes 3–8)
- Random rewards: a joint kernel over (next state, reward), with mean reward .
- Episodic MDPs: an absorbing state is reached almost surely. Average reward is meaningless there, so maximise total (possibly discounted) reward. Finite-horizon: absorption after a fixed number of steps.
- POMDPs: only observations of the state are seen. They can be converted to MDPs on histories or belief states (posteriors over the hidden state), but computing optimal policies is hard in general (Papadimitriou–Tsitsiklis 1987). Compare the Bayesian bandit posterior-as-state view.
- Terminology: agent / decision maker / controller; environment / plant; stochastic optimal control (control theory, average cost) versus multistage stochastic programming (operations research, episodic).
- Finer criteria: bias optimality (gain optimal and ), Blackwell optimality, -discount optimality.
WarningUCRL2 is brittle (Notes 13–14)
- Unreachable high-reward state: a single unreachable state whose reward exceeds forces linear regret, because the optimistic MDP keeps trying to reach it (Exercise 38.27). SCAL (Fruit et al. 2018) fixes this by working with the reachable sub-MDP.
- Traps, redefined (Exercise 38.29): the maximal end components (MECs) form a directed acyclic graph, and its sinks are closed, strongly connected sub-MDPs. Reasonable policies can’t control which sink they fall into, so regret should restart once trapped: , with the target . This definition still ignores how fast the learner gets trapped.
ExampleContextual bandits as MDPs (Exercise 38.25)
If for all , the next state ignores the action: a contextual bandit. The optimal policy is per-state greedy with gain . The diameter is (geometric hitting times). One UCB per state gives , as in one bandit per context. UCRL2’s is loose here: its bound pays for planning that this problem doesn’t need. (Worked here.)
ExampleRiverSwim (Exercise 38.26)
States . “Left” drifts back deterministically, with reward in state 1. “Right” swims against a current: up with probability 0.3, stay 0.6, down 0.1 (state 1: up 0.3, stay 0.7), with reward 1 in state (stay 0.9). Always swimming right gives a birth–death chain with up/down ratio 3, so and
far above . ε-greedy with empirical models stays near the bank: the reward is too far away to stumble upon. UCRL2 deliberately explores upstream because it is optimistic about unvisited states. (Gain worked here.)
RemarkHistory and the wider literature
- Foundations: Bellman (1954; his autobiography mentions encountering Thompson’s bandit paper); Puterman (OR view); Bertsekas (control view); Ross; Kallenberg’s notes; Arapostathis et al. on average-reward theory. RL: Sutton–Barto; Bertsekas–Tsitsiklis; Szepesvári (2010).
- Regret: UCRL/UCRL2 (Auer et al. 2009; Jaksch et al. 2010). PSRL, i.e. Thompson sampling for RL (Strens 2000; Osband et al. 2013). Agrawal–Jia (2017) attempted to improve the dependence, but the proof has unpatched holes. Episodic: via Bernstein/Freedman bonuses and backward induction (Azar et al. 2017), with large lower-order terms. Logarithmic instance-dependent bounds: Tewari–Bartlett (flawed constants), Auer–Ortner; asymptotically optimal constants with known supports (Burnetas–Katehakis 1997).
- Structured MDPs: LQR with regret (Abbasi-Yadkori–Szepesvári 2011); Lipschitz MDPs with (Ortner–Ryabko). Optimistic algorithms are often computationally intractable here, which Thompson sampling may fix.
- PAC-MDP (discounted): R-max, MBIE, delayed Q-learning, MorMax, UCRLγ.
- Adversarial rewards with stochastic transitions: Even-Dar et al. (2004); Neu et al. (2014). Fully adversarial: Abbasi-Yadkori et al. (2013).
Quick reference
| Object | Statement | Note |
|---|---|---|
| MDP | bandit = one state | |
| Diameter | finite iff strongly connected; | |
| Gain | average reward | |
| Value | Cesàro sum | |
| Poisson | ||
| Bellman | , | non-unique solutions |
| Optimality | greedy w.r.t. any solution is optimal; deterministic memoryless suffices | |
| Span | ||
| Discounted | is a -contraction | vanishing discount gives average reward |
| LP | s.t. ; then with | ellipsoid + oracle |
| Practice | value / policy iteration | no polynomial guarantee |
| Regret | ||
| Confidence set | ball, radius | categorical concentration |
| Extended MDP | choose (action, plausible ) | strongly connected; sort-based inner max |
| UCRL2 | optimistic plan, doubling phases | |
| Lower bound | tree → good/bad states ≈ bandit with arms | |
| Gap | dependent on |
Facts to keep to hand
- MDPs are bandits with consequences. The state carries the effect of past actions. Without traps (strong connectivity, finite diameter), average-reward optimality is constant across states and is achieved by a deterministic memoryless policy greedy with respect to any solution of the Bellman optimality equation.
- Planning is linear programming. The optimal gain and value function solve two LPs, polynomial-time via the ellipsoid method with a greedy separation oracle and the span ≤ diameter bound. In practice, value and policy iteration are used.
- Learning is optimism over MDPs. UCRL2 builds confidence balls on transitions, plans in the extended MDP where the agent also picks the most favourable plausible dynamics, and commits to that plan until some visit count doubles. Its regret is about : diameter from value spans, from widths and Cauchy–Schwarz.
- The lower bound is a disguised bandit. About meta-arms, each decision worth about rounds, give . Closing the gap is open and delicate, because the optimistic value function depends on the empirical model it would be paired with.
References
- Lattimore & Szepesvári, Bandit Algorithms — Chapter 38
- Jaksch, Ortner & Auer, “Near-optimal regret bounds for reinforcement learning” (2010)
- Puterman, Markov Decision Processes (2009); Bertsekas, Dynamic Programming and Optimal Control (2012)
- Sutton & Barto, Reinforcement Learning: An Introduction (2018)