Markov Decision Processes and Dynamic Programming

Similar documents
TD(0) Leads to Better Policies than Approximate Value Iteration

Reinforcement Learning

Reinforcement Learning

1 if 1 x 0 1 if 0 x 1

Metric Spaces. Chapter Metrics

Efficient Prediction of Value and PolicyPolygraphic Success

Algorithms for Reinforcement Learning

Computing Near Optimal Strategies for Stochastic Investment Planning Problems

MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.436J/15.085J Fall 2008 Lecture 5 9/17/2008 RANDOM VARIABLES

Vector and Matrix Norms

A linear algebraic method for pricing temporary life annuities

BANACH AND HILBERT SPACE REVIEW

MATH 304 Linear Algebra Lecture 9: Subspaces of vector spaces (continued). Span. Spanning set.

Math 4310 Handout - Quotient Vector Spaces

Systems of Linear Equations

Neuro-Dynamic Programming An Overview

1 Norms and Vector Spaces

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

Modern Optimization Methods for Big Data Problems MATH11146 The University of Edinburgh

Continued Fractions and the Euclidean Algorithm

Overview of Violations of the Basic Assumptions in the Classical Normal Linear Regression Model

Real Roots of Univariate Polynomials with Real Coefficients

Mathematical finance and linear programming (optimization)

CHAPTER 2 Estimating Probabilities

LECTURE 4. Last time: Lecture outline

The Steepest Descent Algorithm for Unconstrained Optimization and a Bisection Line-search Method

Inner Product Spaces

A FIRST COURSE IN OPTIMIZATION THEORY

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

1 The Brownian bridge construction

Call Admission Control and Routing in Integrated Service Networks Using Reinforcement Learning

2.3 Convex Constrained Optimization Problems

Master s Theory Exam Spring 2006

THE FUNDAMENTAL THEOREM OF ALGEBRA VIA PROPER MAPS

Probability Generating Functions

Monte Carlo Methods in Finance

Optimization under uncertainty: modeling and solution methods

Linear Threshold Units

Adaptive Online Gradient Descent

Factorization Theorems

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

On the mathematical theory of splitting and Russian roulette

Continuity of the Perron Root

Fixed Point Theorems

4.5 Linear Dependence and Linear Independence

What is Linear Programming?

Algebra Unpacked Content For the new Common Core standards that will be effective in all North Carolina schools in the school year.

NOV /II. 1. Let f(z) = sin z, z C. Then f(z) : 3. Let the sequence {a n } be given. (A) is bounded in the complex plane

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics

LS.6 Solution Matrices

Using Markov Decision Processes to Solve a Portfolio Allocation Problem

CONTINUED FRACTIONS AND PELL S EQUATION. Contents 1. Continued Fractions 1 2. Solution to Pell s Equation 9 References 12

Exam Introduction Mathematical Finance and Insurance

Introduction to Markov Chain Monte Carlo

VENDOR MANAGED INVENTORY

Linear Algebra I. Ronald van Luijk, 2012

Metric Spaces. Chapter 1

Data Mining: Algorithms and Applications Matrix Math Review

Linear Programming. March 14, 2014

16.3 Fredholm Operators

Linear Algebra Notes for Marsden and Tromba Vector Calculus

Lecture 5 Principal Minors and the Hessian

Differentiation and Integration

A Decomposition Approach for a Capacitated, Single Stage, Production-Inventory System

THE CENTRAL LIMIT THEOREM TORONTO

x1 x 2 x 3 y 1 y 2 y 3 x 1 y 2 x 2 y 1 0.

A Simultaneous Deterministic Perturbation Actor-Critic Algorithm with an Application to Optimal Mortgage Refinancing

Classification of Cartan matrices

Inner Product Spaces and Orthogonality

by the matrix A results in a vector which is a reflection of the given

Separation Properties for Locally Convex Cones

Similarity and Diagonalization. Similar Matrices

The last three chapters introduced three major proof techniques: direct,

1 Short Introduction to Time Series

THE BANACH CONTRACTION PRINCIPLE. Contents

Coordinated Pricing and Inventory in A System with Minimum and Maximum Production Constraints

How To Solve A Sequential Mca Problem

