Docsity

Planning Based on Markov Decision Processes | CMSC 722, Study notes of Computer Science

Partial preview of the text

Download Planning Based on Markov Decision Processes | CMSC 722 and more Study notes Computer Science in PDF only on Docsity!

Dana Nau: Lecture slides for Automated Planning

Chapter 16

Planning Based on Markov

Decision Processes

Dana S. Nau CMSC 722, AI Planning University of Maryland, Spring 2007 Lecture slides for Automated Planning: Theory and Practice

Dana Nau: Lecture slides for Automated Planning

Motivation

● Until now, we’ve assumed that each action has only one possible outcome ◆ In many cases this is unrealistic ● In many situations, actions may have more than one possible outcome ◆ Action failures » e.g., gripper drops its load ◆ Exogenous events » e.g., road closed ● Would like to be able to plan in such situations ● One approach: Markov Decision Processes a c b Grasp block c a c b Intended outcome a b c Unintended outcome

Dana Nau: Lecture slides for Automated Planning ● Robot r1 starts at location l ◆ State s1 in the diagram ● Objective is to get r1 to location l ◆ State s4 in the diagram ● Also present, but not shown: an action called wait ◆ It’s applicable in every state ◆ It leaves the state unchanged Goal Start

Example

Dana Nau: Lecture slides for Automated Planning ● Robot r1 starts at location l ◆ State s1 in the diagram ● Objective is to get r1 to location l ◆ State s4 in the diagram ● No classical plan (sequence of actions) can be a solution ◆ e.g., π = 〈move(r1,l1,l2), move(r1,l2,l3), move(r1,l5,l4)〉 π ' = 〈move(r1,l1,l2), move(r1,l2,l3), move(r1,l5,l4)〉 π '' = 〈move(r1,l1,l4)〉 Goal Start

Example

Dana Nau: Lecture slides for Automated Planning ● Robot r1 starts at location l ◆ State s1 in the diagram ● Objective is to get r1 to location l ◆ State s4 in the diagram ● No classical plan (sequence of actions) can be a solution ◆ e.g., π = 〈move(r1,l1,l2), move(r1,l2,l3), move(r1,l5,l4)〉 π ' = 〈move(r1,l1,l2), move(r1,l2,l3), move(r1,l5,l4)〉 π '' = 〈move(r1,l1,l4)〉 Goal Start

Example

