Docsity

Understanding States, Actions, and Utilities in Reinforcement Learning, Study notes of Computer Science

Toggle sidebar
bg1
1
Reinforcement๎˜ƒlearning:
Markov๎˜ƒDecision๎˜ƒProcesses
1
Reinforcement๎˜ƒLearning
โ€ขYou๎˜ƒcan๎˜ƒthink๎˜ƒof๎˜ƒsupervised๎˜ƒlearning๎˜ƒas๎˜ƒthe๎˜ƒ
teacher๎˜ƒproviding๎˜ƒanswers๎˜ƒ(the๎˜ƒclass๎˜ƒlabels)
โ€ขIn๎˜ƒreinforcement๎˜ƒlearning,๎˜ƒthe๎˜ƒagent๎˜ƒlearns๎˜ƒ
based on apunishment/reward scheme
2
based
๎˜ƒ
on
๎˜ƒ
a
๎˜ƒ
punishment/reward
๎˜ƒ
scheme
โ€ขBefore๎˜ƒwe๎˜ƒcan๎˜ƒtalk๎˜ƒabout๎˜ƒreinforcement๎˜ƒ
learning,๎˜ƒwe๎˜ƒneed๎˜ƒto๎˜ƒintroduce๎˜ƒMarkov๎˜ƒ
Decision๎˜ƒProcesses
Decision๎˜ƒProcesses:๎˜ƒGeneral๎˜ƒ
Description
โ€ขDecide๎˜ƒwhat๎˜ƒaction๎˜ƒto๎˜ƒtake๎˜ƒnext๎˜ƒgiven๎˜ƒthat๎˜ƒyour๎˜ƒ
action๎˜ƒwill๎˜ƒaffect๎˜ƒwhat๎˜ƒhappens๎˜ƒin๎˜ƒthe๎˜ƒfuture
โ€ขReal๎˜ƒworld๎˜ƒexamples:
โ€“ Robot๎˜ƒpath๎˜ƒplanning
3
โ€“Elevator๎˜ƒscheduling
โ€“Travel๎˜ƒroute๎˜ƒplanning
โ€“Aircraft๎˜ƒnavigation
โ€“ Manufacturing๎˜ƒprocesses
โ€“ Network๎˜ƒswitching๎˜ƒand๎˜ƒrouting
Sequential๎˜ƒDecisions
โ€ข Assume a fully observable,
deterministic environment
โ€ข Each grid cell is a state
โ€ขThe
g
oal state is marked +1
4
g
โ€ข At each time step, agent must
move Up, Right, Down, or Left
โ€ข How do you get from start to
the goal state?
Sequential๎˜ƒDecisions
โ€ข Suppose the environment is
now stochastic
โ€ข With 0.8 probability you go
in the direction you intend
โ€ข
With 0 2 probability you
With
0
.
2
probability
you
move at right angles to the
intended direction (0.1 in
either direction โ€“ if you hit
the wall you stay put)
โ€ข What is the optimal solution
now?
Sequential๎˜ƒDecisions
โ€ข Up, Up, Right, Right, Right
reaches the goal state with
probability 0.85=032768
โ€ข But in this stochastic world,
going Up, Up, Right, Right,
Right might end up with
6
Right
might
end
up
with
you actually going Right,
Right, Up, Up, Right with
probability
(0.14)(0.8)=0.00008
โ€ข Even worse, you might end
up in the -1 state
accidentally
pf3
pf4
pf5

Partial preview of the text

Download Understanding States, Actions, and Utilities in Reinforcement Learning and more Study notes Computer Science in PDF only on Docsity!

Reinforcement learning:

Markov Decision Processes

1

Reinforcement Learning

  • You can think of supervised learning as the

teacher providing answers (the class labels)

  • In reinforcement learning, the agent learns

based on a punishment/reward scheme

2

based on a punishment/reward scheme

  • Before we can talk about reinforcement

learning, we need to introduce Markov

Decision Processes