Linear-Quadratic Optimal Controller 10.3 Optimal Linear Control Systems

Numerical Methods I Eigenvalue Problems

Two-Stage Stochastic Linear Programs

Lecture notes: single-agent dynamics 1

MATH 304 Linear Algebra Lecture 20: Inner product spaces. Orthogonal sets.

1 Teaching notes on GMM 1.

3. INNER PRODUCT SPACES

MULTIVARIATE PROBABILITY DISTRIBUTIONS

Metric Spaces Joseph Muscat 2003 (Last revised May 2009)

PUTNAM TRAINING POLYNOMIALS. Exercises 1. Find a polynomial with integral coefficients whose zeros include

THE FUNDAMENTAL THEOREM OF ARBITRAGE PRICING

Finitely Additive Dynamic Programming and Stochastic Games. Bill Sudderth University of Minnesota

Statistical Machine Translation: IBM Models 1 and 2

Lecture 13 Linear quadratic Lyapunov theory

Mathematical Methods of Engineering Analysis

0 <β 1 let u(x) u(y) kuk u := sup u(x) and [u] β := sup

Monte Carlo-based statistical methods (MASM11/FMS091)

Optimal proportional reinsurance and dividend pay-out for insurance companies with switching reserves

MATH 423 Linear Algebra II Lecture 38: Generalized eigenvectors. Jordan canonical form (continued).

Universal Algorithm for Trading in Stock Market Based on the Method of Calibration

Adaptive Search with Stochastic Acceptance Probabilities for Global Optimization

Example 4.1 (nonlinear pendulum dynamics with friction) Figure 4.1: Pendulum. asin. k, a, and b. We study stability of the origin x

Duality of linear conic problems

Transcription:

Markov Decision Processes and Dynamic Programming A. LAZARIC (SequeL Team @INRIA-Lille) ENS Cachan - Master 2 MVA SequeL INRIA Lille MVA-RL Course

In This Lecture How do we formalize the agent-environment interaction? Markov Decision Process (MDP) How do we solve an MDP? Dynamic Programming A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-2/79

Mathematical Tools Outline Mathematical Tools The Markov Decision Process Bellman Equations for Discounted Infinite Horizon Problems Bellman Equations for Uniscounted Infinite Horizon Problems Dynamic Programming Conclusions A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-3/79

Mathematical Tools Probability Theory Definition (Conditional probability) Given two events A and B with P(B) > 0, the conditional probability of A given B is P(A B) = P(A B). P(B) Similarly, if X and Y are non-degenerate and jointly continuous random variables with density f X,Y (x, y) then if B has positive measure then the conditional probability is y B x A P(X A Y B) = f X,Y (x, y)dxdy x f X,Y (x, y)dxdy. y B A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-4/79

Mathematical Tools Probability Theory Definition (Law of total expectation) Given a function f and two random variables X, Y we have that E X,Y [ f (X, Y ) ] = EX [E Y [ f (x, Y ) X = x ] ]. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-5/79

Mathematical Tools Norms and Contractions Definition Given a vector space V R d a function f : V R + 0 an only if If f (v) = 0 for some v V, then v = 0. For any λ R, v V, f (λv) = λ f (v). is a norm if Triangle inequality: For any v, u V, f (v + u) f (v) + f (u). A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-6/79

Mathematical Tools Norms and Contractions L p -norm L -norm ( d ) 1/p v p = v i p. i=1 v = max 1 i d v i. L µ,p -norm L µ,p -norm ( d v µ,p = i=1 v i p ) 1/p. µ i v i v µ, = max. 1 i d µ i L 2,P -matrix norm (P is a positive definite matrix) v 2 P = v Pv. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-7/79

Mathematical Tools Norms and Contractions Definition A sequence of vectors v n V (with n N) is said to converge in norm to v V if lim n v n v = 0. Definition A sequence of vectors v n V (with n N) is a Cauchy sequence if Definition lim sup m n v n v m = 0. n A vector space V equipped with a norm is complete if every Cauchy sequence in V is convergent in the norm of the space. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-8/79

Mathematical Tools Norms and Contractions Definition An operator T : V V is L-Lipschitz if for any v, u V T v T u L u v. If L 1 then T is a non-expansion, while if L < 1 then T is a L-contraction. If T is Lipschitz then it is also continuous, that is Definition if v n v then T v n T v. A vector v V is a fixed point of the operator T : V V if T v = v. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-9/79

Mathematical Tools Norms and Contractions Proposition (Banach Fixed Point Theorem) Let V be a complete vector space equipped with the norm and T : V V be a γ-contraction mapping. Then 1. T admits a unique fixed point v. 2. For any v 0 V, if v n+1 = T v n then v n v with a geometric convergence rate: v n v γ n v 0 v. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-10/79

Mathematical Tools Linear Algebra Given a square matrix A R N N : Eigenvalues of a matrix (1). v R N and λ R are eigenvector and eigenvalue of A if Av = λv. Eigenvalues of a matrix (2). If A has eigenvalues {λ i } N i=1, then B = (I αa) has eigenvalues {µ i } µ i = 1 αλ i. Matrix inversion. A can be inverted if and only if i, λ i 0. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-11/79

Mathematical Tools Linear Algebra Stochastic matrix. A square matrix P R N N is a stochastic matrix if 1. all non-zero entries, i, j, [P] i,j 0 2. all the rows sum to one, i, N j=1 [P] i,j = 1. All the eigenvalues of a stochastic matrix are bounded by 1, i.e., i, λ i 1. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-12/79

The Markov Decision Process Outline Mathematical Tools The Markov Decision Process Bellman Equations for Discounted Infinite Horizon Problems Bellman Equations for Uniscounted Infinite Horizon Problems Dynamic Programming Conclusions A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-13/79

The Markov Decision Process The Reinforcement Learning Model Environment Critic action / actuation reward state / perception Learning Agent A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-14/79

The Markov Decision Process Markov Chains Definition (Markov chain) Let the state space X be a bounded compact subset of the Euclidean space, the discrete-time dynamic system (x t ) t N X is a Markov chain if it satisfies the Markov property P(x t+1 = x x t, x t 1,..., x 0 ) = P(x t+1 = x x t ), Given an initial state x 0 X, a Markov chain is defined by the transition probability p p(y x) = P(x t+1 = y x t = x). A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-15/79

The Markov Decision Process Markov Decision Process Definition (Markov decision process [1, 4, 3, 5, 2]) A Markov decision process is defined as a tuple M = (X, A, p, r) where X is the state space, A is the action space, p(y x, a) is the transition probability with p(y x, a) = P(x t+1 = y x t = x, a t = a), r(x, a, y) is the reward of transition (x, a, y). A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-16/79

The Markov Decision Process Policy Definition (Policy) A decision rule π t can be Deterministic: π t : X A, Stochastic: π t : X (A), A policy (strategy, plan) can be Non-stationary: π = (π 0, π 1, π 2,... ), Stationary (Markovian): π = (π, π, π,... ). Remark: MDP M + stationary policy π Markov chain of state X and transition probability p(y x) = p(y x, π(x)). A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-17/79

The Markov Decision Process Question Is the MDP formalism powerful enough? Let s try! A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-18/79

The Markov Decision Process Example: the Retail Store Management Problem Description. At each month t, a store contains x t items of a specific goods and the demand for that goods is D t. At the end of each month the manager of the store can order a t more items from his supplier. Furthermore we know that The cost of maintaining an inventory of x is h(x). The cost to order a items is C(a). The income for selling q items is f (q). If the demand D is bigger than the available inventory x, customers that cannot be served leave. The value of the remaining inventory at the end of the year is g(x). Constraint: the store has a maximum capacity M. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-19/79

The Markov Decision Process Example: the Retail Store Management Problem State space: x X = {0, 1,..., M}. Action space: it is not possible to order more items that the capacity of the store, then the action space should depend on the current state. Formally, at statex, a A(x) = {0, 1,..., M x}. Dynamics: x t+1 = [x t + a t D t ] +. Problem: the dynamics should be Markov and stationary! The demand D t is stochastic and time-independent. Formally, D t i.i.d. D. Reward: r t = C(a t ) h(x t + a t ) + f ([x t + a t x t+1 ] + ). A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-20/79

