Lecture 2: Markov Decision Processes

Author:David Silver

Outline

  1. Markov Processes
  2. Markov Reward Processes
  3. Markov Decision Processes
  4. Extensions to MDPs

Introduction to MDPs

  • Markov decision processes formally describe anenvironment` for reinforcement learning
  • Where the environment is fully observable
  • i.e. The current state completely characterises the process
  • Almost all RL problems can be formalised as MDPs, e.g.
    • Optimal control primarily deals with continuous MDPs
    • Partially observable problems can be converted into MDPs
    • Bandits are MDPs with one state

Markov Property

“The future is independent of the past given the present”

  • The state captures all relevantinformation from the history
  • Once the state is known, the history may be thrown away
  • i.e. The state is a sufficient statistic of the future

State Transition Matrix

For a Markov state s and successor state s' , the state transition probability is defined by

P_{ss'}=P[S_{t+1}=s'|S_t=s]

State transition matrix P defines transition probabilities from all states s to all successor states s',

where each row of the matrix sums to 1.

Markov Process

A Markov process is a memoryless random process, i.e. a sequence of random states S_1, S_2, ... with the Markov property.

Example: Student Markov Chain

Example: Student Markov Chain Episodes

Example: Student Markov Chain Transition Matrix

Markov Reward Process

A Markov reward process is a Markov chain with values.

Example: Student MRP

Return

  • The discount \gamma \in [0, 1] is the present value of future rewards
  • The value of receiving reward R after k + 1 time-steps is \gamma^kR .
  • This values immediate reward above delayed reward.
    • \gamma close to 0 leads to ”myopic” evaluation
  • \gamma close to 1 leads to ”far-sighted” evaluation

Why discount?

Most Markov reward and decision processes are discounted. Why?

  • Mathematically convenient to discount rewards
  • Avoids infinite returns in cyclic Markov processes
  • Uncertainty about the future may not be fully represented
  • If the reward is financial, immediate rewards may earn more interest than delayed rewards
  • Animal/human behaviour shows preference for immediate reward
  • It is sometimes possible to use undiscounted Markov reward processes (i.e. \gamma = 1), e.g. if all sequences terminate.

Value Function

The value function v(s) gives the long-term value of state s.

Example: Student MRP Returns

Example: State-Value Function for Student MRP (1)

Example: State-Value Function for Student MRP (2)

Example: State-Value Function for Student MRP (3)

Bellman Equation for MRPs

The value function can be decomposed into two parts:

  • immediate reward R_{t+1}
  • discounted value of successor state \gamma v(S_{t+1})

Bellman Equation for MRPs (2)

Example: Bellman Equation for Student MRP

Bellman Equation in Matrix Form

The Bellman equation can be expressed concisely using matrices,

v = R+\gamma Pv

where v is a column vector with one entry per state

\begin{bmatrix} v(1) \\ \vdots\\ v(n) \end{bmatrix}=\begin{bmatrix} R_1 \\ \vdots\\ R_n \end{bmatrix} + \gamma \begin{bmatrix} P_{11} & \dots & P_{1n}\\ \vdots \\ P_{n1} & \dots & P_{nn} \end{bmatrix}\begin{bmatrix} v(1) \\ \vdots\\ v(n) \end{bmatrix}

Solving the Bellman Equation

  • The Bellman equation is a linear equation
  • It can be solved directly:

v=R+\gamma Pv
(I-\gamma P)v=R
v=(I-\gamma P)^{-1}R

  • Computational complexity is O(n^3) for n states
  • Direct solution only possible for small MRPs
  • There are many iterative methods for large MRPs, e.g.
    • Dynamic programming
    • Monte-Carlo evaluation
    • Temporal-Difference learning

Markov Decision Process

A Markov decision process (MDP) is a Markov reward process with decisions. It is an environment in which all states are Markov.

Example: Student MDP

Policies (1)

  • A policy fully defines the behaviour of an agent
  • MDP policies depend on the current state (not the history)
  • i.e. Policies are stationary (time-independent), A_t \sim \pi(\cdot|S_t),\forall t>0

Policies (2)

  • Given an MDP M = <S,A,P,R,\gamma> and a policy \pi
  • The state sequence S_1, S_2, ... is a Markov process <S, P^{\pi}>
  • The state and reward sequence S_1, R_2, S_2, ... is a Markov reward process <S, P^{\pi}, R^{\pi}, \gamma>
  • where

P^{\pi}_{s,s'}=\sum_{a\in A}\pi(a|s)P_{ss'}^a
R_s^{\pi}=\sum_{a\in A}\pi(a|s)R_s^a

Value Function

Example: State-Value Function for Student MDP

Bellman Expectation Equation

The state-value function can again be decomposed into immediate reward plus discounted value of successor state,

v_{\pi}(s)=E_{\pi}[R_{t+1}+\gamma v_{\pi}(S_{t+1})|S_t=s]

The action-value function can similarly be decomposed,

q_{\pi}(s,a)=E_{\pi}[R_{t+1}+\gamma q_{\pi}(S_{t+1},A_{t+1})|S_t=s,A_t=a]

Bellman Expectation Equation for V^{\pi}

Bellman Expectation Equation for Q^{\pi}

Bellman Expectation Equation for v_{\pi} (2)

Bellman Expectation Equation for q_{\pi} (2)

Example: Bellman Expectation Equation in Student MDP

Bellman Expectation Equation (Matrix Form)

The Bellman expectation equation can be expressed concisely using the induced MRP,

v_{\pi}=R^{\pi}+\gamma P^{\pi}v_{\pi}

with direct solution

v_{\pi}=(I-\gamma P^{\pi})^{-1}R^{\pi}

Optimal Value Function

  • The optimal value function specifies the best possible performance in the MDP.
  • An MDP is “solved” when we know the optimal value fn (v+q).

Example: Optimal Value Function for Student MDP

Example: Optimal Action-Value Function for Student MDP

Optimal Policy

Define a partial ordering over policies:

\pi \geq \pi' \mbox{ if } v_{\pi}(s)\geq v_{\pi'}(s), \forall_s

Finding an Optimal Policy

An optimal policy can be found by maximising over q_∗(s,a),

\pi_{*}(a|s) = \begin{cases} 1, & \mbox{if }a=\argmax_{a\in A}q_{*}(s,a) \\ 0, & \mbox{otherwise } \end{cases}

  • There is always a deterministic optimal policy for any MDP
  • If we know q_∗(s,a), we immediately have the optimal policy

Example: Optimal Policy for Student MDP

Bellman Optimality Equation for v_*

Bellman Optimality Equation for Q_*

Bellman Optimality Equation for V^* (2)

Bellman Optimality Equation for Q^* (2)

Example: Bellman Optimality Equation in Student MDP

Solving the Bellman Optimality Equation

  • Bellman Optimality Equation is non-linear
  • No closed form solution (in general)
  • Many iterative solution methods
    • Value Iteration
    • Policy Iteration
    • Q-learning
    • Sarsa

Extensions to MDPs (no exam)

  • Infinite and continuous MDPs
  • Partially observable MDPs
  • Undiscounted, average reward MDPs

Infinite MDPs (no exam)

The following extensions are all possible:

  • Countably infinite state and/or action spaces
    • Straightforward
  • Continuous state and/or action spaces
    • Closed form for linear quadratic model (LQR)
  • Continuous time
    • Requires partial differential equations
    • Hamilton-Jacobi-Bellman (HJB) equation
    • Limiting case of Bellman equation as time-step → 0

POMDPs (no exam)

Belief States (no exam)

Reductions of POMDPs (no exam)

Ergodic Markov Process (no exam)

Ergodic MDP (no exam)

Average Reward Value Function (no exam)

Questions?

The only stupid question is the one you were afraid to ask but never did.
-Rich Sutton

Reference:《UCL Course on RL》

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,014评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,796评论 3 386
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,484评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,830评论 1 285
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,946评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,114评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,182评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,927评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,369评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,678评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,832评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,533评论 4 335
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,166评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,885评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,128评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,659评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,738评论 2 351

推荐阅读更多精彩内容