Planning in Markov Decision Processes with Gap-Dependent Sample Complexity

Anders Jonsson, Emilie Kaufmann, Pierre Ménard, Omar Darwiche Domingues, Edouard Leurent, Michal Valko

Introduction

In reinforcement learning (RL), an agent repeatedly takes actions and observes rewards in an unknown environment described by a state. Formally, the environment is a Markov Decision Process (MDP) M=⟨S,A,p,r⟩\mathcal{M}=\langle\mathcal{S},\mathcal{A},p,r\rangle, where S\mathcal{S} is the state space, A\mathcal{A} the action space, p={ph}h≥1p=\left\{p_{h}\right\}_{h\geq 1} a set of transition kernels and r={rh}h≥1r=\left\{r_{h}\right\}_{h\geq 1} a set of reward functions. By taking action aa in state ss at step hh, the agent reaches a state s′s^{\prime} with probability ph(s′∣s,a)p_{h}(s^{\prime}|s,a) and receives a random reward with mean rh(s,a)r_{h}(s,a). A common goal is to learn a policy π=(πh)h≥1\pi=(\pi_{h})_{h\geq 1} that maximizes cumulative reward by taking action πh(s)\pi_{h}(s) in state ss at step hh. If the agent has access to a generative model, it may plan before acting by generating additional samples in order to improve its estimate of the best action to take next.

In this work, we consider Monte-Carlo planning as the task of recommending a good action to be taken by the agent in a given state s1s_{1}, by using samples gathered from a generative model. Let Q⋆(s1,a)Q^{\star}(s_{1},a) be the maximum cumulative reward, in expectation, that can be obtained from state s1s_{1} by first taking action aa, and let a^n\hat{a}_{n} be the recommended action after nn calls to the generative model. The quality of the action recommendation is measured by its simple regret, defined as rˉn(a^n):=V⋆(s1)−Q⋆(s,a^n),  \mboxwhere  V⋆(s1):=max⁡aQ⋆(s1,a)\bar{r}_{n}(\hat{a}_{n}):=V^{\star}(s_{1})-Q^{\star}(s,\hat{a}_{n}),\;\mbox{where}\;V^{\star}(s_{1}):=\max_{a}Q^{\star}(s_{1},a).

We propose an algorithm in the fixed confidence setting (ε,δ)(\varepsilon,\delta): after nn calls to the generative model, the algorithm should return an action a^n\hat{a}_{n} such that rˉn(a^n)≤ε\bar{r}_{n}(\hat{a}_{n})\leq\varepsilon with probability at least 1−δ1-\delta. We prove that its sample complexity nn is bounded in high probability by a quantity that depends on the sub-optimality gaps of the actions that are applicable in state s1s_{1}. We also provide experiments showing its effectiveness. The only assumption that we make on the MDP is that the support of the transition probabilities ph(⋅∣s,a)p_{h}(\cdot|s,a) should have cardinality bounded by B<∞B<\infty, for all ss, aa and hh.

Monte-Carlo Tree Search (MCTS) is a form of Monte-Carlo planning that uses a forward model to sample transitions from the current state, as opposed to a full generative model that can sample anywhere. Most MCTS algorithms sample trajectories from the current state , and are widely used in deterministic games such as Go. The AlphaZero algorithm guides planning using value and policy estimates to generate trajectories that improve these estimates. The MuZero algorithm combines MCTS with a model-based method which has proven useful for stochastic environments. Hence efficient Monte-Carlo planning may be instrumental for learning better policies. Despite their empirical success, little is known about the sample complexity of state-of-the-art MCTS algorithms.

The earliest MCTS algorithm with theoretical guarantees is Sparse Sampling , whose sample complexity is polynomial in 1/ε1/\varepsilon in the case B<∞B<\infty (see Lemma 1). However, it is not trajectory-based and does not select actions adaptively, making it very inefficient in practice.

A first category of algorithms rely on optimistic planning , and require additional assumptions: a deterministic MDP , the open loop setting in which policies are sequences of actions instead of state-action mappings (the two are equivalent in MDPs with deterministic transitions), or an MDP with known parameters . For MDPs with stochastic and unknown transitions, polynomial sample complexities have been obtained for StOP , TrailBlazer and SmoothCruiser but the three algorithms suffer from numerical inefficiency, even for B<∞B<\infty. Indeed, StOP explicitly reasons about policies and storing them is very costly, while TrailBlazer and SmoothCruiser require a very large amount of recursive calls even for small MDPs. We remark that popular MCTS algorithms such as UCT are not (ε,δ)(\varepsilon,\delta)-correct and do not have provably small sample complexities.

In the setting B<∞B<\infty, BRUE is a trajectory-based algorithm that is anytime and whose sample complexity depends on the smallest sub-optimality gap Δ:=min⁡a≠a⋆(V⋆(s1)−Q⋆(s1,a))\Delta:=\min_{a\neq a^{\star}}\left(V^{\star}(s_{1})-Q^{\star}(s_{1},a)\right). For planning in deterministic games, gap-dependent sample complexity bounds were previously provided in a fixed-confidence setting . Our proposal, MDP-GapE, can be viewed as a non-trivial adaptation of the UGapE-MCTS algorithm to planning in MDPs. The defining property of MDP-GapE is that it uses a best arm identification algorithm, UGapE , to select the first action in a trajectory, and performs optimistic planning thereafter, which helps refining confidence intervals on the intermediate Q-values. Best arm identification tools have been previously used for planning in MDPs and UGapE also served as a building block for StOP .