The Markov Decision Process Exercise: the Parking Problem A driver wants to park his car as close as possible to the restaurant. 1 2 Reward t T p(t) Restaurant Reward 0 The driver cannot see whether a place is available unless he is in front of it. There are P places. At each place i the driver can either move to the next place or park (if the place is available). The closer to the restaurant the parking, the higher the satisfaction. If the driver doesn t park anywhere, then he/she leaves the restaurant and has to find another one. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-21/79

The Markov Decision Process Question How do we evaluate a policy and compare two policies? Value function! A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-22/79

The Markov Decision Process Optimization over Time Horizon Finite time horizon T : deadline at time T, the agent focuses on the sum of the rewards up to T. Infinite time horizon with discount: the problem never terminates but rewards which are closer in time receive a higher importance. Infinite time horizon with terminal state: the problem never terminates but the agent will eventually reach a termination state. Infinite time horizon with average reward: the problem never terminates but the agent only focuses on the (expected) average of the rewards. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-23/79

The Markov Decision Process State Value Function Finite time horizon T : deadline at time T, the agent focuses on the sum of the rewards up to T. [ T 1 ] V π (t, x) = E r(x s, π s (x s )) + R(x T ) x t = x; π, s=t where R is a value function for the final state. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-24/79

The Markov Decision Process State Value Function Infinite time horizon with discount: the problem never terminates but rewards which are closer in time receive a higher importance. [ ] V π (x) = E γ t r(x t, π(x t )) x 0 = x; π, t=0 with discount factor 0 γ < 1: small = short-term rewards, big = long-term rewards for any γ [0, 1) the series always converge (for bounded rewards) A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-25/79

The Markov Decision Process State Value Function Infinite time horizon with terminal state: the problem never terminates but the agent will eventually reach a termination state. [ T ] V π (x) = E r(x t, π(x t )) x 0 = x; π, t=0 where T is the first (random) time when the termination state is achieved. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-26/79

The Markov Decision Process State Value Function Infinite time horizon with average reward: the problem never terminates but the agent only focuses on the (expected) average of the rewards. [ 1 V π (x) = lim E T T T 1 t=0 ] r(x t, π(x t )) x 0 = x; π. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-27/79

The Markov Decision Process State Value Function Technical note: the expectations refer to all possible stochastic trajectories. A non-stationary policy π applied from state x 0 returns (x 0, r 0, x 1, r 1, x 2, r 2,...) with r t = r(x t, π t (x t )) and x t p( x t 1, a t = π(x t )) are random realizations. The value function (discounted infinite horizon) is V π (x) = E (x1,x 2,...) [ t=0 ] γ t r(x t, π(x t )) x 0 = x; π, A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-28/79

The Markov Decision Process Optimal Value Function Definition (Optimal policy and optimal value function) The solution to an MDP is an optimal policy π satisfying π arg max π Π V π in all the states x X, where Π is some policy set of interest. The corresponding value function is the optimal value function V = V π. Remark: π arg max( ) and not π = arg max( ) because an MDP may admit more than one optimal policy. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-29/79

The Markov Decision Process Example: the MVA student dilemma 1 p=0.5 Rest 0.5 2 r=1 Rest 0.4 r= 10 r=0 Work Work 0.3 0.4 0.6 5 0.5 0.5 0.7 Rest 0.6 r=100 r= 1 3 0.5 Work 0.5 r= 10 0.9 Rest 0.1 1 Work 4 6 7 r= 1000 A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-30/79

The Markov Decision Process Example: the MVA student dilemma Model: all the transitions are Markov, states x 5, x 6, x 7 are terminal. Setting: infinite horizon with terminal states. Objective: find the policy that maximizes the expected sum of rewards before achieving a terminal state. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-31/79

The Markov Decision Process Example: the MVA student dilemma V = 88.3 1 r=0 0.5 Rest Work r= 1 V = 86.9 3 p=0.5 0.5 Work 0.5 r=1 0.5 0.3 0.4 0.7 Rest 0.6 Work 0.5 r= 10 V = 88.9 4 V = 88.3 2 Rest 0.6 0.9 Rest Work 0.4 0.1 1 r=100 r= 10 V = 10 5 V = 100 6 r= 1000 V = 1000 7 A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-32/79