Decision Processes: General

Description

  • Decide what action to take next given that your action will affect what happens in the future
  • Real world examples:
    • Robot path planning

3

  • Elevator scheduling
  • Travel route planning
  • Aircraft navigation
  • Manufacturing processes
  • Network switching and routing

Sequential Decisions

  • Assume a fully observable, deterministic environment
  • Each grid cell is a state
  • The goal state is marked +

4

g

  • At each time step, agent must move Up, Right, Down, or Left
  • How do you get from start to the goal state?

Sequential Decisions

  • Suppose the environment is now stochastic
  • With 0.8 probability you go in the direction you intend
  • With 0 2 probability youWith 0.2 probability you move at right angles to the intended direction (0.1 in either direction โ€“ if you hit the wall you stay put)
  • What is the optimal solution now?

Sequential Decisions

  • Up, Up, Right, Right, Right reaches the goal state with probability 0.8 5 =
  • But in this stochastic world, going Up, Up, Right, Right, Right might end up with

6

Right might end up with you actually going Right, Right, Up, Up, Right with probability (0.1 4 )(0.8)=0.

  • Even worse, you might end up in the -1 state accidentally

Transition Model

  • Transition model: a specification of the outcome probabilities for each action in each possible state
  • T( s , a , sโ€™ ) = probability of going to state sโ€™ if you are in state s and do action a
  • The transitions are Markovian ie. the probability of reaching state sโ€™ from s depends only on s and not on the

7

reaching state s from s depends only on s and not on the history of earlier states (aka The Markov Property)

  • Mathematically: Suppose you visited the following states in chronological order: s 0 , โ€ฆ, st P(st+1 | a, s 0 , โ€ฆ, st ) = P(st+1 | a, st)

Markov Property Example

Suppose s 0 = (1,1), s 1 = (1,2), s 2 = (1,3)

s If I go right from state s^2 , the

s (^1)

s 2 s (^3)

8

2 probability of going to s 3 only depends on the fact that I am at state s 2 and not the entire state history {s 0 , s 1 , s 2 }

s (^0)

The Reward Function

  • Depends on the sequence of states (known

as the environment history)

  • At each state s , the agent receives a reward