Finally, going beyond worse-case guarantees for RL is an active research direction, and in a different context gap-dependent bounds on the regret have recently been established for tabular MDPs .

Contributions

We present MDP-GapE, a new MCTS algorithm for planning in the setting B<∞B<\infty. MDP-GapE performs efficient Monte-Carlo planning in the following sense: First, it is a simple trajectory-based algorithm which performs well in practice and only relies on a forward model. Second, while most practical MCTS algorithms are not well understood theoretically, we prove upper bounds on the sample complexity of MDP-GapE. Our bounds depend on the sub-optimality gaps associated to the state-action pairs encountered during exploration. This is in contrast to StOP and TrailBlazer, two algorithms for the same setting, whose guarantees depend on a notion of near-optimal nodes which can be harder to interpret, and that can be inefficient in practice. In the anytime setting, BRUE also features a gap-dependent sample complexity, but only through the worst-case gap Δ\Delta defined above. As can be seen in Table 1, the upper bound for MDP-GapE given in Corollary 1 improves over that of BRUE as it features the gap of each possible first action a1a_{1}, Δ1(s1,a1)=V⋆(s1)−Q1⋆(s1,a1)\Delta_{1}(s_{1},a_{1})=V^{\star}(s_{1})-Q_{1}^{\star}(s_{1},a_{1}), and scales better with the planning horizon HH. Furthermore, our proof technique relates the pseudo-counts of any trajectory prefix to the gaps of state-action pairs on this trajectory, which evidences the fact that MDP-GapE does not explore trajectories uniformly.

Learning Framework and Notation

where the supremum is taken over (deterministic) policies π=(π1,…,πH)\pi=(\pi_{1},\dots,\pi_{H}), and the expectation is on a trajectory s1,a1,…,sh,ahs_{1},a_{1},\dots,s_{h},a_{h} where sh∼ph−1(⋅∣sh−1,ah−1)s_{h}\sim p_{h-1}(\cdot|s_{h-1},a_{h-1}) and ah=πh(sh)a_{h}=\pi_{h}(s_{h}) for h∈[2,H]h\in[2,H]. With this definition, an optimal action in state s1s_{1} is a⋆∈argmaxa∈A(s1)Q⋆(s1,a)a^{\star}\in\text{argmax}_{a\in\mathcal{A}(s_{1})}Q^{\star}(s_{1},a).

We assume that there is a maximal number KK of actions available in each state, and that, for each (s,a)(s,a), the support of ph(⋅∣s,a)p_{h}(\cdot|s,a) is bounded by BB: that is, BB is the maximum number of possible next states when applying any action. We further assume that the rewards are bounded in $.Foreachpairofintegers. For each pair of integersi,hsuchthatsuch thati\leq h,weintroducethenotation, we introduce the notation[i,h]=\{i,\ldots,h\}andand[h]=[1,h]$.

A sequential planning algorithm proceeds as follows. In each episode tt, the agent uses a deterministic policy on the form πt=(π1t,…,πHt)\pi^{t}=(\pi_{1}^{t},\ldots,\pi_{H}^{t}) to generate a trajectory (s1,a1t,r1t,…,sHt,aHt,rHt)(s_{1},a_{1}^{t},r_{1}^{t},\ldots,s_{H}^{t},a_{H}^{t},r_{H}^{t}), where aht=πht(sht)a_{h}^{t}=\pi_{h}^{t}(s_{h}^{t}), rhtr_{h}^{t} is a reward with expectation rh(sht,aht)r_{h}(s_{h}^{t},a_{h}^{t}) and sh+1t∼ph(⋅∣sht,aht)s_{h+1}^{t}\sim p_{h}(\cdot|s_{h}^{t},a_{h}^{t}). After each episode the agent decides whether it should perform a new episode to refine its guess for a near-optimal action, or whether it can stop and make a guess. We denote by τ\tau the stopping rule of the agent, that is the number of episodes performed, and a^τ\hat{a}_{\tau} the guess.

We aim to build an (ε,δ)(\varepsilon,\delta)-correct algorithm, that is an algorithm that outputs a guess a^τ\hat{a}_{\tau} satisfying

while using as few calls to the generative model n=Hτn=H\tau (i.e. as few episodes τ\tau) as possible.

Our setup permits to propose algorithms for planning in the undiscounted episodic case (in which our bounds will not blow up when γ=1\gamma=1) and in discounted MDPs with infinite horizon. Indeed, choosing HH such that 2γH/(1−γ)≤ε2\gamma^{H}/(1-\gamma)\leq{\varepsilon}, an (ε,δ)(\varepsilon,\delta)-correct algorithm for the discounted episodic setting recommends an action that is 2ε2\varepsilon-optimal for the discounted infinite horizon setting.

A (recursive) baseline

Sparse Sampling can be tuned to output a guess a^\hat{a} that satisfies (1), as specified in the following lemma, which provides a baseline for our undiscounted episodic setting (see Appendix F). Note that Sparse Sampling is not strictly sequential as it does not repeatedly select trajectories.

If B<∞B<\infty, Sparse Sampling using horizon HH and performing O((H5/ε2)log⁡(BK/δ))\mathcal{O}\left(({H^{5}}/{\varepsilon^{2}})\log\left({BK}/{\delta}\right)\right) transitions in each node is (ε,δ)(\varepsilon,\delta)-correct with sample complexity O(nSS)O(n_{\text{SS}}) for nSS:=H5(BK)H/ε2n_{\text{SS}}:={H^{5}(BK)^{H}}/{\varepsilon^{2}}.

Structure of the optimal Q-value function

