Announcements  Homework 3: Games  Due tonight at 11:59pm.  Project 2: Multi-Agent Pacman  Has been released, due Friday 2/19 at 5:00pm.  Optional.

Slides:



Advertisements
Similar presentations
Lirong Xia Reinforcement Learning (1) Tue, March 18, 2014.
Advertisements

Value and Planning in MDPs. Administrivia Reading 3 assigned today Mahdevan, S., “Representation Policy Iteration”. In Proc. of 21st Conference on Uncertainty.
Markov Decision Processes (MDPs) read Ch utility-based agents –goals encoded in utility function U(s), or U:S  effects of actions encoded in.
Markov Decision Process
Value Iteration & Q-learning CS 5368 Song Cui. Outline Recap Value Iteration Q-learning.
Announcements  Homework 3: Games  Due tonight at 11:59pm.  Project 2: Multi-Agent Pacman  Has been released, due Friday 2/21 at 5:00pm.  Optional.
Decision Theoretic Planning
CS 188: Artificial Intelligence
1 Reinforcement Learning Introduction & Passive Learning Alan Fern * Based in part on slides by Daniel Weld.
Markov Decision Processes
Infinite Horizon Problems
Planning under Uncertainty
Announcements Homework 3: Games Project 2: Multi-Agent Pacman
91.420/543: Artificial Intelligence UMass Lowell CS – Fall 2010
CS 182/CogSci110/Ling109 Spring 2008 Reinforcement Learning: Algorithms 4/1/2008 Srini Narayanan – ICSI and UC Berkeley.
Pieter Abbeel and Andrew Y. Ng Apprenticeship Learning via Inverse Reinforcement Learning Pieter Abbeel Stanford University [Joint work with Andrew Ng.]
Pieter Abbeel and Andrew Y. Ng Apprenticeship Learning via Inverse Reinforcement Learning Pieter Abbeel Stanford University [Joint work with Andrew Ng.]
CS 188: Artificial Intelligence Fall 2009 Lecture 10: MDPs 9/29/2009 Dan Klein – UC Berkeley Many slides over the course adapted from either Stuart Russell.
Markov Decision Processes Value Iteration Pieter Abbeel UC Berkeley EECS TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
The Value of Plans. Now and Then Last time Value in stochastic worlds Maximum expected utility Value function calculation Today Example: gridworld navigation.
Pieter Abbeel and Andrew Y. Ng Reinforcement Learning and Apprenticeship Learning Pieter Abbeel and Andrew Y. Ng Stanford University.
Department of Computer Science Undergraduate Events More
CS Reinforcement Learning1 Reinforcement Learning Variation on Supervised Learning Exact target outputs are not given Some variation of reward is.
Utility Theory & MDPs Tamara Berg CS Artificial Intelligence Many slides throughout the course adapted from Svetlana Lazebnik, Dan Klein, Stuart.
Instructor: Vincent Conitzer
MAKING COMPLEX DEClSlONS
Reinforcement Learning  Basic idea:  Receive feedback in the form of rewards  Agent’s utility is defined by the reward function  Must learn to act.
CSE 473Markov Decision Processes Dan Weld Many slides from Chris Bishop, Mausam, Dan Klein, Stuart Russell, Andrew Moore & Luke Zettlemoyer.
1 Markov Decision Processes Infinite Horizon Problems Alan Fern * * Based in part on slides by Craig Boutilier and Daniel Weld.
1 Markov Decision Processes Infinite Horizon Problems Alan Fern * * Based in part on slides by Craig Boutilier and Daniel Weld.
Quiz 6: Utility Theory  Simulated Annealing only applies to continuous f(). False  Simulated Annealing only applies to differentiable f(). False  The.
MDPs (cont) & Reinforcement Learning
gaflier-uas-battles-feral-hogs/ gaflier-uas-battles-feral-hogs/
CS 188: Artificial Intelligence Spring 2007 Lecture 23: Reinforcement Learning: III 4/17/2007 Srini Narayanan – ICSI and UC Berkeley.
Announcements  Upcoming due dates  Wednesday 11/4, 11:59pm Homework 8  Friday 10/30, 5pm Project 3  Watch out for Daylight Savings and UTC.
CSE 473Markov Decision Processes Dan Weld Many slides from Chris Bishop, Mausam, Dan Klein, Stuart Russell, Andrew Moore & Luke Zettlemoyer.
Department of Computer Science Undergraduate Events More
QUIZ!!  T/F: Optimal policies can be defined from an optimal Value function. TRUE  T/F: “Pick the MEU action first, then follow optimal policy” is optimal.
Possible actions: up, down, right, left Rewards: – 0.04 if non-terminal state Environment is observable (i.e., agent knows where it is) MDP = “Markov Decision.
Reinforcement Learning
CS 188: Artificial Intelligence Spring 2007 Lecture 21:Reinforcement Learning: II MDP 4/12/2007 Srini Narayanan – ICSI and UC Berkeley.
Def gradientDescent(x, y, theta, alpha, m, numIterations): xTrans = x.transpose() replaceMe =.0001 for i in range(0, numIterations): hypothesis = np.dot(x,
Reinforcement Learning  Basic idea:  Receive feedback in the form of rewards  Agent’s utility is defined by the reward function  Must learn to act.
CS 541: Artificial Intelligence Lecture X: Markov Decision Process Slides Credit: Peter Norvig and Sebastian Thrun.
Announcements Grader office hours posted on course website
Markov Decision Processes II
Markov Decision Processes
CS 4/527: Artificial Intelligence
Reinforcement Learning
CSE 473: Artificial Intelligence
CS 188: Artificial Intelligence
Announcements Homework 3 due today (grace period through Friday)
CAP 5636 – Advanced Artificial Intelligence
Quiz 6: Utility Theory Simulated Annealing only applies to continuous f(). False Simulated Annealing only applies to differentiable f(). False The 4 other.
CS 188: Artificial Intelligence Fall 2007
CS 188: Artificial Intelligence Fall 2008
CS 188: Artificial Intelligence Fall 2008
CS 188: Artificial Intelligence Fall 2007
CSE 473 Markov Decision Processes
CS 188: Artificial Intelligence Spring 2006
Hidden Markov Models (cont.) Markov Decision Processes
CS 188: Artificial Intelligence Spring 2006
CS 188: Artificial Intelligence Fall 2007
CS 416 Artificial Intelligence
Announcements Homework 2 Project 2 Mini-contest 1 (optional)
Warm-up as You Walk In Given Set actions (persistent/static)
Reinforcement Learning (2)
Markov Decision Processes
Markov Decision Processes
Reinforcement Learning (2)
Presentation transcript:

Announcements  Homework 3: Games  Due tonight at 11:59pm.  Project 2: Multi-Agent Pacman  Has been released, due Friday 2/19 at 5:00pm.  Optional mini-contest, due Sunday 2/21 at 11:59pm.

CS 188: Artificial Intelligence Markov Decision Processes II Instructors: Anca Dragan and Pieter Abbeel --- University of California, Berkeley [Slides by Dan Klein, Pieter Abbeel, Anca Dragan;

Example: Grid World  A maze-like problem  The agent lives in a grid  Walls block the agent’s path  Noisy movement: actions do not always go as planned  80% of the time, the action North takes the agent North  10% of the time, North takes the agent West; 10% East  If there is a wall in the direction the agent would have been taken, the agent stays put  The agent receives rewards each time step  Small “living” reward each step (can be negative)  Big rewards come at the end (good or bad)  Goal: maximize sum of (discounted) rewards

Recap: Defining MDPs  Markov decision processes:  Set of states S  Start state s 0  Set of actions A  Transitions P(s’|s,a) (or T(s,a,s’))  Rewards R(s,a,s’) (and discount  )  MDP quantities so far:  Policy = Choice of action for each state  Utility = sum of (discounted) rewards a s s, a s,a,s’ s’s’

Solving MDPs

Racing Search Tree

 We’re doing way too much work with expectimax!  Problem: States are repeated  Idea: Only compute needed quantities once  Problem: Tree goes on forever  Idea: Do a depth-limited computation, but with increasing depths until change is small  Note: deep parts of the tree eventually don’t matter if γ < 1

Optimal Quantities  The value (utility) of a state s: V * (s) = expected utility starting in s and acting optimally  The value (utility) of a q-state (s,a): Q * (s,a) = expected utility starting out having taken action a from state s and (thereafter) acting optimally  The optimal policy:  * (s) = optimal action from state s a s s’ s, a (s,a,s’) is a transition s,a,s’ s is a state (s, a) is a q-state [Demo – gridworld values (L8D4)]

Snapshot of Demo – Gridworld V Values Noise = 0 Discount = 1 Living reward = 0

Snapshot of Demo – Gridworld Q Values Noise = 0 Discount = 1 Living reward = 0

Snapshot of Demo – Gridworld V Values Noise = 0.2 Discount = 1 Living reward = 0

Snapshot of Demo – Gridworld Q Values Noise = 0.2 Discount = 1 Living reward = 0

Snapshot of Demo – Gridworld V Values Noise = 0.2 Discount = 0.9 Living reward = 0

Snapshot of Demo – Gridworld Q Values Noise = 0.2 Discount = 0.9 Living reward = 0

Snapshot of Demo – Gridworld V Values Noise = 0.2 Discount = 0.9 Living reward = -0.1

Snapshot of Demo – Gridworld Q Values Noise = 0.2 Discount = 0.9 Living reward = -0.1

Values of States  Recursive definition of value: a s s, a s,a,s’ s’s’

Time-Limited Values  Key idea: time-limited values  Define V k (s) to be the optimal value of s if the game ends in k more time steps  Equivalently, it’s what a depth-k expectimax would give from s [Demo – time-limited values (L8D6)]

k=0 Noise = 0.2 Discount = 0.9 Living reward = 0

k=1 Noise = 0.2 Discount = 0.9 Living reward = 0

k=2 Noise = 0.2 Discount = 0.9 Living reward = 0

k=3 Noise = 0.2 Discount = 0.9 Living reward = 0

k=4 Noise = 0.2 Discount = 0.9 Living reward = 0

k=5 Noise = 0.2 Discount = 0.9 Living reward = 0

k=6 Noise = 0.2 Discount = 0.9 Living reward = 0

k=7 Noise = 0.2 Discount = 0.9 Living reward = 0

k=8 Noise = 0.2 Discount = 0.9 Living reward = 0

k=9 Noise = 0.2 Discount = 0.9 Living reward = 0

k=10 Noise = 0.2 Discount = 0.9 Living reward = 0

k=11 Noise = 0.2 Discount = 0.9 Living reward = 0

k=12 Noise = 0.2 Discount = 0.9 Living reward = 0

k=100 Noise = 0.2 Discount = 0.9 Living reward = 0

Computing Time-Limited Values

Value Iteration

 Start with V 0 (s) = 0: no time steps left means an expected reward sum of zero  Given vector of V k (s) values, do one ply of expectimax from each state:  Repeat until convergence  Complexity of each iteration: O(S 2 A)  Theorem: will converge to unique optimal values  Basic idea: approximations get refined towards optimal values  Policy may converge long before values do a V k+1 (s) s, a s,a,s’ V k (s’)

Example: Value Iteration S: 1 Assume no discount! F:.5*2+.5*2=2

Example: Value Iteration Assume no discount! S:.5*1+.5*1=1 F: -10

Example: Value Iteration Assume no discount! 1 0

Example: Value Iteration Assume no discount! 1 0 S: 1+2=3 F:.5*(2+2)+.5*(2+1)=3.5

Example: Value Iteration Assume no discount!

Convergence*  How do we know the V k vectors are going to 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 expectimax results in nearly identical search trees  The difference is that on the bottom layer, V k+1 has actual rewards while V k has zeros  That last layer is at best all R MAX  It is at worst R MIN  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

Policy Extraction

Computing Actions from Values  Let’s imagine we have the optimal values V*(s)  How should we act?  It’s not obvious!  We need to do a mini-expectimax (one step)  This is called policy extraction, since it gets the policy implied by the values

Computing Actions from Q-Values  Let’s imagine we have the optimal q-values:  How should we act?  Completely trivial to decide!  Important lesson: actions are easier to select from q-values than values!

Recap: MDPs  Markov decision processes:  States S  Actions A  Transitions P(s’|s,a) (or T(s,a,s’))  Rewards R(s,a,s’) (and discount  )  Start state s 0  Quantities:  Policy = map of states to actions  Utility = sum of discounted rewards  Values = expected future utility from a state (max node)  Q-Values = expected future utility from a q-state (chance node) a s s, a s,a,s’ s’s’

Policy Methods

Problems with Value Iteration  Value iteration repeats the Bellman updates:  Problem 1: It’s slow – O(S 2 A) per iteration  Problem 2: The “max” at each state rarely changes  Problem 3: The policy often converges long before the values a s s, a s,a,s’ s’s’ [Demo: value iteration (L9D2)]

k=12 Noise = 0.2 Discount = 0.9 Living reward = 0

k=100 Noise = 0.2 Discount = 0.9 Living reward = 0

Policy Iteration  Alternative approach for optimal values:  Step 1: Policy evaluation: calculate utilities for some fixed policy (not optimal utilities!) until convergence  Step 2: Policy improvement: update policy using one-step look-ahead with resulting converged (but not optimal!) utilities as future values  Repeat steps until policy converges  This is policy iteration  It’s still optimal!  Can converge (much) faster under some conditions

Policy Evaluation

Fixed Policies  Expectimax trees max over all actions to compute the optimal values  If we fixed some policy  (s), then the tree would be simpler – only one action per state  … though the tree’s value would depend on which policy we fixed a s s, a s,a,s’ s’s’  (s) s s,  (s) s,  (s),s’ s’s’ Do the optimal action Do what  says to do

Utilities for a Fixed Policy  Another basic operation: compute the utility of a state s under a fixed (generally non-optimal) policy  Define the utility of a state s, under a fixed policy  : V  (s) = expected total discounted rewards starting in s and following   Recursive relation (one-step look-ahead / Bellman equation):  (s) s s,  (s) s,  (s),s’ s’s’

Example: Policy Evaluation Always Go RightAlways Go Forward

Example: Policy Evaluation Always Go RightAlways Go Forward

Policy Evaluation  How do we calculate the V’s for a fixed policy  ?  Idea 1: Turn recursive Bellman equations into updates (like value iteration)  Efficiency: O(S 2 ) per iteration  Idea 2: Without the maxes, the Bellman equations are just a linear system  Solve with Matlab (or your favorite linear system solver)  (s) s s,  (s) s,  (s),s’ s’s’

Policy Iteration

 Evaluation: For fixed current policy , find values with policy evaluation:  Iterate until values converge:  Improvement: For fixed values, get a better policy using policy extraction  One-step look-ahead:

Comparison  Both value iteration and policy iteration compute the same thing (all optimal values)  In value iteration:  Every iteration updates both the values and (implicitly) the policy  We don’t track the policy, but taking the max over actions implicitly recomputes it  In policy iteration:  We do several passes that update utilities with fixed policy (each pass is fast because we consider only one action, not all of them)  After the policy is evaluated, a new policy is chosen (slow like a value iteration pass)  The new policy will be better (or we’re done)  Both are dynamic programs for solving MDPs

Summary: MDP Algorithms  So you want to….  Compute optimal values: use value iteration or policy iteration  Compute values for a particular policy: use policy evaluation  Turn your values into a policy: use policy extraction (one-step lookahead)  These all look the same!  They basically are – they are all variations of Bellman updates  They all use one-step lookahead expectimax fragments  They differ only in whether we plug in a fixed policy or max over actions

The Bellman Equations How to be optimal: Step 1: Take correct first action Step 2: Keep being optimal

Double Bandits

Double-Bandit MDP  Actions: Blue, Red  States: Win, Lose WL $1 1.0 $ $ $ $ $0 No discount 100 time steps Both states have the same value

Offline Planning  Solving MDPs is offline planning  You determine all quantities through computation  You need to know the details of the MDP  You do not actually play the game! Play Red Play Blue Value No discount 100 time steps Both states have the same value WL $1 1.0 $ $ $ $ $0

Let’s Play! $2 $0$2 $0

Online Planning  Rules changed! Red’s win chance is different. WL $1 1.0 $1 1.0 ?? $0 ?? $2 ?? $2 ?? $0

Let’s Play! $0 $2$0 $2 $0

What Just Happened?  That wasn’t planning, it was learning!  Specifically, reinforcement learning  There was an MDP, but you couldn’t solve it with just computation  You needed to actually act to figure it out  Important ideas in reinforcement learning that came up  Exploration: you have to try unknown actions to get information  Exploitation: eventually, you have to use what you know  Regret: even if you learn intelligently, you make mistakes  Sampling: because of chance, you have to try things repeatedly  Difficulty: learning can be much harder than solving a known MDP

Next Time: Reinforcement Learning!

Asynchronous Value Iteration*  In value iteration, we update every state in each iteration  Actually, any sequences of Bellman updates will converge if every state is visited infinitely often  In fact, we can update the policy as seldom or often as we like, and we will still converge  Idea: Update states whose value we expect to change: If is large then update predecessors of s

Interlude