The Markov Decision Process Example: the MVA student dilemma V 7 = 1000 V 6 = 100 V 5 = 10 V 4 = 10 + 0.9V 6 + 0.1V 4 88.9 V 3 = 1 + 0.5V 4 + 0.5V 3 86.9 V 2 = 1 + 0.7V 3 + 0.3V 1 V 1 = max{0.5v 2 + 0.5V 1, 0.5V 3 + 0.5V 1 } V 1 = V 2 = 88.3 A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-33/79

The Markov Decision Process State-Action Value Function Definition In discounted infinite horizon problems, for any policy π, the state-action value function (or Q-function) Q π : X A R is [ ] Q π (x, a) = E γ t r(x t, a t ) x 0 = x, a 0 = a, a t = π(x t ), t 1, t 0 and the corresponding optimal Q-function is Q (x, a) = max π Qπ (x, a). A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-34/79

The Markov Decision Process State-Action Value Function The relationships between the V-function and the Q-function are: Q π (x, a) = r(x, a) + γ p(y x, a)v π (y) y X V π (x) = Q π (x, π(x)) Q (x, a) = r(x, a) + γ p(y x, a)v (y) y X V (x) = Q (x, π (x)) = max a A Q (x, a). A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-35/79

Bellman Equations for Discounted Infinite Horizon Problems Outline Mathematical Tools The Markov Decision Process Bellman Equations for Discounted Infinite Horizon Problems Bellman Equations for Uniscounted Infinite Horizon Problems Dynamic Programming Conclusions A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-36/79

Bellman Equations for Discounted Infinite Horizon Problems Question Is there any more compact way to describe a value function? Bellman equations! A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-37/79

Bellman Equations for Discounted Infinite Horizon Problems The Bellman Equation Proposition For any stationary policy π = (π, π,... ), the state value function at a state x X satisfies the Bellman equation: V π (x) = r(x, π(x)) + γ y p(y x, π(x))v π (y). A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-38/79

Bellman Equations for Discounted Infinite Horizon Problems The Bellman Equation Proof. For any policy π, V π (x) = E [ γ t r(x t, π(x t )) x 0 = x; π ] t 0 = r(x, π(x)) + E [ γ t r(x t, π(x t )) x 0 = x; π ] = r(x, π(x)) + γ y = r(x, π(x)) + γ y t 1 P(x 1 = y x 0 = x; π(x 0 ))E [ γ t 1 r(x t, π(x t )) x 1 = y; π ] p(y x, π(x))v π (y). t 1 A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-39/79

Bellman Equations for Discounted Infinite Horizon Problems The Optimal Bellman Equation Bellman s Principle of Optimality [1]: An optimal policy has the property that, whatever the initial state and the initial decision are, the remaining decisions must constitute an optimal policy with regard to the state resulting from the first decision. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-40/79

Bellman Equations for Discounted Infinite Horizon Problems The Optimal Bellman Equation Proposition The optimal value function V (i.e., V = max π V π ) is the solution to the optimal Bellman equation: V [ (x) = max a A r(x, a) + γ p(y x, a)v (y) ]. and the optimal policy is π (x) = arg max a A y [ r(x, a) + γ p(y x, a)v (y) ]. y A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-41/79

Bellman Equations for Discounted Infinite Horizon Problems The Optimal Bellman Equation Proof. For any policy π = (a, π ) (possibly non-stationary), V (x) (a) = max π E[ γ t r(x t, π(x t )) x 0 = x; π ] t 0 [ (b) = max r(x, a) + γ (a,π ) y (c) = max a (d) = max a [ r(x, a) + γ y [ r(x, a) + γ y ] p(y x, a)v π (y) ] p(y x, a) max V π (y) π ] p(y x, a)v (y). A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-42/79

Bellman Equations for Discounted Infinite Horizon Problems The Bellman Operators Notation. w.l.o.g. a discrete state space X = N and V π R N. Definition For any W R N, the Bellman operator T π : R N R N is T π W (x) = r(x, π(x)) + γ y p(y x, π(x))w (y), and the optimal Bellman operator (or dynamic programming operator) is [ T W (x) = max a A r(x, a) + γ p(y x, a)w (y) ]. y A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-43/79