In our algorithm, we will build estimates of the intermediate Q-values, that are useful to compute the optimal Q-value function Q⋆(s1,a)Q^{\star}(s_{1},a). Defining

Q⋆(s1,a)=Q1(s1,a)Q^{\star}(s_{1},a)=Q_{1}(s_{1},a) and the optimal action-values Q=(Q1,…,QH)Q=(Q_{1},\ldots,Q_{H}) can be computed recursively using the Bellman equations, where we use the convention QH+1(⋅,⋅)=0Q_{H+1}(\cdot,\cdot)=0:

Let π⋆=(π1⋆,…,πH⋆)\pi^{\star}=(\pi_{1}^{\star},\ldots,\pi_{H}^{\star}) denote a deterministic optimal policy where, for h∈[H]h\in[H], πh⋆(sh)=arg⁡max⁡aQh(sh,a)\pi_{h}^{\star}(s_{h})=\arg\max_{a}Q_{h}(s_{h},a), with ties arbitrarily broken. Hence the optimal value in shs_{h} is Qh(sh,πh⋆(sh))Q_{h}(s_{h},\pi_{h}^{\star}(s_{h})).

The MDP-GapE Algorithm

In this section we present MDP-GapE, a generalization of UGapE to Monte-Carlo planning. Like BAI-MCTS for games a core component is the construction of confidence intervals on Q1(s1,a)Q_{1}(s_{1},a). The construction below generalizes that of OP-MDP for known transition probabilities.

Let nht(sh,ah,sh+1):=∑s=1t\mathds1((shs,ahs,sh+1s)=(sh,ah,sh+1))n_{h}^{t}(s_{h},a_{h},s_{h+1}):=\sum_{s=1}^{t}\mathds{1}\left((s_{h}^{s},a_{h}^{s},s_{h+1}^{s})=(s_{h},a_{h},s_{h+1})\right) be the number of observations of transition (sh,ah,sh+1)(s_{h},a_{h},s_{h+1}), and Rht(sh,ah):=∑s=1trhs(sh,ah)\mathds1((shs,ahs)=(sh,ah))R_{h}^{t}(s_{h},a_{h}):=\sum_{s=1}^{t}r_{h}^{s}(s_{h},a_{h})\mathds{1}\left((s_{h}^{s},a_{h}^{s})=(s_{h},a_{h})\right) the sum of rewards obtained when selecting aha_{h} in shs_{h}. We define the empirical transition probabilities p^t\hat{p}^{t} and expected rewards r^t\hat{r}^{t} as follows, for state-action pairs such that nht(sh,ah):=∑snht(sh,ah,s)>0n_{h}^{t}(s_{h},a_{h}):=\sum_{s}n_{h}^{t}(s_{h},a_{h},s)>0:

As rewards are bounded in $,wedefinethefollowingKullback−Leiblerupperandlowerconfidenceboundsonthemeanrewards, we define the following Kullback-Leibler upper and lower confidence bounds on the mean rewardsr_{h}(s_{h},a_{h})$ :

In order to define confidence bounds on the values QhQ_{h}, we introduce a confidence set on the probability vector ph(⋅∣sh,ah)p_{h}(\cdot|s_{h},a_{h}). We define Cht(sh,ah)=ΣB\mathcal{C}_{h}^{t}(s_{h},a_{h})=\Sigma_{B} if nht(sh,ah)=0n_{h}^{t}(s_{h},a_{h})=0 and otherwise

where ΣB\Sigma_{B} is the set of probability distribution over BB elements, βp\beta^{p} is an exploration function and KL⁡(p,q)=∑s∈Supp(p)p(s)log⁡p(s)q(s)\operatorname{KL}(p,q)=\sum_{s\in\text{Supp}(p)}p(s)\log\tfrac{p(s)}{{q}(s)} is the Kullback-Leibler divergence between two categorical distributions pp and qq with supports satisfying Supp(p)⊆Supp(q)\text{Supp}(p)\subseteq\text{Supp}(q).

We now define our confidence bounds on the action values inductively. We use the convention UH+1t(⋅,⋅)=LH+1t(⋅,⋅)=0U_{H+1}^{t}(\cdot,\cdot)=L_{H+1}^{t}(\cdot,\cdot)=0, and for all h∈[H]h\in[H],

As explained in Appendix A of , optimizing over these KL confidence sets can be reduced to a linear program with convex constraints, that can be solved efficiently with Newton Iteration, which has complexity O(Blog⁡(d))O(B\log(d)) where dd is the desired digit precision.

We provide in Section 4.1 an explicit choice for the exploration functions βr(n,δ)\beta^{r}(n,\delta) and βp(n,δ)\beta^{p}(n,\delta) that govern the size of the confidence intervals. Note that if the rewards or transitions are deterministic, or if we know pp, we can adapt our confidence bounds by setting βp=0\beta^{p}=0 or βr=0\beta^{r}=0.

MDP-GapE

As any fixed-confidence algorithm, MDP-GapE depends on the tolerance parameter ε\varepsilon and the risk parameter δ\delta. The dependency in ε\varepsilon is explicit in the stopping rule (4), while the dependency in δ\delta is in the tuning of the confidence bounds, that depend on δ\delta.

After tt trajectories observed, MDP-GapE selects the (t+1)(t+1)-st trajectory using the policy πt+1=(π1t+1,…,πHt+1)\pi^{t+1}=(\pi^{t+1}_{1},\dots,\pi^{t+1}_{H}) where the first action choice is made according to UGapE:

where btb^{t} is the current guess for the best action, which is the action bb with the smallest upper confidence bound on its gap Q1⋆(s1,a⋆)−Q1(s1,b)Q_{1}^{\star}(s_{1},a^{\star})-Q_{1}(s_{1},b), and ctc^{t} is some challenger:

Then for all remaining steps we follow an optimistic policy, for all h∈[2,H]h\in[2,H],

and the guess output when stopping is a^τ=bτ\hat{a}_{\tau}=b^{\tau}. A generic implementation of MDP-GapE is given in Algorithm 1 in Appendix A, where we also discuss some implementation details. Note that, in sharp contrast with the deterministic stopping rule proposed for Sparse Sampling in Lemma 1, MDP-GapE uses an adaptive stopping rule.

Analysis of MDP-GapE

Recall that MDP-GapE uses policy πt+1=(π1t+1,…,πHt+1)\pi^{t+1}=(\pi_{1}^{t+1},\dots,\pi_{H}^{t+1}) to select the (t+1)(t+1)-st trajectory, s1,a1t+1,s2t+1,a2t+1,…,sHt+1,aHt+1s_{1},a_{1}^{t+1},s_{2}^{t+1},a_{2}^{t+1},\dots,s_{H}^{t+1},a_{H}^{t+1}, satisfying aht+1=πht+1(sht+1)a_{h}^{t+1}=\pi_{h}^{t+1}(s_{h}^{t+1}) and sh+1t+1∼ph(⋅∣sht+1,aht+1)s_{h+1}^{t+1}\sim p_{h}\left(\cdot\left|s_{h}^{t+1},a_{h}^{t+1}\right.\right).

To define an event E\mathcal{E} that holds with high probability, let Er\mathcal{E}^{r} (resp. Ep\mathcal{E}^{p}) be the event that the confidence regions for the mean rewards (resp. transition kernels) are correct:

For a state-action pair (sh,ah)(s_{h},a_{h}), let phπ(sh,ah)p_{h}^{\pi}(s_{h},a_{h}) be the probability of reaching it at step hh under policy π\pi, and let pht(sh,ah)=phπt(sh,ah)p_{h}^{t}(s_{h},a_{h})=p_{h}^{\pi^{t}}(s_{h},a_{h}). We define the pseudo-counts of the number of visits of (sh,ah)(s_{h},a_{h}) as nˉht(sh,ah):=∑s=1tphs(sh,ah) .\bar{n}_{h}^{t}(s_{h},a_{h}):=\sum_{s=1}^{t}p_{h}^{s}(s_{h},a_{h})\,. As nht(sh,ah)−nˉht(sh,ah)n_{h}^{t}(s_{h},a_{h})-\bar{n}_{h}^{t}(s_{h},a_{h}) is a martingale, the counts should not be too far from the pseudo-counts. Given a rate function βcnt\beta^{\text{cnt}}, we define the event

Finally, we define E\mathcal{E} to be the intersection of these three events: E=Er∩Ep∩Ecnt\mathcal{E}=\mathcal{E}^{r}\cap\mathcal{E}^{p}\cap\mathcal{E}^{\text{cnt}}.

1 Correctness

One can easily prove by induction (see Appendix B) that

In Lemma 2 below, we provide a calibration of the thresholds functions βr,βp\beta^{r},\beta^{p} and βcnt\beta^{\text{cnt}} such that this sufficient condition holds. This result, proved in Appendix C, relies on new time-uniform concentration inequalities that follow from the method of mixtures .

Moreover, the maximum of these three thresholds defined (by continuity when B=1B=1) as

is such that n↦β(n,δ)n\mapsto\beta(n,\delta) is non-decreasing and n↦β(n,δ)/nn\mapsto\beta(n,\delta)/n is non-increasing.

2 Sample Complexity

In order to state our results, we define the following sub-optimality gaps. Δh(sh,ah)\Delta_{h}(s_{h},a_{h}) measures the gap in future discounted reward between the optimal action πh⋆(sh)\pi_{h}^{\star}(s_{h}) and the action aha_{h}, whereas Δ1⋆(s1,a1)\Delta_{1}^{\star}(s_{1},a_{1}) also takes into account the gap of the second best action and the tolerance level ε\varepsilon.

Recall that Δ=min⁡a≠a⋆[Q1(s1,a⋆)−Q1(s1,a)]\Delta=\min_{a\neq a^{\star}}\left[Q_{1}(s_{1},a^{\star})-Q_{1}(s_{1},a)\right]. For all h∈[H]h\in[H], we let

Our sample complexity bounds follow from the following crucial theorem, which we prove in Appendix D, that relates the pseudo-counts of state-action pairs at time τ\tau to the corresponding gap.

If E\mathcal{E} holds, every (sh,ah)(s_{h},a_{h}) is such that

The number of episodes used by MDP-GapE satisfies

The upper bound on the sample complexity n=Hτn=H\tau of MDP-GapE that follows from Corollary 1 improves over the O(H5(BK)H/ε2)\mathcal{O}(H^{5}(BK)^{H}/\varepsilon^{2}) sample complexity of Sparse Sampling. It is also smaller than the O(H4(BK)H/Δ2)\mathcal{O}(H^{4}(BK)^{H}/\Delta^{2}) samples needed for BRUE to have a reasonable upper bound on its simple regret. The improvement is twofold: first, this new bound features the problem dependent gap Δ(s1,a1)∨Δ∨ε\Delta(s_{1},a_{1})\vee\Delta\vee\varepsilon for each action a1a_{1} in state s1s_{1}, whereas previous bounds were only expressed with ε\varepsilon or Δ\Delta. Second, it features an improved scaling in H2H^{2}.

