David Silver’s YouTube series on Reinforcement Learning, Episode 3.

The full lesson is the following:

We have so far formulated the Bellman Equation, but we did not cover ways to solve it. In this article, we will explore Dynamic Programming, and more specifically:

  • policy evaluation
  • policy iteration
  • value iteration

Dynamic Programming

Dynamic Programming is a very general solution method for problems which have two properties :

  • Optimal substructure :
    • principle of optimality applies
    • optimal solution can be decomposed into subproblems
  • Overlapping subproblems :
    • subproblems recur many times
    • solutions can be cached and reused

Markov Decision Processes satisfy both of these properties. The Bellman equation gives a recursive decomposition. The values function stores and reuses solutions.

Dynamic Programming assumes full knowledge of the MDP. We know the dynamics and the reward. It is used for planning in an MDP, and it’s not a full Reinforcement Learning problem.

For Prediction :

  • The input takes the form of an MDP and a policy , or an MRP .
  • The output is a value function .

For Control :

  • The input takes the form of an MDP and a policy .
  • The output is the optimal value function , and an optimal policy .

Dynamic Programming is used in :

  • Scheduling algorithms (sequence alignment)
  • Graph algorithms (shortest path)
  • Graphical models (Viterbi)
  • Bioinformatics (lattice models)

Policy Evaluation

If we are given an MDP and a policy (e.g always go straight ahead), how can we evaluate this policy ?

We apply the Bellman expectation backup iteratively.

We start off with an arbitrary value function . We then do a 1-step look-ahead to figure out . Then, we iterate many times until .

We use synchronous backups :

  • At each iteration :
    • For all states
    • Update from
    • where is a successor state of

The convergence of this process can also be proven.

We can represent Policy Evaluation graphically as in the previous article :

image

Which can be re-written under matrix form :

Let us now illustrate this concept with a simple grid. The aim of the agent is to reach one of the terminal states (either upper left or lower right). The reward is until the terminal state is reached.

image

We suppose that the agent follows a uniform random policy, and has chance to pick each action (Up, Down, Left, Right) :

Here is what a the greedy policy would look like at step of this random policy :

image

The initial estimate of the value function is to put zeros everywhere. Then, let’s move on by 1 step. For each cell (except for the terminal states), we set the value as a weighted average of the reward we get by following each action. Since the reward is at each cell expect for the terminal states, the average is equal to -1 everywhere.

image

Let’s now move on by 1 step :

image

We still get the immediate reward of for moving, but we add to this amount the value of the cell at the previous step. Threfore, by following this principle by which we add the celle value to the reward we get, when we moved from step 0 to step 1, the value of the cells right next to a terminal state is given by:

If we move by a final step, to :

image

At that point, we have reached the optimal policy. There is no longer need to iterate.

We now have a way to find the value of a given policy iteratively. How do we then identify the optimal policy ?

Policy Iteration

Given a policy , how can we improve the policy we used to have ?

  • First, evaluate this policy :
  • Then, improve the policy greedily :

The greedy part means that we systematically optimize over the next action by taking into account what will happen if we take this action.

In general, we need a lot of improvements and evaluations. This process of policy iteration always converges to .

The process can be represented as such :

image

Let us consider a deterministic policy : . We can improve the policy by acting greedily :

This improves the value from any state over one step (at lease) :

Therefore, the value function is improved over time :

What if the improvements stop, i.e :

Have we reached the optimal state? Or a we stuck? We actually satisfy the Bellman optimality equation :

Therefore, for all .

And is the optimal policy.

Policy iteration solves MDPs. If the iteration ever stops, it means that the optimal policy has been identified.

Modified Policy Iteration

Sometimes, we do not need the policy iteration to converge to exactly, since this process might be really long. We can therefore :

  • introduce a stopping criteria over an convergence
  • stop after iterations

This is called the modified policy iteration.

Value Iteration

Principle of optimality : A policy achieves the optimal value from state , if and only if for any state reachable from , achieves the optimal value state :

Suppose that we know the solution to subproblems . Using Bellman, the solution can be found by one-step lookahead :

The idea of value iteration is to apply these updates iteratively.

We start with the final rewardds, and work backwards. Suppose that we work on a small gridworld again, where our goal is to reach the blue top-left corner.

image

As before, we suppose that moving has a reward of , and reaching the final state has a reward of . When we compute the value iteration, we propagate the reward step by step :

image

In value iteration, we must find optimal policy by iteratively applying Bellman optimality backup :

It relies on synchronous backups :

  • At each state
  • For all states
  • Update from

Unlike policy iteration, there is no explicit policy.


Like it? Buy me a coffeeLike it? Buy me a coffee

Categories:

Updated:

Leave a comment