PAC Bounds for Discounted MDPs
Tor Lattimore, Marcus Hutter
Introduction
The goal of reinforcement learning is to construct algorithms that learn to act optimally, or nearly so, in unknown environments. In this paper we restrict our attention to finite state discounted MDPs with unknown transitions. The performance of reinforcement learning algorithms in this setting can be measured in a number of ways, for instance by using regret or PAC bounds [Kakade, 2003]. We focus on the latter, which is a measure of the number of time-steps where an algorithm is not near-optimal with high probability. Many previous algorithms have been shown to be PAC with varying bounds [Kakade, 2003, Strehl and Littman, 2005, Strehl et al., 2006, 2009, Szita and Szepesvári, 2010, Auer, 2011].
We modify the Upper Confidence Reinforcement Learning (UCRL) algorithm of Auer et al. , Auer , Strehl and Littman and, under the assumption that there are at most two possible next-states for each state/action pair, prove a PAC bound of
This bound is an improvementIn this slightly restricted setting. on the previous best [Auer, 2011] and published best [Szita and Szepesvári, 2010], which are
respectively. The additional assumption is unfortunate and is probably unnecessary as discussed in Section 6.
We also present a matching (up to logarithmic factors) lower bound that is both larger and more general than the previous best given by Strehl et al. . The class of MDPs used in the counter-example satisfy the assumption used in the upper bound.
Notation
Unfortunately, we found it impossible to reduce the amount of notation and number of constants. While we have endeavoured to define everything before we use it, readers are encouraged to consult the tables of notation and constants found in the appendix.
Estimation
In the next section we will introduce the new algorithm, but first we give an intuitive introduction to the type of parameter estimation required to prove sample-complexity bounds for MDPs. The general idea is to use concentration inequalities to show the empiric estimate of a transition probability approaches the true probability exponentially fast in the number of samples gathered. There are a wide variety of concentration inequalities, each catering to a slightly different purpose. We improve on previous work by using Bernstein’s inequality, which takes variance into account (unlike Hoeffding). The following example demonstrates the need for Bernstein’s inequality when estimating the value functions of MDPs. It also gives insight into the workings of the proof in the next two sections.
Consider the Markov reward process on the right with two states where rewards are shown inside the states and transition probabilities on the edges. Note this is not an MDP because there are no actions. We are only concerned with how well the value can be approximated. Assume , arbitrarily large (but not ) and let be the empiric estimate of and consider the error in our estimated value and the true value while in state . One can show that
Therefore if is to be estimated to within accuracy, we need . Now suppose we bound via a standard Hoeffding bound, then with high probability where is the number of visits to state and . Therefore to obtain an error less than we need visits to state , which is already too many for a bound in terms of . If Bernstein’s inequality is used instead, then and so is required, but Equation (1) depends on . Therefore visits are sufficient. If then Equation (1) can be improved.
Upper Confidence Reinforcement Learning Algorithm
UCRL is based on the optimism principle for solving the exploration/exploitation dilemma. It is model-based in the sense that at each time-step the algorithm acts according to a model (in this case an MDP, ) chosen from a model class. The idea is to choose the smallest model class guaranteed to contain the true model with high probability and act according to the most optimistic model within this class. With a good choice of model class this guarantees a policy that biases its exploration towards unknown states that may yield good rewards while avoiding states that are known to be bad. The approach has been successful in obtaining uniform sample complexity (or regret) bounds in various domains where the exploration/exploitation problem is an issue [Lai and Robbins, 1985, Agrawal, 1995, Auer et al., 2002, Strehl and Littman, 2005, Auer and Ortner, 2007, Auer et al., 2010, Auer, 2011].
Unfortunately, to prove our new bound we needed to make an assumption about the transition probabilities of the true MDP. We do not believe this assumption is crucial, but it substantially eases the analysis by removing some dependencies in the more general problem. In Section 6 we present an approach to remove the assumption as well as some intuition into why this ought to be possible, but non-trivial.
The true unknown MDP, , satisfies for all but two denoted .Note that and are dependent on and are known to the algorithm.
The pseudo-code of UCRL can be found below, but first we define a knownness index, . If is the number of times a state/action pair has been visited then is the knownness of that state/action pair at level . The knownness of a state increases with the number of visits, is bounded by and is always a natural number. The reason for defining these now is that UCRL will only perform an update when the knownness index of some states would be changed by an update. Unfortunately, the definition below is unlikely to be very intuitive. A more thorough explanation of knownness is given in Section 5.
Note that the existence of the function ExtendedValueIteration is proven and an algorithm given by Strehl and Littman .
Upper PAC Bounds
We present two new PAC bounds. The first improves on all previous analysis, but relies on Assumption 1. The second is completely general, but gains an additional dependence on leading to a PAC bound in terms of and . This bound is worse than the previous best in terms of , but better in terms .
Let be the true MDP satisfying Assumption 1. Let be the actual (non-stationary) policy of UCRL (Algorithm 1), then for at most
time-steps with probability at least . ( and are defined in Appendix D.)
Note that although is stationary, the global policy of UCRL is non-stationary. Despite this, we will abuse notation by allowing ourselves to write , whereas really should depend on the entire history. Fortunately, when UCRL is not delaying, the policy is nearly stationary in the sense that it will be so for the next time-steps. This allows us to work almost entirely with stationary policies and so discard the cumbersome notation required for non-stationary policies.
Let be the true MDP (possibly not satisfying Assumption 1) then there exists a policy such that for at most time-steps with probability at least .
The proof of Theorem 4 is omitted, but follows easily by converting an arbitrary MDP with states into a functionally equivalent MDP with states that satisfies Assumption 1. This is done by adding a tree of states for each state/action pair and rescaling .
Proof Overview. The proof of Theorem 3 borrows components from the work of Auer et al. , Strehl and Littman and Szita and Szepesvári .
Show that the true MDP remains in the model class for all .
Use the optimism principle to show that if and then . This key fact shows that if is not nearly-optimal at some time-step then the true value and model value of differ and so some information is (probably) gained by following this policy.
The final component is to bound the number of time-steps when is not nearly-optimal.
Episodes and phases. UCRL operates in episodes, which are blocks of time-steps ending when update is called. The length of each episode is not fixed, instead, an episode ends when the knownness of a state changes. We often refer to time-step and episode and unless there is ambiguity we will not define and just assume it is the episode in which resides. A delay phase is the period of contiguous time-steps where UCRL is in the function delay, which happens immediately before an update. An exploration phase is a period of time-steps starting at where is not in a delay phase and where . Exploration phases do note overlap. More formally, the starts of exploration phases, , are defined inductively
Note there need not, and with high probability will not, be infinitely many such . The exploration phases are only used in the analysis, they are not known to UCRL.
Weights and variances. We define the weightAlso called the discounted future state distribution in Kakade . of state/action pair as follows.
The active set. We will shortly see that states with small cannot influence the differences in value functions. Thus we define an active set of states where is not tiny. At each time-step define the active set by
Knownness. We now expand on the concept of knownness and explain its purpose. We write for the value of at time-step and where is the episode associated with time-step . Let be some non-delaying time-step and suppose is active (). Now let and note that . We define a partition of the active set by
The set represents a set of states that have comparable weights and visit counts. We will show that if for all then the values and are reasonably close. This result forms a key stage in the proof of Theorem 3 because it shows that if is not nearly-optimal at time-step then there exists a that is quite large and where states have not been visited sufficiently. Furthermore, the weights where are large enough that some learning is expected to occur.
Analysis. The proof of Theorem 3 follows easily from three key lemmas.
The total number of updates is bounded by .
If and is not in a delay phase and then
for all with probability at least .
The number of exploration phases is bounded by with probability at least .
The proofs of the lemmas are delayed while we apply them to prove Theorem 3.
Proof of Theorem 3. By Lemma 6, for all with probability . By Lemma 7 we have that the number of exploration phases is bounded by with probability . Now if is not in a delaying or exploration phase and then by Lemma 5, is nearly-optimal. Finally note that the number of updates is bounded by and so the number of time-steps in delaying phases is at most . Therefore UCRL is nearly-optimal for all but time-steps with probability .
We now turn our attention to proving Lemmas 5, 6 and 7. Of these, only Lemma 7 presents a substantial challenge.
Proof of Lemma 5. For part 1 we note that for the knownness of a state/action pair at level satisfies . Since the knownness index for each is non-decreasing and an update only occurs when an index is increased, the total number of updates is bounded by .
The proof of part 2 is closely related to the approach taken by Strehl and Littman . Recall that is chosen optimistically by extended value iteration. This generates an MDP, , such that for all . Since we have assumed we have that . Therefore . Finally note that is a non-delaying time-step and so policy will remain stationary and equal to for at least time-steps. Using the definition of the horizon, , we have that . Therefore as required.
Proof of Lemma 6. In the previous lemma we showed that there are at most updates. Therefore we only need to check for each up to . Fix an pair and apply the best of either Bernstein or Hoeffding inequalities to show that with probability . Setting and applying the union bound completes the proof.
We are now ready to work on Lemma 7. The proof follows from two lemmas:
If is the start of an exploration phase then there exists a such that .
If for sufficiently many then sufficient information is gained that some state/action pair must have an increase in knownness.
Let be a non-delaying time-step and assume . If for all then .
The full proof is long, technical and has been relegated to Appendix B. We provide a sketch, but first we need some useful results about MDPs and the differences in value functions.
Let and be two Markov decision processes differing only in transition probabilities and be a stationary policy then
If at time-step and then
The idea is to note that are in and apply the definition of the confidence intervals. The full proof is subsumed in the proof of the more general Lemma 33 in Appendix C. The following lemma bounds the expected total discounted local variance.
The following lemmas are used to show that cannot be larger than for too many time-steps with high probability. Combined with Lemma 8 above this will be sufficient to bound the number of exploration phases. Let be the start of an exploration phase and define to be the number of visits to state within the next time-steps. Formally, .
Let be the start of an exploration phase and then .
Proof sketch. Use the definition of the horizon to show that is not much larger than a bounded-horizon version. Compare and the definition of .
Let be as in Appendix D. If for exploration phases then with probability at least .
Now and so by Lemma 12 we have . We now prepare to use Bernstein’s inequality. Let , and then
Setting this equal to and solving for gives
Naively bounding and noting that leads to
Since satisfies this, the result is complete.
Bounding the number of useful visits. A visit to state/action pair in time-step is -useful if . Fixing a we bound the number of -useful visits to state/action pair . Suppose and and then for all . Therefore for each pair there at most visits that are -useful.
Bounding the number of exploration phases. Let and be the start of an exploration phase. Therefore and so by Lemma 8 there exists a such that . If at the start of exploration phases, then by Lemma 13
Therefore by the union bound there are at most exploration phases with probability .
Eliminating the Assumption
The last problem is that extended value iteration is no longer a trivial operation (even granting infinite computation). The problem is that the condition is not local to , it also depends on the choice of for . This complication is probably resolvable, but the formal demonstration of extended value iteration is no longer so easy.
Lower PAC Bound
We now turn our attention to proving a matching lower bound. The approach is similar to that of Strehl et al. , but we make two refinements to improve the bound to depend on and remove the policy restrictions. The first is to add a delaying state where no information can be gained, but where an algorithm may still fail to be PAC. The second is more subtle and will be described in the proof.
A non-stationary policy is a function .
Let be a (possibly non-stationary) policy depending on and , then there exists a Markov decision process such that for at least time-steps with probability at least where
and are independent of the policy as well as all inputs .
The proof can found in Appendix A, but we give the counter-example MDP and intuition.
Counter Example. We prove Theorem 15 for a class of MDPs where and . The rewards and transitions for a single action are depicted in the diagram on the right where for some and for all other actions. Some remarks: {enumerate*}
States and are almost completely absorbing and confer maximum/minimum rewards respectively.
The transitions are independent of actions for all states except state . From this state, actions lead uniformly to / except for one action, , which has a slightly higher probability of transitioning to state . Thus is the optimal action in state .
State has an absorption rate such that, on average, a policy will stay there for time-steps.
Intuition. The MDP above is very bandit-like in the sense that once a policy reaches state it should choose the action most likely to lead to state whereupon it will either be rewarded or punished (visit state or ). Eventually it will return to state when the whole process repeats. This suggests a PAC-MDP algorithm can be used to learn the bandit with . We can then make use of a theorem of Mannor and Tsitsiklis on bandit sample-complexity to show that the number of times is not selected is at least
Improving the bound to depend on is intuitively easy, but technically somewhat annoying. The idea is to consider the value differences in state as well as state . State has the following properties: {enumerate*}
The absorption rate is sufficiently large that any policy remains in state for around time-steps.
The absorption rate is sufficiently small that the difference in values due to bad actions planned in state still matter while in state . While in state an agent cannot make an error in the sense that for all . But we are measuring and so an agent can be penalised if its policy upon reaching state is to make an error. Suppose the agent is in state at some time-step before moving to state and making a mistake. On average it will stay in state for roughly time-steps during which time it will plan a mistake upon reaching state . Thus the bound in Equation (5) can be multiplied by . The proof is harder because an agent need not plan to make a mistake in all future time-steps when reaching state before eventually doing so in one time-step. Note that Strehl et al. proved their theorem for a specific class of policies while Theorem 15 holds for all policies.
Conclusion
Summary. We presented matching upper and lower bounds on the number of time-steps when a reinforcement learning algorithm can be nearly-optimal with high probability. While the lower bound is completely general, the upper bound depends on the assumption that there are at most two next-states for each state/action pair. This assumption aside, the new upper bound improves on the previously best known bound of Auer . If the assumption is dropped then the new proof can be used to construct an algorithm that is better than the bound of Auer in terms of , but worse in . The lower bound, which comes without assumptions, improves on the work of Strehl et al. by being both larger and more general. The class of MDPs used for the counter-example do satisfy Assumption 1 and so the upper and lower bounds now match in this restricted case.
Running Time. We did not analyze the running time of our version of UCRL, but expect analysis similar to that of Strehl and Littman can be used to show that UCRL can be approximated to run in polynomial time with no cost to sample-complexity.
Acknowledgements. Thanks to Peter Sunehag for his careful reading and useful suggestions.
References
Appendix A Proof of Lower PAC Bound
The proof makes use of a simple form of bandit and Theorem 16, which lower bounds the sample-complexity of bandit algorithms. We need some new notation required for non-stationary policies and bandits.
History Sequences. We write for the history sequence of length . Histories can be concatenated, so where .
Bandits. An -armed bandit is a vector . A policy interacts with a bandit sequentially. In time-step some arm is played whereupon the policy receives reward with probability and reward otherwise. This is repeated over all time-steps. More formally, a bandit policy is a function . The optimal arm is defined . A policy dependent on and has sample-complexity if for all bandits the arm chosen on time-step satisfies with probability at least .
There exist positive constants , , , and , such that for every , and there exists a bandit such that
The bandit used in the proof of Theorem 16 satisfies for all except which has .
We now prepare to prove Theorem 15. For the remainder of this section let be an arbitrary policy and be the MDP of Figure 2. As in previous work we write . The idea of the proof will be to use Theorem 16 to show that cannot be approximately correct in state too often. Then use this to show that while in state before-hand it is also not approximately correct.
Let be the sequence of states seen by policy and for arbitrary history let
If , and then
Proof sketch. Both results follow from the geometric series and easy calculus.
The following lemma lower-bounds if sub-optimal action is taken in state .
Let be a history such that and then
Proof. The result essentially follows from the definition of the value function.
where we used the definition of the value function and MDP, .
We now define time-intervals where the policy is in state . Recall we chose the absorption in this state such that the expected number of time-steps a policy remains there is approximately . We define the intervals starting when a policy arrives in state and ending when it leaves to state .
is the number of time-steps spent in state before moving to state .
The values are independent of and each other.
for all where .
Define random variables and by
Intuitively, is the event that the th phase lasts at least time-steps. is the event that the th phase lasts at least time-steps and the combined weight of sub-optimal actions at the start of a phase is at least . The following lemma shows that at least two thirds of all phases have with high probability.
Proof. Preparing to use Hoeffding’s bound,
where we used the definitions of , and Lemma 19. Therefore .
where we applied basic inequalities followed by Hoeffding’s bound.
Rearranging, setting and using the geometric series completes the proof.
So far, none of our results have been especially surprising. Lemma 25 shows that at least two thirds of all phases have length exceeding with high probability. Lemma 26 shows that if at the start of a phase assigns a high weight to the sub-optimal actions, then it does so throughout the entire phase. The following lemma is more fundamental. It shows that the number of phases where assigns a high weight to the sub-optimal actions is of order with high probability.
Let with constants as in Theorem 16 then
The idea is similar to that in [Strehl et al., 2009]. Assume a policy exists that doesn’t satisfy the condition above and then use it to learn the bandit defined by .
Proof. Let be a bandit and use to learn bandit using Algorithm 2 below, which returns an action defined as
By Theorem 16, the strategy in Algorithm 2 must fail with probability at least . Therefore with probability at least , . However is defined as the majority action of all the and so for at least time-steps . Suppose , then by Lemma 23, and . This implies that with probability , for at least time-steps as required.
Proof of Theorem 15. Suppose and then and
where Equation (6) follows from the definition of and the value function. Equation (7) by Lemma 20. Equation (8) by the definition of and Equation (8) by Lemma 26. Thus for each where , policy makes at least -errors. The proof is completed by showing that for at least time-steps with probability at least , which follows easily from Lemma 27 and Lemma 25.
Dependence on is added trivially by chaining arbitrarily many such Markov decision processes together.
Dependence on can possibly be added by a similar technique used by Strehl et al. , but details could be messy.
Appendix B Technical Results
Let be independent $1$. Then
Let be independent real-valued random variables with zero mean and variance . If with probability one then
where .
Proof. Using the first confidence interval
Appendix C Proof of Lemma 8
We need to define some higher “moments” of the value function. This is somewhat unfortunate as it complicates the proof, but may be unavoidable.
We define the space of bounded value/reward functions by
Let be some stationary policy. For define values by the Bellman equations
The following lemma generalises Lemma 10.
Let at time-step then
Assume without loss of generality that . Therefore we have
where we used Assumption 1 and the fact that .
Substituting into Equation (10) completes the proof.
The expressions and are substantially easier to bound than . First we give a naive bound on , which we use later.
Expanding the recurrence up to leads to
where we used the naive bound to control . The bounds on and are somewhat easier, and follow similar lines to the naive bound on .
Letting completes the proof.
Appendix D Constants
The proof of Theorem 3 uses many constants, which can be hard to keep track of. For convenience we list them below, including approximate upper/lower bounds as appropriate.