In particular, using that τ=∑t1:H∈Tnˉhτ(t1:H)\tau=\sum_{t_{1:H}\in\mathcal{T}}\bar{n}_{h}^{\tau}(t_{1:H}) where T\mathcal{T} is the set of (BK)H(BK)^{H} complete trajectories leads to a sample complexity bound featuring all gaps. However, its improvement over the bound of Corollary 1 is not obvious in the general case. For B=1B=1, that is for planning in a deterministic MDP with possibly random rewards, a slightly different proof technique leads to the following improved gap-dependent sample complexity bound (see the proof in Appendix E).

Numerical Experiments

We consider random discounted MDPs with infinite horizon in which the maximal number BB of successor states and the sparsity of rewards are controlled. The transition kernel is generated as follows: for each transition in S×A\mathcal{S}\times\mathcal{A}, we uniformly pick BB next states in S\mathcal{S}. The cumulative transition probabilities to these states are computed by sorting B−1B-1 numbers uniformly sampled in (0,1)(0,1). The reward kernel is computed by selecting a proportion of the transitions to have non-zero rewards with means sampled uniformly in (0,1)(0,1). The values for these parameters are shown in Table 3(a).

We verify empirically that MDP-GapE is (ε\varepsilon, δ\delta)-correct while stopping with a reasonable number of oracle calls. Table 3(b) shows the choice of parameters for the algorithm. For various values of the desired accuracy ε\varepsilon and of the corresponding planning horizon H=⌈log⁡γ(ε(1−γ)/2)⌉H=\lceil\log_{\gamma}(\varepsilon(1-\gamma)/2)\rceil (see Section 2), we run simulations on 200 random MDPs. We report in Table 4 the distribution of the number n=τHn=\tau H of oracle calls and the simple regret rˉn(a^n)\bar{r}_{n}(\hat{a}_{n}) of MDP-GapE over these 200 runs. We first observe that MDP-GapE verifies rˉn(a^n)<ε\bar{r}_{n}(\hat{a}_{n})<\varepsilon in all simulations, despite the use of smaller exploration functions compared to those prescribed in Lemma 2. We then compare its sample complexity to that of Sparse Sampling, which is deterministic and for which nSSn_{\text{SS}} given in Lemma 1 is a tight upper bond. We see that the sample complexity of MDP-GapE is an order of magnitude smaller than that of Sparse Sampling.

Scaling in ε𝜀\varepsilon

Comparison to the state of the art

In the fixed-confidence setting, most existing algorithms are considered theoretical and cannot be applied to practical cases. For instance, for our problem with K=5K=5 and ε=1\varepsilon=1, Sparse Sampling and SmoothCruiser both require a fixed budgetIn non-regularized MDPs, SmoothCruiser has the same sample complexity as Sparse Sampling. of at least nSS=n_{\text{SS}}=8\text{\times}{10}^{9}$.Likewise,Trailblazerisarecursivealgorithmwhichdidnotterminateinoursetting.WedidnotimplementStOPasitrequirestostoreatreeofpolicies,whichisverycostlyevenformoderatehorizons.Incomparison,Table4showsthatMDP−GapEstoppedafter. Likewise, Trailblazer is a recursive algorithm which did not terminate in our setting. We did not implement StOP as it requires to store a tree of policies, which is very costly even for moderate horizons. In comparison, Table 4 shows that MDP-GapE stopped aftern=1.9\times1041.9\text{\times}{10}^{4}oraclecallsintheworstcase.Tothebestofourknowledge,MDP−GapEisthefirstoracle calls in the worst case. To the best of our knowledge, MDP-GapE is the first(\varepsilon,\delta)$-correct algorithm for general MDPs with an easy implementation and a reasonable running time in practice. The only planning algorithms that can be run in practice are in the fixed-budget setting, which we now consider.

Fixed-budget evaluation

We compare MDP-GapE to three existing baselines: first, the KL-OLOP algorithm , which uses the same upper-confidence bounds on the rewards uhtu_{h}^{t} and states values UhtU_{h}^{t} as MDP-GapE, but is restricted to open-loop policies, i.e. sequences of actions only. Second, the BRUE algorithm which explores uniformly and handles closed-loop policies. Third, the popular UCT algorithm , which is also closed-loop and performs optimistic exploration at all depths. UCT and its variants lack theoretical guarantees, but they have been shown successful empirically in many applications. For each algorithm, we tune the planning horizon HH similarly to KL-OLOP, by dividing the available budget nn into τ\tau episodes, where τ\tau is the largest integer such that τlog⁡τ/(2log⁡1/γ)≤n\tau\log\tau/(2\log 1/\gamma)\leq n, and choose H=log⁡τ/(2log⁡1/γ)H=\log\tau/(2\log 1/\gamma). The exploration functions are those of KL-OLOP and depend on τ\tau: βr(nht,δ)=βp(nht,δ)=log⁡(τ)\beta_{r}(n_{h}^{t},\delta)=\beta_{p}(n_{h}^{t},\delta)=\log(\tau). Again, we perform 200 simulations and report in Figure 2 the mean simple regret, along with its 95%95\% confidence interval. We observe that MDP-GapE compares favourably with these baselines in the high-budget regime.

Conclusion

We proposed a new, efficient algorithm for Monte-Carlo planning in Markov Decision Processes, that combines tools from best arm identification and optimistic planning and exploits tight confidence regions on mean rewards and transitions probabilities. We proved that MDP-GapE attains the smallest existing gap-dependent sample complexity bound for general MDPs with stochastic rewards and transitions, when the branching factor BB is finite. In future work, we will investigate the worse-case complexity of MDP-GapE, that is try to derive an upper bound on its sample complexity that only features ε\varepsilon and some appropriate notion of near-optimality dimension.

