Docsity

CSE 291d Assignment 7: Horizon Time, Convergence, and Policy vs Value Iteration, Assignments of Computer Science

Toggle sidebar
bg1
CSE 291d. Assignment 7
Out: Tue Mar 6
Due: Tue Mar 13 (in class, no extensions)
7.1 Effective horizon time
Consider a Markov decision process (MDP) whose rewards rt∈[0,1] are bounded between zero and one.
Let h= (1 −γ)−1define an effective horizon time in terms of the discount factor 0≤γ≤1. Consider the
approximation to the (infinite horizon) discounted return,
r0+γr1+γ2r2+γ3r3+γ4r4+. . . ,
obtained by neglecting rewards from some time tand beyond. Recalling that log γ≤γ−1, show that the
error from such an approximation decays exponentially as:
X
k≥t
γkrk≤he−t/h.
Thus, we can view MDPs with discounted returns as similar to MDPs with finite horizons, where the finite
horizon h= (1 −γ)−1grows as γ→1. This is a useful intuition for proving the convergence of many
algorithms in reinforcement learning.
7.2 Convergence of iterative policy evaluation
Consider an MDP with transition matrices P(s0|s, a)and reward function R(s). In class, we showed that
the state value function Vπ(s)for a fixed policy πsatisfies the Bellman equation:
Vπ(s) = R(s) + γX
s0
P(s0|s, π(s))Vπ(s0).
For γ < 1, one method to solve this set of linear equations is by iteration. Initialize the state value function
by V0(s)=0 for all states s. The update rule at the kth iteration is given by:
Vπ
k+1(s)←R(s) + γX
s0
P(s0|s, π(s))Vπ
k(s0).
Use a contraction mapping to derive an upper bound on the error
∆k= maxs|Vk(s)−Vπ(s)|
after kiterations of the update rule. Your result should show that the error ∆kdecays exponentially fast in
the number of iterations, k, and hence that limk→∞ Vk(s)=Vπ(s)for all states s.
1
pf3
pf4
pf5

Partial preview of the text

Download CSE 291d Assignment 7: Horizon Time, Convergence, and Policy vs Value Iteration and more Assignments Computer Science in PDF only on Docsity!

CSE 291d. Assignment 7

Out: Tue Mar 6 Due: Tue Mar 13 (in class, no extensions)

7.1 Effective horizon time

Consider a Markov decision process (MDP) whose rewards rt ∈ [0, 1] are bounded between zero and one. Let h = (1 − γ)−^1 define an effective horizon time in terms of the discount factor 0 ≤ γ ≤ 1. Consider the approximation to the (infinite horizon) discounted return,

r 0 + γr 1 + γ^2 r 2 + γ^3 r 3 + γ^4 r 4 +... ,

obtained by neglecting rewards from some time t and beyond. Recalling that log γ ≤ γ − 1 , show that the error from such an approximation decays exponentially as:

∑

k≥t

γkrk ≤ he−t/h.

Thus, we can view MDPs with discounted returns as similar to MDPs with finite horizons, where the finite horizon h = (1 − γ)−^1 grows as γ → 1. This is a useful intuition for proving the convergence of many algorithms in reinforcement learning.

7.2 Convergence of iterative policy evaluation

Consider an MDP with transition matrices P (s′|s, a) and reward function R(s). In class, we showed that the state value function V π(s) for a fixed policy π satisfies the Bellman equation:

V π(s) = R(s) + γ

∑

s′

P (s′|s, π(s))V π(s′).

For γ < 1 , one method to solve this set of linear equations is by iteration. Initialize the state value function by V 0 (s) = 0 for all states s. The update rule at the kth^ iteration is given by:

V (^) kπ+1(s) ← R(s) + γ

∑

s′

P (s′|s, π(s))V (^) kπ (s′).

Use a contraction mapping to derive an upper bound on the error

∆k = maxs |Vk(s) − V π(s)|

after k iterations of the update rule. Your result should show that the error ∆k decays exponentially fast in the number of iterations, k, and hence that limk→∞ Vk(s) = V π(s) for all states s.

7.3 Policy versus value iteration

Consider an MDP with n = 6 states, binary actions, and discount factor γ = 0. 92. Download the ASCII files on the course web site that store the transition matrices and reward function for this MDP. The transition matrices are stored such that the rows sum to one. In this problem, you will compare the two classical algorithms derived in class for computing optimal policies in MDPs.

(a) Compute the optimal policy π∗(s) for this MDP using the method of policy iteration, starting from the initial guess π 0 (s) = 1 for all states s. For the step of policy evaluation, you may use either the iterative method from problem 7.2 (allowing it to converge to a high degree of accuracy) or a black- box routine for solving linear systems of equations. Turn in your source code (in the language of your choice), as well as a print-out of the optimal policy π∗(s) and its state value function V ∗(s). Also note the number of iterations required to converge to the optimal policy.

