[Chapter 2] Value Iteration and Policy Iteration

We now know the most important thing for computing an optimal policy is to compute the value function. But how? (The following contents are all based on infinite horizon problems.) The solution to this problem can be roughly divided into two categories: Value Iteration and Policy Iteration.

Value Iteration

Based on the formula of expected utility with discounted factor:

U^{\pi}(s)=E[\sum_{t=1}^{\infty}{\gamma^t R(s_t)}]

and the transition function P(s^′|s,a) defined in MDP model, there is an equation for the value function to intutively statisfy:

V(s)=R(s)+\gamma max_{a \in A(s)}⁡\sum_{s^′}{P(s^′│s,a)V(s^′)}

which is called Bellman equation.

Unfortunately, it's very difficult to solve the Bellman euqation, since there is a max operator, so that's why we need value iteration method.

Based on the Bellman equation, we can get the Bellman updata:

U_{t+1}(s) \leftarrow R(s)+\gamma max_{a \in A(s)}⁡ \sum_{s^′}{P(s^′│s,a)U_t(s^′)}

Where t represents the iteration time steps.

The value iteration algorithm can be described as following:

image

We can initialize all utilities for all states as 0, and using the Bellman update formula to compute new utilities step by step until it converges (all values reach unique fixed points. This will save much more time than solve the Bellman equations directly.

Policy Iteration

Now, think about this, we are updating the values/utilities for each state in the first method, but in policy iteration, we initialize and update the policies. This is based on that sometimes, to find the optimal policy, we don't really need to find the highly accurate value function, e.g. if one action is clearly better than others. So we give up computing the values using Bellman update, we initialize the policies as {\pi}_0 and then update them. To do this, we alternate the following two main steps:

  • Policy evaluation: given the current policy {\pi}_t, calculate the next-step utilities U_{t+1}:

U_{t+1}(s) \leftarrow R(s)+\gamma \sum_{s^′}{P(s^′│s,{\pi}_t(s))U_t(s^′)}

This update formula is similar but simpler than Bellman update formula, there is no need to compute the maximum value among all possible actions, but using the actions given by the policy at time step t.

  • Policy inrovement: Using the calculated one step look-ahead utilities U_{t+1}(s) to compute new policy {\pi}_{t+1}.

To improve the policy, we need to choose another better policy to replace the current one, to do so, we need to introduce the action-value function or Q-function for policy {\pi}:

Q^{\pi}(s,a)=R(s)+\sum_{s^′}{P(s^′│s,a)U^{\pi}(s^′)}

The main different for Q-function in comparison to the value function is that the Q-function is the expected utility after determining the exact action a. Suppose the size of the state space and action space is |S| and |A| respectively, then for each policy {\pi}, there will be |S| value functions, one for each state, and will be |S| \times |A| Q-functions, one for each state-action pair.

The policy improvement theorem can be very easy then: suppose a new policy {\pi}′ that for all s \in S:

Q^{\pi}(s,{\pi}′(s)) \geq U^{\pi}(s)

Then for all s \in S, there will be:

U^{\pi}′(s) \geq U^{\pi}(s)

In this case, we can say that {\pi}′ is better than {\pi}, so we can improve the policy from {\pi} to {\pi}′.

Alternatively do the above two steps until there is no change in policy, we can get the optimal policy, this is the policy iteration algorithm, describing as following:

image

More Accurate Policy Iteration Methods

The policy iteration method stated above with both doing policy evaluation and policy improvement one step is called generalized policy iteration, which is a very general and common method. However, there are some other more accurate methods based on more accurate policy evaluation.

  • For each step of policy evaluation, not only update the utilities one time step, but using the following set of equations to solve the accurate utilities:

U_t(s)=R(s)+\gamma \sum_{s^′}{P(s^′│s,{\pi}_t(s))U_t(s^′)}

For N states, there are N equations and they can be solved in O(N^3) time using some basic linear algebra knowledge. This will be much more complex but much more accurate, however, it's a bit too much for almost all problems, we ususlly don't need the most accurate utilities.

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

推荐阅读更多精彩内容