Acknowledgments

Anders Jonsson is partially supported by the Spanish grants TIN2015-67959 and PCIN-2017-082.

References

Appendix A Detailed Algorithm

In this section we provide a detailed algorithm for MDP-GapE, namely Algorithm 1.

There are different ways to store and update the confidence bounds on the QQ-value (that is, to specify the UpdateBounds subroutine) according to how we merge information across states.

The most obvious one, suggested by previous work (and also implemented for our experiments) does not merge information at all and builds a search tree in which a node (sh,ah)(s_{h},a_{h}) at depth hh is identified with the sequence of hh states and actions that leads to it. It leads to a very simple update: after each trajectory, one only needs to update the confidence bounds, Uh(sh,ah)U_{h}(s_{h},a_{h}) and Lh(sh,ah)L_{h}(s_{h},a_{h}), of the visited action-state pairs. Another option is to merge information for the same states and a fixed depth. But in this case the search tree becomes a graph and after each trajectory we need to re-compute the values Uh(sh,ah)U_{h}(s_{h},a_{h}) for all stored state action pairs (sh,ah)(s_{h},a_{h}) at each depth.

Appendix B Correctness of MDP-GapE

In this section we prove the correctness of MDP-GapE under the assumption that the event Er∩Ep\mathcal{E}^{r}\cap\mathcal{E}^{p} holds. Concretely, we prove by induction that

The base case is given by h=H+1h=H+1, in which case by our previous convention,

For the inductive case, assume that the inclusion holds at depth h+1h+1. Then we have

Appendix C Concentration Events

In this section we prove that the event E\mathcal{E} holds with high probability. But before we need several concentration inequalities.

Let X1,X2,…,Xn,…X_{1},X_{2},\ldots,X_{n},\ldots be i.i.d. samples from a distribution supported over {1,…,m}\{1,\ldots,m\}, of probabilities given by p∈Σmp\in\Sigma_{m}, where Σm\Sigma_{m} is the probability simplex of dimension m−1m-1. We denote by p^n\widehat{p}_{n} the empirical vector of probabilities, i.e. for all k∈{1,…,m}k\in\{1,\ldots,m\}

For all p∈Σmp\in\Sigma_{m}, for all δ∈\delta\in,

We apply the method of mixture with a Dirichlet prior on the mean parameter of the exponential family formed by the set of categorical distribution on {1,…,m}\{1,\ldots,m\}. Letting

be the log-partition function, the following quantity is a martingale:

where in the second inequality we used Lemma 3. Now we choose the uniform prior α=(1,…,1)\alpha=(1,\ldots,1). Hence we get

It remains to upper-bound the entropic term

Thus we can lower bound the martingale as follows

Using the fact that, for any supermartingale it holds that

which is a well-known property used in the method of mixtures (see ), we conclude that

where φp(λ)=log⁡(pm+∑k=1m−1pkeλk)\varphi_{p}(\lambda)=\log(p_{m}+\sum_{k=1}^{m-1}p_{k}e^{\lambda_{k}}) and pλ=∇φp0(λ)p^{\lambda}=\nabla\varphi_{p_{0}}(\lambda).

There is a more general way than the ad hoc one below to prove the result. First note that

C.2 Deviation Inequality for Bounded Distribution

Let X1,X2,…,Xn,…X_{1},X_{2},\ldots,X_{n},\ldots be i.i.d. samples from a distribution ν\nu of mean μ\mu supported on $.Wedenoteby. We denote by\widehat{\mu}_{n}$ the empirical mean

It is well known, see , that we can "project" the distribution ν\nu on a Bernoulli distribution with the same mean and then use deviation inequality for Bernoulli to concentrate the empirical mean. This method dos not lead to the sharpest confidence intervals but it provides a good trade-off between complexity computation and accuracy.

For all distribution ν\nu of mean μ\mu supported on the unit interval, for all δ∈\delta\in,

Then we can follow the proof of Proportion 1 with m=2m=2 and where MnλM_{n}^{\lambda} is only a supermartingale but this does not change the result as the property (6) still holds. Thus the proposition follows by specifying Proposition 1 to the case m=2m=2. ∎

C.3 Deviation Inequality for sequence of Bernoulli Random Variables

C.4 Proof of Lemma 2

We just prove that each event forming E=Er∩Ep∩En\mathcal{E}=\mathcal{E}^{r}\cap\mathcal{E}^{p}\cap\mathcal{E}^{n} holds with high probability. For the first one using Proposition 2, since the reward are bounded in the unit interval we have

where we used Doob’s optional skipping in the second inequality in order to apply Proposition 2, see Section 4.1 of . Similarly for the confidence regions for the probabilities transitions, using Proposition 1 we obtain

It remains to control the counts, using Proposition 3,

where we used that by definition of the pseudo-counts

Appendix D Proof of Theorem 1

In this section we present the proof of Theorem 1, which relies on three important ingredients. The first ingredient is Lemma 5 in Appendix D.1, which provides a relationship between the state-action gaps and the diameter Dht(sh,ah):=Uht(sh,ah)−Lht(sh,ah)D_{h}^{t}(s_{h},a_{h}):=U_{h}^{t}(s_{h},a_{h})-L_{h}^{t}(s_{h},a_{h}) of the confidence intervals. The second ingredient is Lemma 8 in Appendix D.2, which provides an upper bound on the diameter Dht(sh,ah)D_{h}^{t}(s_{h},a_{h}). The third ingredient is Lemma 9 in Appendix D.3, which relates the actual counts of state-action pairs to the corresponding pseudo-counts. After providing these ingredients, we present the detailed proof of Theorem 1 in Appendix D.4.