(b) Compute the optimal state value function V ∗(s) using the method of value iteration. Turn in your source code, as well as a print-out of V ∗(s). Your result in part (b) should agree with your result in part (a); you can use this to check your work.

7.4 Stochastic approximation

In this problem, you will analyze an incremental update rule for estimating the mean μ = E[X] of a random variable X from samples {x 1 , x 2 , x 3 ,.. .}. Consider the incremental update rule:

μk ← μk− 1 + αk(xk − μk− 1 ),

with the initial condition μ 0 = 0 and step sizes αk = 1/k.

(a) Show that the step sizes αk = 1/k obey the conditions (i)

∑∞ k=1 αk^ =^ ∞^ and (ii)^

∑∞ k=1 α

2 k <^ ∞, thus guaranteeing that the update rule converges to the true mean. (You are not required to prove convergence.)

(b) Show that for this particular choice of step sizes, the incremental update rule yields the same result as the sample average: μk = (1/k)(x 1 + x 2 +... + xk).

7.6 Multiplicative rewards

Consider a Markov decision process (MDP) with discrete states s ∈ S, discrete actions a ∈ A, deterministic rewards R(s), and transition probabilities P (s′|s, a). Let W π(s) denote the expected product of rewards over a finite horizon of T steps, starting from state s and following policy π; more precisely,

W π(s) = Eπ

[ (^) T ∏

t=

R(st)

∣∣ ∣∣ ∣ s^0 =^ s

] ,

where the expectation on the right hand side is over all T -step paths through state space, as weighted by their probabilities under policy π. More explicitly, we can write this expected product of rewards as:

W π(s) = R(s)

∑

S

∏T

t=

[ P ( st| st− 1 , π(st− 1 )) R(st)

] .

where the sum on the right hand side is over all paths S = (s 1 , s 2 ,... , sT ).

(a) One-step and two-step horizons Evaluate the expected product of rewards for the special cases of one and two-step horizons; that is, compute W π(s) for T = 1 and T = 2, explicitly writing out the sums over paths S in each case.

(b) Dynamic programming Consider how to compute the expected product of rewards W π(s) over a finite horizon of T ≥ 2 steps. Specifically, show how to fill in a matrix {αit} for states i ∈ S and times t ≥ 0 , such that the expected product of rewards after T steps is related in a simple way to the elements of αiT. The computation time of your algorithm should scale as O(n^2 T ), where n is the number of states.

αi 0 =?

αi,t+1 =?

W π(s) =?

Naturally, your algorithm should reproduce your solution in part (a) for the cases T = 1 and T = 2.

7.7 Explore or exploit

Consider a Markov decision process (MDP) with discrete states s ∈ { 1 , 2 ,... , n}, binary actions a ∈ { 0 , 1 }, deterministic rewards R(s), and transition probabilities:

P (s′|s, a = 0) =

n

for all s′,

P (s′|s, a = 1) =

{ 1 for s = s′, 0 otherwise.

In this MDP, the “explore” action a = 0 leads to uniformly random exploration of the state space, while the “exploit” action a = 1 leaves the agent in its current state.

The simple structure of this MDP allows one to calculate its value functions, as well as the form of its optimal policy. This problem guides you through those calculations.

(a) Local reward-mining As usual, the state-value function V π(s) is defined as the expected sum of discounted rewards starting from state s at time t = 0 and taking action π(st) at time t:

V π(s) = Eπ

[ (^) ∞ ∑

t=

γtR(st)

∣∣ ∣∣ ∣ s^0 =^ s

] .

Consider the subset of states S 1 = {s|π(s) = 1} in which the agent chooses the “exploit” action. Compute V π(s) for states s ∈ S 1 by evaluating the expected sum of discounted rewards.

(b) Bellman equation for exploration Consider the subset of states S 0 = {s|π(s) = 0} in which the agent chooses the “explore” action. Write down the Bellman equation satisfied by the value function V π(s) for states s ∈ S 0. Your answer should substitute in the appropriate transition probabilities from these states.

(c) State-averaged value function Assume that the reward function, averaged over the state space, has zero mean: (^1) n

∑ s R(s) = 0. Let μ = (^1) n |S 0 | denote the fraction of states in which the agent chooses to explore. Let r = (^1) n

∑ s∈S 1 R(s)^ denote the average reward in the remaining states. Let v = (^1) n

∑ s V^ π(s)^ denote the expected return if the initial state is chosen uniformly at random.

Combining your results from parts (a-b), show that the state-averaged expected return v is given by:

v =

γr