R(s) which may be positive or negative (but

9

R(s) which may be positive or negative (but

must be bounded)

  • For now, weโ€™ll define the utility of an

environment history as the sum of the

rewards received

Utility Function Example

R(4,3) = +1 (Agent wants to get here) R(4,2) = โ€ 1 (Agent wants to avoid this R(s) = โ€0.04 (for all other states) U(s 1 , โ€ฆ, sn) = R(s 1 ) + โ€ฆ + R(sn)

10

If the states an agent goes through are Up, Up, Right, Right, Right, the utility of this environment history is: -0.04-0.04-0.04-0.04-0.04+

Utility Function Example

If thereโ€™s no uncertainty, then the agent would find the sequence of actions that maximizes the sum of the rewards of the visited states

11

Markov Decision Process

The specification of a sequential decision problem for a fully observable environment with a Markovian transition model and additive rewards is called a Markov Decision Process (MDP) A MDP h th f ll i t

12

An MDP has the following components:

  1. A finite set of states S along with an initial state S 0
  2. A finite set of actions A
  3. Transition Model: T(s, a, sโ€™) = P( sโ€™ | a, s )
  4. Reward Function: R(s)

Nonstationary Policies

  • Nonstationary policy: the optimal action in a given state changes over time
  • With a finite horizon, the optimal policy is nonstationary
  • With an infinite horizon there is no incentive to

19

  • With an infinite horizon, there is no incentive to behave differently in the same state at different times
  • With an infinite horizon, the optimal policy is stationary
  • We will assume infinite horizons

Utility of a State Sequence

Under stationarity, there are two ways to assign utilities to sequences:

  1. Additive rewards: The utility of a state sequence is:

20

U(s 0 , s 1 , s 2 , โ€ฆ) = R(s 0 ) + R(s 1 ) + R(s 2 ) + โ€ฆ

  1. Discounted rewards: The utility of a state sequence is: U(s 0 , s 1 , s 2 , โ€ฆ) = R(s 0 ) + ฮณR(s 1 ) + ฮณ^2 R(s 2 ) + โ€ฆ Where 0 โ‰ค ฮณ โ‰ค 1 is the discount factor

The Discount Factor

  • Describes preference for current rewards over future rewards
  • Compensates for uncertainty in available time (models mortality)
  • Eg Being promised $10000 next year is only

21

  • Eg. Being promised $10000 next year is only worth 90% of being promised $10000 now
  • ฮณ near 0 means future rewards donโ€™t mean anything
  • ฮณ = 1 makes discounted rewards equivalent to additive rewards

Utilities

We assume infinite horizons. This means that if the agent doesnโ€™t get to a terminal state, then environmental histories are infinite, and utilities with additive rewards are infinite. How do we deal with this? Discounted rewards makes utility finite. A i l t ibl d i R d 1

22

Assuming largest possible reward is Rmax and ฮณ < 1 ,

max max 0

0

0 1 2

ฮณ

ฮณ

ฮณ

โˆ‘

โˆ‘ โˆž =

โˆž

R R

Us s s Rs

t

t

t t

t

Computing Optimal Policies

  • A policy ฯ€ generates a sequence of states
  • But the world is stochastic, so a policy ฯ€ has

a range of possible state sequences, each

of which has some probability of occurring

23

of which has some probability of occurring

  • The value of a policy is the expected sum of

discounted rewards obtained

The Optimal Policy

  • Given a policy ฯ€, we write the expected

sum of discounted rewards obtained as:

โŽฅ โŽฆ

โŽค โŽข โŽฃ

โŽก โˆ‘

โˆž

0

( ) | t

t E ฮณ t^ Rs ฯ€

24

โŽฃ t = 0 โŽฆ

  • An optimal policy ฯ€* is the policy that

maximizes the expected sum above

โŽฅ โŽฆ

โŽค โŽข โŽฃ

โŽก = (^) โˆ‘

โˆž

= 0

  • (^) arg max ( )| t

t ฯ€ E ฮณ t^ Rs ฯ€ ฯ€

The Optimal Policy

  • For every MDP, there exists an optimal policy
  • There is no better option (in terms of expected sum of rewards) than to follow this policy
  • How do you calculate this optimal policy? Canโ€™t

25

evaluate all policiesโ€ฆtoo many of them

  • First, need to calculate the utility of each state
  • Then use the state utilities to select an optimal action in each state

Rewards vs Utilities

  • Whatโ€™s the difference between R(s) the

reward for a state and U(s) the utility of a

state?

  • R(s) โ€“ the short term reward for being in s

26

( ) g

  • U(s) โ€“ The longโ€term total expected reward for the sequence of states starting at s (not just the reward for state s)

Utilities in the Maze Example

Start at state (1,1). Letโ€™s suppose we choose the action Up.

27

U(1,1) = R(1,1) + ...

Reward for current state

Utilities in the Maze Example

Start at state (1,1). Letโ€™s choose the action Up.

U(1,1) = R(1,1) + 0.8U(1,2) + 0.1U(2,1) + 0.1*U(1,1)

Prob of moving up

Prob of moving right

Prob of moving left (into the wall) and staying put

Utilities in the Maze Example

Now letโ€™s throw in the

29

discounting factor

U(1,1) = R(1,1) + ฮณ* 0.8U(1,2) + ฮณ 0.1U(2,1) + ฮณ 0.1*U(1,1)

The Utility of a State

'

( ) () (, , ') (') s

U s Rs ฮณ T sas U s

If we choose action a at state s, expected future rewards (discounted) are:

Reward at current state s Probability of moving from state s to state sโ€™ by doing action a Expected sum of future discounted rewards starting at state sโ€™

Expected sum of future discounted rewards starting at state s