Before stating Lemma 5, we prove an important property of the UGapE algorithm. We recall that btb^{t} and ctc^{t} are the candidate best action and its challenger, defined as

The policy at the root is then defined as π1t+1(s1)=argmax b∈{bt,ct}[U1t(s1,b)−L1t(s1,b)]\pi^{t+1}_{1}(s_{1})=\underset{b\in\{b^{t},c^{t}\}}{\text{argmax }}\left[U_{1}^{t}(s_{1},b)-L_{1}^{t}(s_{1},b)\right].

For all t∈[τδ−1]t\in[\tau_{\delta}-1], the following inequalities hold:

U1t(s1,ct)−L1t(s1,bt)≤U1t(s1,πt+1(s1))−L1t(s1,πt+1(s1))U^{t}_{1}\left(s_{1},c^{t}\right)-L^{t}_{1}\left(s_{1},b^{t}\right)\leq U^{t}_{1}\left(s_{1},\pi^{t+1}(s_{1})\right)-L^{t}_{1}\left(s_{1},\pi^{t+1}(s_{1})\right),

U1t(s1,bt)−L1t(s1,ct)<2[U1t(s1,πt+1(s1))−L1t(s1,πt+1(s1))]U^{t}_{1}\left(s_{1},b^{t}\right)-L^{t}_{1}\left(s_{1},c^{t}\right)<2\left[U^{t}_{1}\left(s_{1},\pi^{t+1}(s_{1})\right)-L^{t}_{1}\left(s_{1},\pi^{t+1}(s_{1})\right)\right].

We show the first part by contradiction. If the inequality does not hold, we obtain

where the last inequality follows from the definition of btb^{t}. Combining the two inequalities yields U1t(s1,bt)<U1t(s1,ct)<max⁡a≠ctU1t(s1,a)U_{1}^{t}(s_{1},b^{t})<U_{1}^{t}(s_{1},c^{t})<\max_{a\neq c^{t}}U_{1}^{t}(s_{1},a), which contradicts the definition of ctc^{t}.

For the second part, if t<τδt<\tau_{\delta} then the algorithm has not yet stopped, implying

As a consequence of Lemma 4, we can upper bound any confidence interval involving btb^{t} and ctc^{t}.

For each pair of actions a,a′∈{bt,ct}a,a^{\prime}\in\{b^{t},c^{t}\}, it holds that

If E\mathcal{E} holds and t<τδt<\tau_{\delta}, for all h∈[H]h\in[H] and sh∈Sh(πt+1)s_{h}\in\mathcal{S}_{h}(\pi^{t+1}),

The proof for h∈[2,H]h\in[2,H] is immediate from the correctness of the confidence bounds implied by E\mathcal{E}, and the fact that the selection is optimistic:

For h=1h=1, we prove separately that each term in the max is smaller that the right hand side of desired inequality, that is

Now, by definition of the stopping rule, if t<τδt<\tau_{\delta}, U1t(s1,ct)−L1t(s1,bt)>εU_{1}^{t}\left(s_{1},c^{t}\right)-L_{1}^{t}\left(s_{1},b^{t}\right)>\varepsilon. Using the first property in Lemma 4 yields

Then, exploiting the fact that the action with largest UCB is either btb^{t} or ctc^{t}, it holds on E\mathcal{E} that

Using Corollary 3 to further upper bound the right hand side yields

Finally, one can also write, on the event E\mathcal{E},

In each of the four possible choices of (a,a′)(a,a^{\prime}), Corollary 3 implies that

Lemma 5 follows by combining (7), (8) and (9) with the definition of Δ1⋆(s1,πt+1(s1))\Delta_{1}^{\star}\left(s_{1},\pi^{t+1}(s_{1})\right). ∎

D.2 Upper bounding the diameters

In this section we state and prove Lemma 8. We use the notation σh=∑i=0h−1γi\sigma_{h}=\sum_{i=0}^{h-1}\gamma^{i} to upper bound the discounted reward in hh steps. As a first step, we prove the following auxiliary lemma.

If E\mathcal{E} holds, for each h∈[H]h\in[H], each (sh,ah)(s_{h},a_{h}) and each q∈Cht(sh,ah)q\in\mathcal{C}_{h}^{t}(s_{h},a_{h}),

where we have used Pinsker’s inequality to bound the L1L^{1}-norm using the KL divergence, combined with the fact that both qq and pp are close to the empirical transition probabilities p^t\hat{p}^{t} under E\mathcal{E}. ∎

As a consequence, we can express the upper bound UtU^{t} in terms of the true transition probabilities pp.

If E\mathcal{E} holds, for each h∈[H]h\in[H] and each (sh,ah)(s_{h},a_{h}),

We can also express the lower bound LtL^{t} in terms of the transition probabilities pp and policy πt+1\pi^{t+1}.

If E\mathcal{E} holds, for each h∈[H]h\in[H] and each (sh,ah)(s_{h},a_{h}),

We exploit the fact that for each h∈[H]h\in[H], each (sh,ah)(s_{h},a_{h}) and each q∈Cht(sh,ah)q\in\mathcal{C}_{h}^{t}(s_{h},a_{h}),

The proof is analogous to the proof of Lemma 6. We can now write

If E\mathcal{E} holds, for all h∈[H]h\in[H], sh∈Sh(πt+1)s_{h}\in\mathcal{S}_{h}(\pi^{t+1}) and aha_{h},