Dana Nau: Lecture slides for Automated Planning Goal π 1 = {(s1, move(r1,l1,l2)), (s2, move(r1,l2,l3)), (s3, move(r1,l3,l4)), (s4, wait), (s5, wait)} π 2 = {(s1, move(r1,l1,l2)), (s2, move(r1,l2,l3)), (s3, move(r1,l3,l4)), (s4, wait), (s5, move(r1,l5,l4))} π 3 = {(s1, move(r1,l1,l4)), (s2, move(r1,l2,l1)), (s3, move(r1,l3,l4)), (s4, wait), (s5, move(r1,l5,l4)} ● Policy : a function that maps states into actions ● Write it as a set of state-action pairs

Policies

Start

Dana Nau: Lecture slides for Automated Planning Goal

Histories

Start ● History : sequence of system states h = 〈 s 0 , s 1 , s 2 , s 3 , s 4

h 0 = 〈s1, s3, s1, s3, s1, … 〉 h 1 = 〈s1, s2, s3, s4, s4, … 〉 h 2 = 〈s1, s2, s5, s5, s5, … 〉 h 3 = 〈s1, s2, s5, s4, s4, … 〉 h 4 = 〈s1, s4, s4, s4, s4, … 〉 h 5 = 〈s1, s1, s4, s4, s4, … 〉 h 6 = 〈s1, s1, s1, s4, s4, … 〉 h 7 = 〈s1, s1, s1, s1, s1, … 〉 ● Each policy induces a probability distribution over histories ◆ If h = 〈 s 0 , s 1 , … 〉 then P ( h | π) = P ( s 0 ) ∏ i ≥ 0 P π ( S i )^ ( s i+ | s i ) The book omits this since it assumes s 0 is known move(r1,l2,l1)

Dana Nau: Lecture slides for Automated Planning goal Goal π 1 = {(s1, move(r1,l1,l2)), (s2, move(r1,l2,l3)), (s3, move(r1,l3,l4)), (s4, wait), (s5, wait)} h 1 = 〈s1, s2, s3, s4, s4, … 〉 P ( h 1 | π 1 ) = 1 × 1 × 0.8 × 1 × … = 0. h 2 = 〈s1, s2, s5, s5 … 〉 P ( h 2 | π 1 ) = 1 × 1 × 0.2 × 1 × … = 0. P ( h | π 1 ) = 0 for all other h

Example

Start move(r1,l2,l1)

Dana Nau: Lecture slides for Automated Planning goal π 3 = {(s1, move(r1,l1,l4)), (s2, move(r1,l2,l1)), (s3, move(r1,l3,l4)), (s4, wait), (s5, move(r1,l5,l4)} h 4 = 〈s1, s4, s4, … 〉 P ( h 4 | π 3 ) = 0.5 × 1 × 1 × 1 × 1 × … = 0. h 5 = 〈s1, s1, s4, s4, … 〉 P ( h 5 | π 3 ) = 0.5 × 0.5 × 1 × 1 × 1 × … = 0. h 6 = 〈s1, s1, s1, s4, s4, … 〉 P ( h 6 | π 3 ) = 0.5 × 0.5 × 0.5 × 1 × 1 × … = 0.

  • • • h 7 = 〈s1, s1, s1, s1, s1, s1, … 〉 P ( h 6 | π 3 ) = 0.5 × 0.5 × 0.5 × 0.5 × 0.5 × … = 0 Goal Start move(r1,l2,l1)

Example (continued)

Dana Nau: Lecture slides for Automated Planning ● Numeric cost C ( s,a ) for each state s and action a ● Numeric reward R ( s ) for each state s ● Example: ◆ C ( s,a ) = 1 for each “horizontal” action ◆ C ( s,a ) = 100 for each “vertical” action ◆ C ( s, wait) =0, for s ≠ s ◆ C (s5,wait) = 100 ◆ R as shown ● Utility function: generalization of a goal ◆ If h = 〈 s 0 , s 1 , … 〉, then V ( h | π) = ∑ i ≥ 0 ( R ( s i ) – C ( s i ,π( s i ))) r = – 100 Start

Utility Functions

Dana Nau: Lecture slides for Automated Planning r = – 100 Start

Discounted Utility

● We often need to use

a discount factor, γ

● Discounted utility of a history: ◆ V ( h | π) = ∑ i ≥ 0

i ( R ( s i ) – C ( s i ,π( s i

● Less weight to distant rewards/costs

● Guarantees convergence if 0 ≤ γ < 1

● Expected utility of a policy: E (π) = ∑ h P ( h |π) V ( h |π)

Dana Nau: Lecture slides for Automated Planning r = – 100 Start

Example

π 1 = {(s1, move(r1,l1,l2)), (s2, move(r1,l2,l3)), (s3, move(r1,l3,l4)), (s4, wait), (s5, wait)} γ = 0. h 1 = 〈s1, s2, s3, s4, s4, … 〉 V ( h 1 | π 1 ) =. 0 (0 – 100) +. 1 (0 – 1) +. 2 (0 – 100) +. 3 100 +. 4 100 + … = 547. h 2 = 〈s1, s2, s5, s5 … 〉 V ( h 2 | π 1 ) =. 0 (0 – 100) +. 1 (0 – 1) +. 2 (–100) +. 3 (–100) + … = – 910. E (π 1 ) = 0.8 * 547.9 + 0.2 (–910.1) = 256. c = 0 c = 0

Dana Nau: Lecture slides for Automated Planning

Bellman’s Theorem

● Suppose we have a policy π. Then ◆ E π

( s ) = C ( s , π( s )) + γ ∑

s ∈ S

P

π( s ) ( s ′ | s ) E ( s ′) ● Let Q π ( s,a ) be the expected cost in a state s if we start by using action a in state s , and then use the policy π from then on ◆ Q π

( s,a ) = C ( s,a ) + γ ∑

s ′ ∈ S

P

π′( s ) ( s ′ | s ) E π ( s ′) ● Let π

be an optimal policy ◆ Then at each state s , π

satisfies Bellman’s equation : » E π* ( s ) = min a ∈ A

Q

π* ( s,a ) ◆ I.e., at each state, π

chooses the action that produces the smallest expected cost from there onward ● Thus ◆ E π* ( s ) = min a

{ C ( s,a ) + γ ∑

s’ ∈ S

P

a ( s ′ | s ) E π* ( s ′)}

Dana Nau: Lecture slides for Automated Planning

Policy Iteration

● Policy iteration is a way to find an optimal policy ● Start with an arbitrary initial policy π 1 ● For i = 1, 2, … ◆ Compute E π i ( s ) for every s by solving the system of equations » E π i ( s ) = C( s, π i

( s )) + γ ∑

s ′ ∈ S P π i ( s ) ( s ′ | s ) E π i ( s ′) ◆ For every s , » π i + ( s ) := argmin a ∈ A

C( s, a ) + γ ∑

s ′ ∈ S

P

a ( s ′ | s ) E π i ( s ′) ◆ If π i + = π i then exit ● Converges in a finite number of iterations