Bellman Equations for Discounted Infinite Horizon Problems The Bellman Operators Proposition Properties of the Bellman operators 1. Monotonicity: for any W 1, W 2 R N, if W 1 W 2 component-wise, then 2. Offset: for any scalar c R, T π W 1 T π W 2, T W 1 T W 2. T π (W + ci N ) = T π W + γci N, T (W + ci N ) = T W + γci N, A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-44/79

Bellman Equations for Discounted Infinite Horizon Problems The Bellman Operators Proposition 3. Contraction in L -norm: for any W 1, W 2 R N T π W 1 T π W 2 γ W 1 W 2, 4. Fixed point: For any policy π T W 1 T W 2 γ W 1 W 2. V π is the unique fixed point of T π, V is the unique fixed point of T. Furthermore for any W R N and any stationary policy π lim (T π ) k W = V π, k lim (T k )k W = V. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-45/79

Bellman Equations for Discounted Infinite Horizon Problems The Bellman Equation Proof. The contraction property (3) holds since for any x X we have T W 1(x) T W 2(x) [ = max r(x, a) + γ p(y x, a)w ] [ a 1(y) max r(x, a ) + γ a y y (a) max a = γ max a [ r(x, a) + γ p(y x, a)w ] 1(y) [ r(x, a) + γ y y p(y x, a) W 1(y) W 2(y) y γ W 1 W 2 max a p(y x, a) = γ W 1 W 2, y p(y x, a )W 2(y) ] p(y x, a)w 2(y) ] where in (a) we used max a f (a) max a g(a ) max a(f (a) g(a)). A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-46/79

Bellman Equations for Discounted Infinite Horizon Problems Exercise: Fixed Point Revise the Banach fixed point theorem and prove the fixed point property of the Bellman operator. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-47/79

Bellman Equations for Uniscounted Infinite Horizon Problems Outline Mathematical Tools The Markov Decision Process Bellman Equations for Discounted Infinite Horizon Problems Bellman Equations for Uniscounted Infinite Horizon Problems Dynamic Programming Conclusions A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-48/79

Bellman Equations for Uniscounted Infinite Horizon Problems Question Is there any more compact way to describe a value function when we consider an infinite horizon with no discount? Proper policies and Bellman equations! A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-49/79

Bellman Equations for Uniscounted Infinite Horizon Problems The Undiscounted Infinite Horizon Setting The value function is [ T ] V π (x) = E r(x t, π(x t )) x 0 = x; π, t=0 where T is the first random time when the agent achieves a terminal state. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-50/79

Bellman Equations for Uniscounted Infinite Horizon Problems Proper Policies Definition A stationary policy π is proper if n N such that x X the probability of achieving the terminal state x after n steps is strictly positive. That is ρ π = max x P(x n x x 0 = x, π) < 1. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-51/79

Bellman Equations for Uniscounted Infinite Horizon Problems Bounded Value Function Proposition For any proper policy π with parameter ρ π after n steps, the value function is bounded as V π r max ρ t/n π. t 0 A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-52/79

Bellman Equations for Uniscounted Infinite Horizon Problems The Undiscounted Infinite Horizon Setting Proof. By definition of proper policy P(x 2n x x 0 = x, π) = P(x 2n x x n x, π) P(x n x x 0 = x, π) ρ 2 π. Then for any t N P(x t x x 0 = x, π) ρ t/n π, which implies that eventually the terminal state x is achieved with probability 1. Then V π = max E[ r(x t, π(x t )) x 0 = x; π ] x X t=0 r max P(x t x x 0 = x, π) t>0 nr max + r max t n ρ t/n π. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-53/79

Bellman Equations for Uniscounted Infinite Horizon Problems Bellman Operator Assumption. There exists at least one proper policy and for any non-proper policy π there exists at least one state x where V π (x) = (cycles with only negative rewards). Proposition ([2]) Under the previous assumption, the optimal value function is bounded, i.e., V < and it is the unique fixed point of the optimal Bellman operator T such that for any vector W R n T W (x) = max a A [ r(x, a) + p(y x, a)w (y)]. y Furthermore V = lim k (T ) k W. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-54/79

