1
play

1 Gridworld: Q* The Bellman Equa)ons How to be op)mal: - PDF document

Stochas)c Planning: MDPs CS 188: Ar)ficial Intelligence Static Markov Decision Processes II Environment Fully Observable Stochastic What action next? Instantaneous Perfect Percepts


  1. Stochas)c ¡Planning: ¡MDPs ¡ CS ¡188: ¡Ar)ficial ¡Intelligence ¡ Static ¡ Markov ¡Decision ¡Processes ¡II ¡ Environment Fully Observable Stochastic What action next? Instantaneous Perfect Percepts Actions Instructors: ¡Dan ¡Klein ¡and ¡Pieter ¡Abbeel ¡-­‑-­‑-­‑ ¡University ¡of ¡California, ¡Berkeley ¡ 3 [These ¡slides ¡were ¡created ¡by ¡Dan ¡Klein ¡and ¡Pieter ¡Abbeel ¡for ¡CS188 ¡Intro ¡to ¡AI ¡at ¡UC ¡Berkeley. ¡ ¡All ¡CS188 ¡materials ¡are ¡available ¡at ¡hKp://ai.berkeley.edu.] ¡ Recap: ¡MDPs ¡ Solving ¡MDPs ¡ § Markov ¡decision ¡processes: ¡ § States ¡S ¡ § Value ¡Itera)on ¡ § Ac)ons ¡A ¡ § Real-­‑Time ¡Dynamic ¡Programming ¡ § Transi)ons ¡P(s’|s,a) ¡(or ¡T(s,a,s’)) ¡ § Rewards ¡R(s,a,s’) ¡(and ¡discount ¡ γ ) ¡ § Policy ¡Itera)on ¡ § Start ¡state ¡s 0 ¡ s § Quan))es: ¡ § Reinforcement ¡Learning ¡ a § Policy ¡= ¡map ¡of ¡states ¡to ¡ac)ons ¡ § U)lity ¡= ¡sum ¡of ¡discounted ¡rewards ¡ s, ¡a ¡ § Values ¡= ¡expected ¡future ¡u)lity ¡from ¡a ¡state ¡(max ¡node) ¡ § Q-­‑Values ¡= ¡expected ¡future ¡u)lity ¡from ¡a ¡q-­‑state ¡(chance ¡node) ¡ s,a,s ’ ¡ s ’ ¡ Op)mal ¡Quan))es ¡ Gridworld ¡Values ¡V* ¡ § The ¡value ¡(u)lity) ¡of ¡a ¡state ¡s: ¡ V * (s) ¡= ¡expected ¡u)lity ¡star)ng ¡in ¡s ¡and ¡ s is a s ac)ng ¡op)mally ¡ state a (s, a) is a § The ¡value ¡(u)lity) ¡of ¡a ¡q-­‑state ¡(s,a): ¡ s, a q-state Q * (s,a) ¡= ¡expected ¡u)lity ¡star)ng ¡out ¡ having ¡taken ¡ac)on ¡a ¡from ¡state ¡s ¡and ¡ s,a,s’ (s,a,s’) is a (therea]er) ¡ac)ng ¡op)mally ¡ transition s’ ¡ § The ¡op)mal ¡policy: ¡ π * (s) ¡= ¡op)mal ¡ac)on ¡from ¡state ¡s ¡ [Demo: ¡ ¡gridworld ¡values ¡(L9D1)] ¡ 1

  2. Gridworld: ¡Q* ¡ The ¡Bellman ¡Equa)ons ¡ How ¡to ¡be ¡op)mal: ¡ ¡ ¡ ¡ ¡ ¡Step ¡1: ¡Take ¡correct ¡first ¡ac)on ¡ ¡ ¡ ¡ ¡ ¡Step ¡2: ¡Keep ¡being ¡op)mal ¡ The ¡Bellman ¡Equa)ons ¡ Racing ¡Search ¡Tree ¡ § Defini)on ¡of ¡“op)mal ¡u)lity” ¡via ¡expec)max ¡recurrence ¡ s § We’re ¡doing ¡way ¡too ¡much ¡ work ¡with ¡expec)max! ¡ gives ¡a ¡simple ¡one-­‑step ¡lookahead ¡rela)onship ¡ a amongst ¡op)mal ¡u)lity ¡values ¡ s, ¡a ¡ § Problem: ¡States ¡are ¡repeated ¡ ¡ § Idea: ¡Only ¡compute ¡needed ¡ s,a,s ’ ¡ quan))es ¡once ¡ s ’ ¡ § Problem: ¡Tree ¡goes ¡on ¡forever ¡ § Idea: ¡Do ¡a ¡depth-­‑limited ¡ computa)on, ¡but ¡with ¡increasing ¡ depths ¡un)l ¡change ¡is ¡small ¡ § These ¡are ¡the ¡Bellman ¡equa)ons, ¡and ¡they ¡characterize ¡ § Note: ¡deep ¡parts ¡of ¡the ¡tree ¡ eventually ¡don’t ¡maKer ¡if ¡ γ ¡< ¡1 ¡ op)mal ¡values ¡in ¡a ¡way ¡we’ll ¡use ¡over ¡and ¡over ¡ ¡ ¡ Time-­‑Limited ¡Values ¡ Time-­‑Limited ¡Values: ¡Avoiding ¡Redundant ¡Computa)on ¡ § Key ¡idea: ¡)me-­‑limited ¡values ¡ § Define ¡V k (s) ¡to ¡be ¡the ¡op)mal ¡value ¡of ¡s ¡if ¡the ¡game ¡ends ¡ in ¡k ¡more ¡)me ¡steps ¡ § Equivalently, ¡it’s ¡what ¡a ¡depth-­‑k ¡expec)max ¡would ¡give ¡from ¡s ¡ [Demo ¡– ¡)me-­‑limited ¡values ¡(L8D6)] ¡ 2

  3. Value ¡Itera)on ¡ Example: ¡Value ¡Itera)on ¡ ¡ ¡3.5 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡2.5 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡0 ¡ ¡ ¡2 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡1 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡0 ¡ ¡ ¡0 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡0 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡0 ¡ Assume ¡no ¡discount ¡(gamma=1) ¡to ¡keep ¡math ¡simple! ¡ Value ¡Itera)on ¡ Called a Example: Bellman Backup “Bellman Backup” § Start ¡with ¡V 0 (s) ¡= ¡0: ¡ ¡ ¡ ¡ ¡ no ¡8me ¡steps ¡le9 ¡means ¡an ¡expected ¡reward ¡sum ¡of ¡zero ¡ Q 1 (s,a 1 ) = 2 + γ 0 § Given ¡vector ¡of ¡V k (s) ¡values, ¡do ¡one ¡ply ¡of ¡expec?max ¡from ¡each ¡state: ¡ s 1 2 a 1 V 0 = 0 V 1 = 6.5 ~ 2 V k+1 (s) ¡ 5 a Q 1 (s,a 2 ) = 5 + γ 0.9~ 1 s 0 a 2 s, ¡a ¡ 4 + γ 0.1~ 2 . 5 § Repeat ¡un?l ¡convergence ¡ ¡ 0 . 9 s 2 V 0 = 1 ~ 6.1 s,a,s ’ ¡ a greedy = a 3 0 (trust ¡me, ¡it ¡does) ¡ a 3 . 1 V k (s’) ¡ Q 1 (s,a 3 ) = 4.5 + γ 2 ~ 6.5 s 3 V 0 = 2 max k=0 ¡ k=1 ¡ If agent is in 4,3, it only has one legal action: get jewel. It gets a reward and the game is over. If agent is in the pit, it has only one legal action, die. It gets a penalty and the game is over. Agent does NOT get a reward for moving INTO 4,3. Noise ¡= ¡0.2 ¡ Noise ¡= ¡0.2 ¡ Discount ¡= ¡0.9 ¡ Discount ¡= ¡0.9 ¡ Living ¡reward ¡= ¡0 ¡ Living ¡reward ¡= ¡0 ¡ 3

  4. k=2 ¡ k=3 ¡ Noise ¡= ¡0.2 ¡ Noise ¡= ¡0.2 ¡ Discount ¡= ¡0.9 ¡ Discount ¡= ¡0.9 ¡ Living ¡reward ¡= ¡0 ¡ Living ¡reward ¡= ¡0 ¡ k=4 ¡ k=5 ¡ Noise ¡= ¡0.2 ¡ Noise ¡= ¡0.2 ¡ Discount ¡= ¡0.9 ¡ Discount ¡= ¡0.9 ¡ Living ¡reward ¡= ¡0 ¡ Living ¡reward ¡= ¡0 ¡ k=6 ¡ k=7 ¡ Noise ¡= ¡0.2 ¡ Noise ¡= ¡0.2 ¡ Discount ¡= ¡0.9 ¡ Discount ¡= ¡0.9 ¡ Living ¡reward ¡= ¡0 ¡ Living ¡reward ¡= ¡0 ¡ 4

  5. k=8 ¡ k=9 ¡ Noise ¡= ¡0.2 ¡ Noise ¡= ¡0.2 ¡ Discount ¡= ¡0.9 ¡ Discount ¡= ¡0.9 ¡ Living ¡reward ¡= ¡0 ¡ Living ¡reward ¡= ¡0 ¡ k=10 ¡ k=11 ¡ Noise ¡= ¡0.2 ¡ Noise ¡= ¡0.2 ¡ Discount ¡= ¡0.9 ¡ Discount ¡= ¡0.9 ¡ Living ¡reward ¡= ¡0 ¡ Living ¡reward ¡= ¡0 ¡ k=12 ¡ k=100 ¡ Noise ¡= ¡0.2 ¡ Noise ¡= ¡0.2 ¡ Discount ¡= ¡0.9 ¡ Discount ¡= ¡0.9 ¡ Living ¡reward ¡= ¡0 ¡ Living ¡reward ¡= ¡0 ¡ 5

  6. Value ¡Itera)on ¡ Value ¡Itera)on ¡ § Start ¡with ¡V 0 (s) ¡= ¡0: ¡ § Bellman ¡equa)ons ¡characterize ¡the ¡op)mal ¡values: ¡ V(s) ¡ § Given ¡vector ¡of ¡V k (s) ¡values, ¡do ¡one ¡ply ¡of ¡expec?max ¡from ¡each ¡state: ¡ V k+1 (s) ¡ a s, ¡a ¡ a s, ¡a ¡ s,a,s ’ ¡ § Value ¡itera)on ¡computes ¡them: ¡ V(s’) ¡ s,a,s ’ ¡ § Repeat ¡un?l ¡convergence ¡ V k (s’) ¡ § Complexity ¡of ¡each ¡itera?on: ¡O(S 2 A) ¡ § Number ¡of ¡itera?ons: ¡poly(|S|, ¡|A|, ¡1/(1-­‑g)) ¡ ¡ § Value ¡itera)on ¡is ¡just ¡a ¡fixed ¡point ¡solu)on ¡method ¡ § … ¡though ¡the ¡V k ¡vectors ¡are ¡also ¡interpretable ¡as ¡)me-­‑limited ¡values ¡ § Theorem: ¡will ¡converge ¡to ¡unique ¡op?mal ¡values ¡ Convergence* ¡ Policy ¡Extrac)on ¡ § How ¡do ¡we ¡know ¡the ¡V k ¡vectors ¡will ¡converge? ¡ § Case ¡1: ¡If ¡the ¡tree ¡has ¡maximum ¡depth ¡M, ¡then ¡ V M ¡holds ¡the ¡actual ¡untruncated ¡values ¡ § Case ¡2: ¡If ¡the ¡discount ¡is ¡less ¡than ¡1 ¡ § Sketch: ¡For ¡any ¡state ¡V k ¡and ¡V k+1 ¡can ¡be ¡viewed ¡as ¡ depth ¡k+1 ¡expec)max ¡results ¡in ¡nearly ¡iden)cal ¡ search ¡trees ¡ § The ¡max ¡difference ¡happens ¡if ¡big ¡reward ¡at ¡k+1 ¡level ¡ § That ¡last ¡layer ¡is ¡at ¡best ¡all ¡R MAX ¡ ¡ § But ¡everything ¡is ¡discounted ¡by ¡γ k ¡that ¡far ¡out ¡ § So ¡V k ¡and ¡V k+1 ¡are ¡at ¡most ¡γ k ¡max|R| ¡different ¡ § So ¡as ¡k ¡increases, ¡the ¡values ¡converge ¡ Compu)ng ¡Ac)ons ¡from ¡Values ¡ Compu)ng ¡Ac)ons ¡from ¡Q-­‑Values ¡ § Let’s ¡imagine ¡we ¡have ¡the ¡op)mal ¡values ¡V*(s) ¡ § Let’s ¡imagine ¡we ¡have ¡the ¡op)mal ¡q-­‑values: ¡ § How ¡should ¡we ¡act? ¡ § How ¡should ¡we ¡act? ¡ § It’s ¡not ¡obvious! ¡ § Completely ¡trivial ¡to ¡decide! ¡ § We ¡need ¡to ¡do ¡a ¡mini-­‑expec)max ¡(one ¡step) ¡ § This ¡is ¡called ¡policy ¡extrac)on, ¡since ¡it ¡gets ¡the ¡policy ¡implied ¡by ¡the ¡values ¡ § Important ¡lesson: ¡ac)ons ¡are ¡easier ¡to ¡select ¡from ¡q-­‑values ¡than ¡values! ¡ 6

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend