Docsity

Maximizing Utility in Stochastic Environments: Sequential Decisions in MDPs, Study notes of Computer Science

Toggle sidebar
bg1
Artificial Intelligence
Programming
Sequential Decision Making
Chris Brooks
Department of Computer Science
University of San Francisco
Making Sequential Decisions
Previously, we’ve talked about:
Making one-shot decisions in a deterministic
environment
Making sequential decisions in a deterministic
environment
Search
Inference
Planning
Making one-shot decisions in a stochastic
environment
Probability and Belief Networks
Expected Utility
What about sequential decisions in a stochastic
environment?
Departmentof Computer Science — University of San Francisco – p.1/??
Sequential Decisions
We’ve thought a
little bit about this in
terms of value of
information.
We can model this
as a state-space
problem.
We can even use
a minimax-style ap-
proach to determine
the optimal actions
to take.
Initial
$10
{door 1, 1.0}
$0 $25
{door 2, 0.5}
{door 2, 0.5}
$20
{door 3, 0.2}
$10
{door 3, 0.8}
door
2 has
prize
{reveal 2, 0.5}
{reveal 2, 0.5}
door
2
empty
$10
{door 1, 1.0}
$0
{door 2, 1.0}
$20
{door 3, 0.2}
$10
{door 3, 0.8}
$10
{door 1, 1.0}
$25
$20
{door 3, 0.2}
$10
{door 3, 0.8}
{door 2, 1.0}
Departmentof Computer Science — University of San Francisco
Expected Utility
Recall that the expected utility of an action is the utility
of each possible outcome, weighted by the probability of
that outcome occurring.
More formally, from state s, an agent may take actions
a1, a2, ..., an.
Each action aican lead to states si1, si2, ..., sim, with
probability pi1, pi2, ..., pim
EU (ai) = Xpijsij
We call the set of probabilities and associated states the
state transition model.
The agent should choose the action a′that maximizes
EU.
Departmentof Computer Science — University of San Francisco – p.3/??
Markovian environments
We can extend this idea to sequential environments.
Problem: How to determine transition probabilities?
The probability of reaching state sgiven action a
might depend on previous actions that were taken.
Reasoning about long chains of probabilities can be
complex and expensive.
The Markov assumption says that state transition
probabilities depend only on a finite number of parents.
Simplest: a first-order Markov process. State transition
probabilities depend only on the previous state.
This is what we’ll focus on.
Departmentof Computer Science — University of San Francisco – p.4/??
Stationary Distributions
We’ll also assume a stationary distribution
This says that the probability of reaching a state s′given
action afrom state swith history Hdoes not change.
Different histories may produce different probabilities
Given identical histories, the state transitions will be the
same.
We’ll also assume that the utility of a state does not
change throughout the course of the problem.
In other words, our model of the world does not
change while we are solving the problem.
Departmentof Computer Science — University of San Francisco
pf3
pf4
pf5
pf8

Partial preview of the text

Download Maximizing Utility in Stochastic Environments: Sequential Decisions in MDPs and more Study notes Computer Science in PDF only on Docsity!

Artificial IntelligenceProgramming Sequential Decision Making

Chris BrooksDepartment of Computer ScienceUniversity of San Francisco

Making Sequential Decisions Previously, we’ve talked about:^ Making one-shot decisions in a deterministicenvironment^ Making sequential decisions in a deterministicenvironment^ Search^ Inference^ Planning^ Making one-shot decisions in a stochasticenvironment^ Probability and Belief Networks^ Expected Utility What about sequential decisions in a stochasticenvironment?

Department of Computer Science — University of San Francisco – p.1/

??

Sequential Decisions We’ve thought alittle bit about this interms of value ofinformation. We can model thisas a state-spaceproblem. We^ can^

even^ use a minimax-style ap-proach to determinethe optimal actionsto take.

Initial $ {door 1, 1.0}^ $^

{door 2, 0.5}^ {door 3, 0.2}^ {door 2, 0.5}^ $20$

$ {door 3, 0.8} {reveal 2, 0.5} {reveal 2, 0.5} door door2 hasprize (^2) empty {door 1, 1.0}^ $10^ {door 2, 1.0}^ $

{door 3, 0.8}{door 3, 0.2}^ $10 $

$10 {door 3, 0.8}{door 3, 0.2} {door 2, 1.0} $20 {door 1, 1.0} $25 $10 Department of Computer Science — University of San Fra

Expected Utility Recall that the expected utility of an action is the utilityof each possible outcome, weighted by the probability ofthat outcome occurring. More formally, from state

s, an agent may take actions a, a, ..., a^12

.n Each action

acan lead to statesi^

s, s, ..., si^1 i^2

, withim

probability

p, p, ..., pi^1 i^2

im ∑ EU^ (a) =^ i

psij^ ij

We call the set of probabilities and associated states thestate transition model. The agent should choose the action

′^ athat maximizes

EU.^

Department of Computer Science — University of San Francisco – p.3/

??

Markovian environments We can extend this idea to sequential environments. Problem: How to determine transition probabilities?^ The probability of reaching state

s^ given action

a

might depend on previous actions that were taken. Reasoning about long chains of probabilities can becomplex and expensive. The Markov assumption says that state transitionprobabilities depend only on a finite number of parents. Simplest: a first-order Markov process. State transitionprobabilities depend only on the previous state. This is what we’ll focus on.

Department of Computer Science — University of San Francisco – p.4/

??

Stationary Distributions We’ll also assume a

stationary distribution This says that the probability of reaching a state

′^ sgiven

action^ a^ from state

s^ with history

H^ does not change.

Different histories may produce different probabilities Given identical histories, the state transitions will be thesame. We’ll also assume that the utility of a state does notchange throughout the course of the problem.^ In other words, our model of the world does notchange while we are solving the problem.

Department of Computer Science — University of San Fra

Solving sequential problems If we have to solve a sequential problem, the total utilitywill depend on a sequence of states

s, s, ..., s^12

.n

Let’s assign each state a utility or

reward^ R(s).i

Agent wants to maximize the sum of rewards. We call this formulation a Markov decision process.^ Formally:^ An initial state

s^0 A discrete set of states and actions A Transition model:

′ T (s, a, s )^ that indicates the

probability of reaching state

′^ sfrom^ s when taking

action^ a. A reward function:

R(s)

Department of Computer Science — University of San Francisco – p.6/

??

Example grid problem 3 2 1 1 2

3 4 START

0.8 0.10.

(a)^

(b) + 1^ – Agent moves in the “intended” direction with probability0.8, and at a right angle with probability 0.2 What should an agent do at each state to maximizereward?

Department of Computer Science — University of San Francisco – p.7/

??

MDP solutions Since the environment is stochastic, a solution will notbe an action sequence. Instead, we must specify what an agent should do inany reachable state. We call this specification a

policy “If you’re below the goal, move up.” “If you’re in the left-most column, move right.” We denote a policy with

π, and^ π

(s)^ indicates the policy

for state^

s.

Department of Computer Science — University of San Fra

MDP solutions Things to note:^ We’ve wrapped the goal formulation into the problem^ Different goals will require different policies.^ We are assuming a great deal of (correct) knowledgeabout the world.^ State transition models, rewards^ We’ll touch on how to learn these without a model.

Department of Computer Science — University of San Francisco – p.9/

??

Comparing policies We can compare policies according to the expectedutility of the histories they produce. The policy with the highest expected utility is the

optimal

policy. Once an optimal policy is found, the agent can just lookup the best action for any state.

Department of Computer Science — University of San Francisco – p.10/

??

Example grid problem 3 + 1 2 – 1 1 2 3

(^14) R s ( ) < 1.62840.4278 <^ < 0.0850 R s ( )^ +1^ –^1 > 0 R s ( ) (a)^

+1^ +1 –^1 –^1 +1^ –^1 < 0 R s ( )0.0221 <(b)

Left figure: R(s) = -0.04. Note: there are typos in this figure; all non-zero rewards should benegative.^ As the costs for nonterminal states change, so does theoptimal policy.^ Very high cost: Agent tries to exit immediately^ Middle ground: Agent tries to avoid bad exit^ Positive reward: Agent doesn’t try to exit.

Department of Computer Science — University of San Fran

Dynamic Programming The Bellman equation is the basis of dynamicprogramming. In an acyclic transition graph, you can solve theserecursively by working backward from the final state tothe initial states. Can’t do this directly for transition graphs with loops.

Department of Computer Science — University of San Francisco – p.18/

??

Value Iteration Since state utilities are defined in terms of other stateutilities, how to find a closed-form solution? We can use an iterative approach:^ Give each state random initial utilities.^ Calculate the new left-hand side for a state based onits neighbors’ values.^ Propagate this to update the right-hand-side for otherstates,^ Update rule:^ U(si+

) =^ R(s) +

∑ γmaxa ′^ T^ (s, a, s s

′′)U(s)i

This is guaranteed to converge to the solutions to theBellman equations.

Department of Computer Science — University of San Francisco – p.19/

??

Value Iteration algorithm dofor^ s^ in^ statesU(s)^ =^ R(s)

+^ gamma^ *

max^ T(s,a,s’)

U(s’)

untilall^ utilities

change^ by

less^ then delta

where^ δ^ =^ error^ ∗

(1^ −^ γ)/γ

Department of Computer Science — University of San Fran

Example

+1 -

1

2

3 4 6

5 7 -0.1^8

0.^

0.05 0. -0.02 0.^

-0.

0.^

Start by assigning random utilities to each state. Assume^

γ^ = 0.^8 Assume time cost is -0.04: (

R(s) =^ −

0.^04 )

Assume error =0.01:

δ^ = 0.^0025

Department of Computer Science — University of San Francisco – p.21/

??

Example

+1 -

1

2

3 4 6

5 7

8

9 -0.

0.^

0.62 0. 0.02 0.^

0.^

After one iteration, here are the estimated values.

Department of Computer Science — University of San Francisco – p.22/

??

Example

+1 -

1

2

3 4 6

5 7

8

9

-0.^

0.65 0. -0.02 -0.^

0.^

After two iterations, here are the estimated values.

Department of Computer Science — University of San Fran

Example

+1 -

1

2

3 4 6

5 7

8

9

0.^

0.69 0. -0.06 -0.^

-0.^

-0.

After three iterations, here are the estimated values.

Department of Computer Science — University of San Francisco – p.24/

??

Example

+1 -

1

2

3 4 6

5 7

8

9

0.^

0.68 0. 0.07 -0.^

0.^

-0.

After four iterations, here are the estimated values.

Department of Computer Science — University of San Francisco – p.25/

??

Example

+1 -

1

2

3 4 6

5 7

8

9

0.^

0.68 0. 0.13 0.^

0.^

-0.

After five iterations, here are the estimated values.

Department of Computer Science — University of San Fran

Example

+1 -

1

2

3 4 6

5 7

8

9

0.^

0.68 0. 0.15 0.^

0.^

-0.

After six iterations, here are the estimated values. At this point, we are close to converging.

Department of Computer Science — University of San Francisco – p.27/

??

Discussion Strengths of Value iteration^ Guaranteed to converge to correct solution^ Simple iterative algorithm Weaknesses:^ Convergence can be slow^ We really don’t need all this information^ Just need

what to do

at each state.

Department of Computer Science — University of San Francisco – p.28/

??

Policy iteration Policy iteration helps address these weaknesses. Searches directly for optimal policies, rather than stateutilities. Same idea: iteratively update policies for each state. Two steps:^ Given a policy, compute the utilities for each state.^ Compute a new policy based on these new utilities.

Department of Computer Science — University of San Fran

Example

+1 -

1

2

3 4 6

5 7

8

9

-0.^

-0.04 -0.^

-0.^

-0.^

-0. 0.63 0.

And use these new utility estimates to construct optimalpolicies^

Department of Computer Science — University of San Francisco – p.36/

??

Example

+1 -

1

2

3 4 6

5 7

8

9

0.^

0.04 -0.^

-0.^

0.^

-0. 0.67 0.

Again, use the policies to re-estimate utilities

Department of Computer Science — University of San Francisco – p.37/

??

Example

+1 -

1

2

3 4 6

5 7

8

9

0.^

0.04 -0.^

-0.^

0.^

-0. 0.67 0.

And then use the utilities to update your optimal policies.

Department of Computer Science — University of San Fran

Example

+1 -

1 2

3 4 6

5 7

8 9

0.^

  1. 0.06 -0.^ -0.^ 0.68 0.33 0.13^ -0. And once more update your utility estimates based onthe new policy. Once we update our policy based on these newestimates, we see that it doesn’t change, so we’re done.

Department of Computer Science — University of San Francisco – p.39/

??

Discussion Advantages:^ Faster convergence.^ Solves the actual problem we’re interested in. Wedon’t really care about utility estimates except as away to construct a policy.

Department of Computer Science — University of San Francisco – p.40/

??

POMDPs So far we’ve assumed that the agent knows where it is,and only actions are stochastic. What if our sensors are also faulty? Agent may not know exactly what state it is in. We can extend the MDP model to a partially observableMarkov decision process. (POMDP)

Department of Computer Science — University of San Fran

Belief state We introduce the idea of a

belief state

This is a probability distribution over states in theworld, indicating the belief that we are in a specificstate. We now have to explicitly consider sensing in our model. Agent takes an action Then senses where it thinks it is

Department of Computer Science — University of San Francisco – p.42/

??

POMDPs The basic idea is this: The agent’s new belief state is given by the action takenin the current state, the transition model, and itsprevious belief state and an observation

o.

′′ b(s) =^ O

∑′(s, o) s

′T (s, a, s )b(s)

where^ O is an observation function that tells provides the agent with new information about the current state.^ If the environment is fully observable and sensors areerror-free, then

′ O(s, o) = ′^ sfor all ′ s. Department of Computer Science — University of San Francisco – p.43/

??

POMDPs We then need to incorporate belief state into policyselection.^ Choose the action that maximizes expected utility,weighted by the probability of being in each possiblestate. This works well, but is exponentially hard. Algorithms for approximating POMDP solutions andreducing problem size are currently hot research areas.

Department of Computer Science — University of San Fran

Learning a Policy MDPs and POMDPs assume that we know a model ofthe world^ Specifically, the transition function

T

We can also learn a policy through interaction with theenvironment. This is known as

reinforcement learning

We’ll talk about this in a couple of weeks.

Department of Computer Science — University of San Francisco – p.45/

??

Summary Markov decision policies provide an agent with adescription of

how to act optimally

for any state in a

problem.^ Must know state space, have a fixed goal. Value iteration and policy iteration can be applied tosolve this. In partiallly observable worlds, we can extend this modelto POMDPs.

Department of Computer Science — University of San Francisco – p.46/

??