The bound on the diameter follows directly from Corollary 4 and Lemma 7:

where we used Er⊇E\mathcal{E}^{r}\supseteq\mathcal{E} and Pinsker’s inequality to bound

To obtain the final expression in Lemma 8, we observe that it also trivially holds that

The conclusion follows by observing that one can get rid of the maximum with 1 in the denominator by using instead the convention 1/0=+∞1/0=+\infty. ∎

D.3 Relating counts to pseudo-counts

D.4 Detailed proof of Theorem 1

Using Lemma 5 and the fact that pht+1(sh,ah)=0p^{t+1}_{h}(s_{h},a_{h})=0 if ah≠πt+1(sh)a_{h}\neq\pi^{t+1}(s_{h}) yields

By induction, one then obtains the following upper bound:

Summing for t∈{0,…,τ−1}t\in\{0,\dots,\tau-1\} the inequalities given by (10) yields

The rest of the proof consists in upper bounding Bhτ(sh,ah)B_{h}^{\tau}(s_{h},a_{h}) in terms of the pseudo counts n‾hτ(sh,ah)\overline{n}_{h}^{\tau}(s_{h},a_{h}).

Step 4: from counts to pseudo-counts

Using Lemma 9 to relate the counts to the conditional pseudo-counts, one can write

Since γ≤1\gamma\leq 1 and x>1x>1, we can write

where r=1/x<1r=1/x<1. The latter is an arithmetico-geometric sum that can be upper bounded as

Appendix E Proof of Theorem 2

The proof of Theorem 2 uses the same ingredients as the proof of Theorem 1: Lemma 5 which relates the gaps to the diameters of the confidence intervals Dht(sh,ah)=Uht(sh,ah)−Lht(sh,ah)D_{h}^{t}(s_{h},a_{h})=U_{h}^{t}(s_{h},a_{h})-L_{h}^{t}(s_{h},a_{h}) and a counterpart of Lemma 8 for the deterministic case, stated below.

If E\mathcal{E} holds, and t1:H=(s1,a1,…,sH,aH)t_{1:H}=(s_{1},a_{1},\dots,s_{H},a_{H}) is the (t+1)(t+1)-st trajectory generated by MDP-GapE, for all h∈[H]h\in[H],

It follows from Lemma 11 that for all h∈[H]h\in[H], along the (t+1)(t+1)-st trajectory t1:H=(s1,a1,…,sH,aH)t_{1:H}=(s_{1},a_{1},\dots,s_{H},a_{H}),

Using Lemma 5, if t<τt<\tau, if t1:Ht_{1:H} is the trajectory selected at time (t+1)(t+1), either nt(t1:H)=0n^{t}(t_{1:H})=0 or

It follows that for any trajectory t1:Ht_{1:H},

The conclusion follows from Lemma 12 and from the fact that τ=∑t1:H∈Tnτ(t1:H)\tau=\sum_{t_{1:H}\in\mathcal{T}}n^{\tau}(t_{1:H}).

Appendix F Sample complexity of Sparse Sampling in the Fixed-Confidence Setting

For simplicity, and without loss of generality, assume that the reward function is known. Let C>0C>0. Sparse Sampling builds, recursively, the estimates V^h\widehat{V}_{h} and Q^h\widehat{Q}_{h} for h∈[H+1]h\in[H+1], starting from V^H+1(s)=0\widehat{V}_{H+1}(s)=0 and Q^H+1(s,a)=0\widehat{Q}_{H+1}(s,a)=0 for all (s,a)(s,a). Then, from a target state-action pair (s,a)(s,a), it samples CC transitions Zi∼ph(⋅∣s,a)Z_{i}\sim p_{h}(\cdot|s,a) for i∈[C]i\in[C] and computes:

For an initial state ss, its output is Q^1(s,a)\widehat{Q}_{1}(s,a) for all a∈[K]a\in[K]. For any state ss, consider the events

defined for h∈[H+1]h\in[H+1], where εh:=(H−h+1)H(2/C)log⁡(2/δ′)\varepsilon_{h}:=(H-h+1)H\sqrt{(2/C)\log(2/\delta^{\prime})} for some δ′>0\delta^{\prime}>0.

with probability at least 1−δ1-\delta, where δ=2Kδ′((BK)H−1)/(BK−1)\delta=2K\delta^{\prime}\left((BK)^{H}-1\right)/(BK-1). Finally, we let ε:=H2(2/C)log⁡(2/δ′)/2\varepsilon:=H^{2}\sqrt{(2/C)\log(2/\delta^{\prime})}/2 and solve for CC, obtaining

Thus predicting a^=argmax aQ^1(s1,a)\hat{a}=\underset{a}{\text{argmax }}\widehat{Q}_{1}(s_{1},a) after O(C(BK)H)\mathcal{O}\left(C(BK)^{H}\right) sampled transitions we have

Appendix G A Technical Lemma

We state and prove below a technical result that permits to obtain an upper bound on nn from a condition of the form nΔ2≤β(n,δ)n\Delta^{2}\leq\beta(n,\delta), like the one which appears in Theorem 1.

Let n≥1n\geq 1 and a,b,c,d>0a,b,c,d>0. If nΔ2≤a+blog⁡(c+dn)n\Delta^{2}\leq a+b\log(c+dn) then

Since log⁡(x)≤x\log(x)\leq\sqrt{x} and x+y≤x+y\sqrt{x+y}\leq\sqrt{x}+\sqrt{y} for all x,y>0x,y>0, we have