Bellman Equations for Uniscounted Infinite Horizon Problems Bellman Operator Proposition Let all the policies π be proper, then there exist µ R N with µ > 0 and a scalar β < 1 such that, x, y X, a A, p(y x, a)µ(y) βµ(x). y Thus both operators T and T π are contraction in the weighted norm L,µ, that is T W 1 T W 2,µ β W 1 W 2,µ. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-55/79

Bellman Equations for Uniscounted Infinite Horizon Problems Bellman Operator Proof. Let µ be the maximum (over policies) of the average time to the termination state. This can be easily casted to a MDP where for any action and any state the rewards are 1 (i.e., for any x X and a A, r(x, a) = 1). Under the assumption that all the policies are proper, then µ is finite and it is the solution to the dynamic programming equation µ(x) = 1 + max p(y x, a)µ(y). a Then µ(x) 1 and for any a A, µ(x) 1 + y p(y x, a)µ(y). Furthermore, p(y x, a)µ(y) µ(x) 1 βµ(x), y y for β = max x µ(x) 1 µ(x) < 1. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-56/79

Bellman Equations for Uniscounted Infinite Horizon Problems Bellman Operator Proof (cont d). From this definition of µ and β we obtain the contraction property of T (similar for T π ) in norm L,µ : T W 1 T W 2,µ = max x max x,a max x,a T W 1 (x) T W 2 (x) µ(x) y p(y x, a) W 1 (y) W 2 (y) µ(x) y p(y x, a)µ(y) W 1 W 2 µ µ(x) β W 1 W 2 µ A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-57/79

Dynamic Programming Outline Mathematical Tools The Markov Decision Process Bellman Equations for Discounted Infinite Horizon Problems Bellman Equations for Uniscounted Infinite Horizon Problems Dynamic Programming Conclusions A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-58/79

Dynamic Programming Question How do we compute the value functions / solve an MDP? Value/Policy Iteration algorithms! A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-59/79

Dynamic Programming System of Equations The Bellman equation V π (x) = r(x, π(x)) + γ y p(y x, π(x))v π (y). is a linear system of equations with N unknowns and N linear constraints. The optimal Bellman equation V [ (x) = max a A r(x, a) + γ p(y x, a)v (y) ]. is a (highly) non-linear system of equations with N unknowns and N non-linear constraints (i.e., the max operator). y A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-60/79

Dynamic Programming Value Iteration: the Idea 1. Let V 0 be any vector in R N 2. At each iteration k = 1, 2,..., K Compute Vk+1 = T V k 3. Return the greedy policy π K (x) arg max a A [ r(x, a) + γ y ] p(y x, a)v K (y). A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-61/79

Dynamic Programming Value Iteration: the Guarantees From the fixed point property of T : lim V k = V k From the contraction property of T V k+1 V = T V k T V γ V k V γ k+1 V 0 V 0 Convergence rate. Let ɛ > 0 and r r max, then after at most iterations V K V ɛ. K = log(r max/ɛ) log(1/γ) A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-62/79

Dynamic Programming Value Iteration: the Complexity One application of the optimal Bellman operator takes O(N 2 A ) operations. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-63/79

Dynamic Programming Value Iteration: Extensions and Implementations Q-iteration. 1. Let Q 0 be any Q-function 2. At each iteration k = 1, 2,..., K Compute Q k+1 = T Q k 3. Return the greedy policy Asynchronous VI. 1. Let V 0 be any vector in R N π K (x) arg max a A Q(x,a) 2. At each iteration k = 1, 2,..., K Choose a state x k Compute V k+1 (x k ) = T V k (x k ) 3. Return the greedy policy π K (x) arg max a A [ r(x, a) + γ p(y x, a)v K (y) ]. y A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-64/79

Dynamic Programming Policy Iteration: the Idea 1. Let π 0 be any stationary policy 2. At each iteration k = 1, 2,..., K Policy evaluation given πk, compute V π k. Policy improvement: compute the greedy policy [ π k+1 (x) arg max a A r(x, a) + γ p(y x, a)v π k (y) ]. 3. Return the last policy π K y Remark: usually K is the smallest k such that V π k = V π k+1. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-65/79

Dynamic Programming Policy Iteration: the Guarantees Proposition The policy iteration algorithm generates a sequences of policies with non-decreasing performance V π k+1 V π k, and it converges to π in a finite number of iterations. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-66/79

Dynamic Programming Policy Iteration: the Guarantees Proof. From the definition of the Bellman operators and the greedy policy π k+1 V π k = T π k V π k T V π k = T π k+1 V π k, (1) and from the monotonicity property of T π k+1, it follows that V π k T π k+1 V π k, T π k+1 V π k (T π k+1 ) 2 V π k,... (T π k+1 ) n 1 V π k (T π k+1 ) n V π k,... Joining all the inequalities in the chain we obtain V π k lim n (T π k+1 ) n V π k = V π k+1. Then (V π k ) k is a non-decreasing sequence. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-67/79

Dynamic Programming Policy Iteration: the Guarantees Proof (cont d). Since a finite MDP admits a finite number of policies, then the termination condition is eventually met for a specific k. Thus eq. 1 holds with an equality and we obtain V π k = T V π k and V π k = V which implies that π k is an optimal policy. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-68/79

Dynamic Programming Exercise: Convergence Rate Read the more refined convergence rates in: Improved and Generalized Upper Bounds on the Complexity of Policy Iteration by B. Scherrer. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-69/79

Dynamic Programming Policy Iteration Notation. For any policy π the reward vector is r π (x) = r(x, π(x)) and the transition matrix is [P π ] x,y = p(y x, π(x)) A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-70/79

Dynamic Programming Policy Iteration: the Policy Evaluation Step Direct computation. For any policy π compute V π = (I γp π ) 1 r π. Complexity: O(N 3 ) (improvable to O(N 2.807 )). Exercise: prove the previous equality. Iterative policy evaluation. For any policy π lim T π V 0 = V π. n Complexity: An ɛ-approximation of V π requires O(N 2 log 1/ɛ log 1/γ ) steps. Monte-Carlo simulation. In each state x, simulate n trajectories ((x i t ) t 0, ) 1 i n following policy π and compute ˆV π (x) 1 n n γ t r(xt i, π(xt i )). i=1 t 0 Complexity: In each state, the approximation error is O(1/ n). A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-71/79

Dynamic Programming Policy Iteration: the Policy Improvement Step If the policy is evaluated with V, then the policy improvement has complexity O(N A ) (computation of an expectation). If the policy is evaluated with Q, then the policy improvement has complexity O( A ) corresponding to π k+1 (x) arg max Q(x, a), a A A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-72/79

Dynamic Programming Comparison between Value and Policy Iteration Value Iteration Pros: each iteration is very computationally efficient. Cons: convergence is only asymptotic. Policy Iteration Pros: converge in a finite number of iterations (often small in practice). Cons: each iteration requires a full policy evaluation and it might be expensive. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-73/79

Dynamic Programming Exercise: Review Extensions to Standard DP Algorithms Modified Policy Iteration λ-policy Iteration A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-74/79

Dynamic Programming Exercise: Review Linear Programming Linear Programming: a one-shot approach to computing V A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-75/79

Conclusions Outline Mathematical Tools The Markov Decision Process Bellman Equations for Discounted Infinite Horizon Problems Bellman Equations for Uniscounted Infinite Horizon Problems Dynamic Programming Conclusions A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-76/79

Conclusions Things to Remember The Markov Decision Process framework The discounted infinite horizon setting State and state-action value function Bellman equations and Bellman operators The value and policy iteration algorithms A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-77/79

Conclusions Bibliography I R. E. Bellman. Dynamic Programming. Princeton University Press, Princeton, N.J., 1957. D.P. Bertsekas and J. Tsitsiklis. Neuro-Dynamic Programming. Athena Scientific, Belmont, MA, 1996. W. Fleming and R. Rishel. Deterministic and stochastic optimal control. Applications of Mathematics, 1, Springer-Verlag, Berlin New York, 1975. R. A. Howard. Dynamic Programming and Markov Processes. MIT Press, Cambridge, MA, 1960. M.L. Puterman. Markov Decision Processes: Discrete Stochastic Dynamic Programming. John Wiley & Sons, Inc., New York, Etats-Unis, 1994. A. LAZARIC Markov Decision Processes and Dynamic Programming Oct 1st, 2013-78/79

Conclusions Reinforcement Learning Alessandro Lazaric alessandro.lazaric@inria.fr sequel.lille.inria.fr