Robust Anytime Learning of Markov Decision Processes
Abstract
Markov decision processes (MDPs) are formal models commonly used in sequential decision-making.
MDPs capture the stochasticity that may arise, for instance, from imprecise actuators via probabilities in the transition function.
However, in data-driven applications, deriving precise probabilities from (limited) data introduces statistical errors that may lead to unexpected or undesirable outcomes.
Uncertain MDPs (uMDPs) do not require precise probabilities but instead use so-called uncertainty sets in the transitions, accounting for such limited data.
Tools from the formal verification community efficiently compute robust policies that provably adhere to formal specifications, like safety constraints, under the worst-case instance in the uncertainty set.
We continuously learn the transition probabilities of an MDP in a robust anytime-learning approach that combines a dedicated Bayesian inference scheme with the computation of robust policies.
In particular, our method (1) approximates probabilities as intervals, (2) adapts to new data that may be inconsistent with an intermediate model, and (3) may be stopped at any time to compute a robust policy on the uMDP that faithfully captures the data so far. Furthermore, our method is capable of adapting to changes in the environment.
We show the effectiveness of our approach and compare it to robust policies computed on uMDPs learned by the UCRL2 reinforcement learning algorithm in an experimental evaluation on several benchmarks.
Introduction
Sequential decision-making in realistic scenarios is inherently subject to uncertainty, commonly captured via probabilities.
Markov decision processes (MDPs) are the standard model to reason about such decision-making problems [Puterman, 1994, Bertsekas, 2005].
Safety-critical scenarios require assessments of correctness which can, for instance, be described by temporal logic [Pnueli, 1977] or expected reward specifications.
A fundamental requirement for providing such correctness guarantees on MDPs is that probabilities are precisely given.
Methods such as variants of modelbased reinforcement learning [Moerland et al., 2020] or PAC-learning [Strehl et al., 2009] can learn MDPs by deriving point estimates of probabilities from data to satisfy this requirement.
This derivation naturally carries the risk of statistical errors.
Optimal policies are highly sensitive to small perturbations in transition probabilities, leading to sub-optimal outcomes such as a deterioration in performance [Mannor et al., 2007, Goyal and Grand-Clement, 2020].
Uncertain MDPs (uMDPs; also known as interval or robust MDPs) extend MDPs to incorporate such statistical errors by introducing an additional layer of uncertainty via uncertainty sets on the transition function [Nilim and Ghaoui, 2005, Wiesemann et al., 2013, Goyal and Grand-Clement, 2020, Rigter et al., 2021].
The solution of a uMDP is a robust policy that allows an adversarial selection (i.e., the worst-case scenario) of probabilities within the uncertainty set, and induces a worst-case performance (a conservative bound on, e.g., the reachability probability or expected reward).
The problem of computing such robust policies, also called robust verification , is solved using value iteration or convex optimization, where the uncertainty sets are convex [Wolff et al., 2012, Puggelli et al., 2013].
Our approach.
We study the problem of learning an MDP from data.
We propose an iterative learning method which uses uMDPs as intermediate models and is able to adapt to new data which may be inconsistent with prior assumptions.
Furthermore, the method is task-aware in the sense that the learning procedure respects temporal logic specifications.
In particular, our method learns intervals of probabilities for individual transitions.
This Bayesian anytime-learning approach employs intervals with linearly updating conjugate priors [Walter and Augustin, 2009], and can iteratively improve upon a uMDP that approximates the true MDP we wish to learn.
This method not only decreases the size of each interval, but may also increase it again in case of a so-called prior-data conflict where new data suggests the actual probability lies outside the current interval.
Consequently, a newly learned interval does not need to be a subset of its prior interval.
This property makes our method especially suitable to learn MDPs where the transition probabilities change.
Alternatively, we also include probably approximately correct (PAC) intervals via Hoeffding’s inequality [Hoeffding, 1963], which introduces a correctness guarantee for each transition.
We summarize the key features of our learning method, and what sets it apart from other methods.
• An anytime approach.
The ability to iteratively update intervals that are not necessarily subsets of each other allows us to design an anytime-learning approach .
At any time, we may stop the learning and compute a robust policy for the uMDP that the process has yielded thus far, together with the worst-case performance of this policy against a given specification.
This performance may not be satisfactory, e.g., the worst-case probability to reach a set of critical states may be below a certain threshold.
We continue learning towards a new uMDP that more faithfully captures the true MDP due to the inclusion of further data.
Thereby, we ensure that the robust policy gradually gets closer to the optimal policy for the true MDP.
• Specification-driven.
Our method features the possibility to learn in a task-aware fashion, that is, to learn transitions that matter for a given specification.
In particular, for reachability or expected reward (temporal logic) specifications which require a certain set of target states to be reached, we only learn and update transitions along paths towards these states.
Transitions outside those paths do not affect the satisfaction of the specification. • Adaptive to changing environment dynamics.
When using linearly updating intervals, our approach is adaptive to changing environment dynamics. That is, if during the learning process the probability distributions of the underlying MDP change, our method can easily adapt and learns these new distributions.
Related Work
Uncertain MDPs have (often implicitly) been used by reinforcement learning (RL) algorithms, for instance, to optimize the exploration/exploitation trade-off by guiding the RL agent towards unexplored parts of the environment, following the optimism in the face of uncertainty principle [Jaksch et al., 2010, Fruit et al., 2017].
We use the same principle in the exploration phase of our procedure, but compute robust policies as output to account for the uncertainty in an adversarial (or pessimistic) way.
Similarly, uncertain MDPs are used to compute robust policies when the data available is limited [Nilim and Ghaoui, 2005, Wiesemann et al., 2013, Russel and Petrik, 2019].
Such robustness is connected to a pessimistic principle that has been effective in offline RL settings [Lange et al., 2012], where the agent only has access to a fixed dataset of past trajectories, meaning it needs to base decisions on limited data [Rashidinejad et al., 2021, Buckman et al., 2021, Jin et al., 2021].
Likewise, our method may be stopped early and return a policy before the problem is fully explored.
Robust RL concerns the standard RL problem, but explicitly accounts for input disturbances and model errors [Morimoto and Doya, 2005].
Often there is a focus on ensuring that a reasonable performance is achieved during data collection.
To that end, Lim et al.
[2013] and Derman et al. [2019] sample trajectories using a robust policy, which can slow down the process to find an optimal policy.
We assume sampling access to the underlying MDP, which allows us to use more efficient exploration.
It should be noted that we only use uMDPs as an intermediate model towards learning a standard MDP, whereas in robust RL the model itself may also be an (adversarial) uncertain MDP.
As a result, our method converges to an MDP, while robust RL attempts to learn and possibly converge to an uncertain MDP.
Learning MDPs from data is also related to model learning , which typically assumes no knowledge about the states and thus iteratively increases the set of states [Vaandrager, 2017].
In [Tappler et al., 2019, 2021] the L ∗ algorithm for learning finite automata is adapted for MDPs.
These methods only yield point estimates of probabilities, and make strong assumptions on the structure of the MDP that is being learned.
Ashok et al.
[2019] use PAC-learning to estimate the transition functions of MDPs and stochastic games in order to perform statistical model checking with a PAC guarantee on the resulting value.
In [Bacci et al., 2021] the Baum-Welch algorithm for learning hidden Markov models is adapted to learn MDPs.
Finally, the literature distinguishes two types of uncertainty: aleatoric and epistemic uncertainty [Hüllermeier and Waegeman, 2021].
Aleatoric uncertainty refers to the uncertainty generated by a probability distribution, like the transition function of an MDP, and is also known as irreducible uncertainty .
In contrast, epistemic uncertainty is reducible by collecting and accounting for (new) data.
Our work can be seen as adding an additional layer of epistemic uncertainty on the probability distributions of the transition function that is then, by gathering and including more data, reduced.
Preliminaries
A discrete probability distribution over a finite set X is a function µ : X → [0 , 1] ⊂ R with (cid:80) x ∈ X µ ( x ) = 1 .
We write D ( X ) for the set of all discrete probability distributions over X , and by | X | we denote the number of elements in X .
For any closed interval I ⊆
R we write I and I for the lower and upper bounds of the interval, that is, I =
[ I, I ] .
Definition 1 (Markov decision process) .
A Markov decision process (MDP) is a tuple ( S, s I , A, P, R ) with S a finite set of states,
s I ∈ S the initial state, A a finite set of actions, P : S × A × S → [0 , 1] with ∀ s, a ∈ S × A, (cid:80) s ′ P ( s, a, s ′ )
= 1 (such that P ( s, a ) ∈ D ( S ) )
the probabilistic transition function, and R : S ×
A → R ≥
the reward (or cost) function.
A trajectory in an MDP is a finite sequence ( s 0 , a 0 , s 1 , a 1 , . . .
, s n ) ∈ ( S × A ) ∗ × S where s
= s I and P ( s i , a i , s i +1 ) > 0 for 0 ≤ i < n .
A memoryless policy is a function π : S → D ( A ) . If π maps to Dirac distributions, then it is a memoryless deterministic (or pure) policy.
Applying a policy to an MDP M resolves all the non-deterministic choices and yields an (induced) discrete-time Markov chain (DTMC); see, e.g., Puterman [1994] for details.
Definition 2 (Uncertain MDP) .
An uncertain MDP (uMDP) is a tuple ( S, s I , A, I , P , R )
where
S, s I , A, R are as for MDPs, I is a set of probability intervals
I = { [ a, b ] | 0 < a ≤ b ≤ 1 } , and
P : S ×
A × S → ( I ∪{ 0 } ) is the uncertain transition function , assigning either a probability interval, or the exact probability 0 to any transition.
Uncertain MDPs can be seen as an uncountable set of MDPs that only differ in their transition functions.
For a transition function P , we write P ∈ P if for every transition the probability of P lies within the interval of
P , i.e., P ( s, a, s ′ )
∈ P ( s, a, s ′ ) for all ( s, a, s ′ )
∈ S ×
A × S .
We only allow intervals with a lower bound greater than zero, to ensure a transition cannot vanish under certain distributions generated by the uncertainty.
This assumption is standard in uMDPs [Wiesemann et al., 2013, Puggelli et al., 2013]. Applying a policy to a uMDP yields an induced interval Markov chain [Jonsson and Larsen, 1991].
Specifications.
We consider reachability or expected reward (cost) specifications.
The value
P Mπ ( ♢ T ) is the probability to reach a set of target states T ⊆ S in the MDP M under the policy π , also referred to as the performance of π . {+
+}
Likewise, R Mπ ( ♢ T ) describes the expected accumulated reward to reach T under π .
Note that for probabilistic specifications, we can replace the formula ♢ T by more general reach-avoid specifications using the until operator from temporal logic.
Formally, the specification P Max ( ♢ T ) = max π P π ( ♢ T ) expresses that the probability of eventually reaching the target set T ⊆ S should be maximized.
Likewise, the specification R Max ( ♢ T ) requires the expected reward for reaching T to be maximized.
For minimization, we write P Min ( ♢ T ) and R Min ( ♢ T ) , respectively.
Besides optimizing a probability or reward, a specification may also express an explicit user-provided threshold to compare the performance of a policy to.
For uMDPs, we define optimistic and pessimistic specifications.
In optimistic specifications, we assume the best-case scenario of the uncertainty to satisfy the specification by also minimizing (or maximizing) over the uncertainty set, written as P MinMin ( ♢ T ) =
min π min P ∈P P M [ P ] π ( ♢ T ) (or
P MaxMax ( ♢ T ) ), where the first Min (Max) signals what the decision-maker is trying to achieve, and the second what the uncertainty does.
In pessimistic specifications, the uncertainty does the opposite of the goal: P MaxMin ( ♢ T ) or P MinMax ( ♢ T ) .
The notation is similar for reward specifications.
A (standard) specification φ can be extended to be optimistic or pessimistic by adding a second Min or
Max.
We write φ O for its optimistic extension, and φ P for its pessimistic extension.
For an MDP M , the aim is to compute a policy π that either optimizes a given specification φ , or whose performance respects a given threshold that, e.g., provides an upper bound on the probability of reaching a set of critical states.
Common methods are value iteration or linear programming [Puterman, 1994, Baier and Katoen, 2008].
For uncertain MDPs M , the goal is to compute a policy π that satisfies an optimistic or pessimistic specification φ O or φ P .
In the latter case, we call π a robust policy .
Optimal policies in uMDPs can be computed via robust dynamic programming or convex optimization [Wolff et al., 2012, Puggelli et al., 2013].
Problem Statement and Outline of the Procedure
We have an unknown but fixed MDP M =
( S, s I , A, P, R ) , which we will refer to as the true MDP , an initial prior uMDP M = ( S, s I , A, I , P , R ) , and a specification φ which we want to satisfy.
A discussion of prior (and other parameter) choices follows in Section 6.
[Figure]
✗ ✓
Assumption 1 (Underlying graph) .
We assume that the underlying graph of the true MDP is known.
In particular: transitions that do not exist in the true MDP (transitions of probability 0 ) do also not exist in the uMDP, transitions of probability 1 in the true MDP are assigned the point interval [1 , 1] in the uMDP, and any other transition of non-zero probability p has an interval I ∈ I in the uMDP.
Under Assumption 1 and Definition 2, we construct the initial prior uMDP M to have transitions of probability 0 and 1 exactly where the true MDP M has these too, and interval transitions [ ε, 1 − ε ] for all other transitions, with ε > 0 free to choose.
In particular, our approach does not require ε to be smaller than the smallest probability p > 0 occurring in M , which we also do not assume to be known.
Alternatively, in case further knowledge is available, one may use any other prior uMDP as long as it satisfies Assumption 1.
Our learning problem is expressed as follows: The
problem is to learn the transition probabilities of a true MDP M , driven by a specification φ , via intermediate uncertain MDPs M that are iteratively updated to account for newly collected data, such that at any time a robust policy can be computed.
In the following we outline our anytime-learning procedure as illustrated in Figure 1.
Input.
We start with an initial prior uMDP M and a specification φ we wish to verify.
We assume (black box) access to the unknown true MDP M to sample trajectories from, or alternatively, assume a (constant) stream of observations from the true MDP. ssssaa0 .0 .   (a) The true MDP.
ssssaa? ? ? ?   (b) Assumption 1. ssssaa[ ε, 1 − ε ] [ ε , 1 − ε ] [ ε , 1 − ε ] [ ε, 1 − ε ]   (c) Initial prior. ssssaa[0 . 6 , 0 . 8] [. 2 5 , 0 .
(d) Intermediate uMDP. ssssaa[0 . 96]   (e) Converging to- wards the true MDP. Robust policy computation.
We compute a robust policy π for the pessimistic extension of φ , i.e. φ P , in the uncertain MDP M , together with the worst-case performance of the specification in the current uMDP.
If the specification contains an explicit threshold, the value can be compared against the threshold for automatic termination.
In case of specifications that optimize a probability or reward, termination needs to be done manually, as it is impossible to tell if the maximum (minimum) was achieved.
Anytime learning.
If the result from step 2 is unsatisfactory, we start learning:
(a) Exploration.
We sample
one
or more trajectories
from
the true MDP M , using the optimism in the face of uncertainty principle.
(b) Update.
We update the intervals of the uMDP M in accordance with the
newly
collected data.
This update yields a new uMDP that more faithfully captures all collected data up to this point than the previous uMDP.
(c) Repeat.
We start again at step 2 with this new uMDP until (manual) termination.
Output.
The process may be stopped at any moment and yields the latest uMDP M together with robust policy π and the performance of π on M .
The effects of this procedure are illustrated in Figure 2.
In 2a, we see an example MDP M to learn, and 2b shows the assumed knowledge about M .
2c shows the initial uMDP M constructed from 2b, using a (symbolic or explicit) lower bound ε > 0 to ensure that all lower bounds of M are strictly greater than zero.
In 2d, we see an intermediate learned uMDP.
Some intervals may already have successfully converged towards the probability of that transition in the true MDP, while others may be very inaccurate due to a low sample size and thus a bad estimate.
Finally, 2e depicts the learned uMDP converging towards the true MDP.
Bayesian Learning
We assume access to trajectories through the true MDP.
Due to the Markov property of the MDP, i.e., the fact that the transition probabilities only depend on the current state and not on any further history, we may split each trajectory τ into separate sets of independent experiments where a state-action pair ( s, a ) is sampled and a successor state s i is observed; see also Appendix A of [Strehl and Littman, 2008].
We count the number of occurrences of the transition ( s, a, s i ) in each trajectory τ , and the number of occurrences of the state-action pair ( s, a ) in each trajectory τ , denoted by #( s, a, s i ) and #( s, a ) , respectively.
In the following, we introduce the two approaches of learning intervals: the standard approach of PAC learning via Hoeffding’s inequality which provides a PAC guarantee on the value of the learned model, and a new approach using linearly updating intervals (LUI), which is more flexible due to the inclusion of prior-data conflicts and its closure properties. Finally, we introduce a minor modification to the LUI approach, making it also applicable to situations where the underlying MDP changes over time. Such a modification is not possible in PAC learning as
Hoeffding’s inequality assumes independent samples from a fixed distribution.
5.1 Learning PAC Intervals
We use the standard method of maximum a-posteriori probability (MAP) estimation to infer point estimates of probabilities; see Appendix A for details.
These point estimates can then easily be turned into probably approximately correct (PAC) intervals via Hoeffding’s inequality.
Given N =
#( s, a ) samples and a fixed error rate γ , we use Hoeffding’s inequality [Hoeffding, 1963] to compute the interval size δ = (cid:112) log( 2 / γ ) / 2 N .
This δ may then be used to construct intervals that are PAC with respect to the true transition probability.
To lift the PAC guarantee to the entire learned MDP, and consequently also the optimal value for some specification, we need to distribute δ over all transitions, i.e., δ P = δ / (cid:80) ( s,a ) ∈ S
× A | Succ ( s,a ) | , where Succ ( s, a ) is the set of successor states of ( s, a ) .
Using this δ P , we then construct the intervals
[Equation]
where ˜ P is the (MAP) point estimate, and ε is again a small value to ensure that the interval lower bounds are non-zero.
As a result, we have the following Proposition, whose proof is a direct application of Hoeffding’s inequality.
Proposition 1.
The true MDP M ∗ lies within the learned uMDP M with probability greater or equal to 1 − γ . This is a standard result and also used in, e.g., PAC statistical model checking [Ashok et al., 2019].
5.2 Learning Linearly Updating Probability Intervals
We use the Bayesian approach of intervals with linearly updating conjugate priors [Walter and
Augustin, 2009] to learn intervals of probabilities.
Each uncertain transition P ( s, a, s i ) is assigned a prior interval P i =
[ P i , P i ] , and a prior strength interval [ n i , n i ] that represents a minimum and maximum number of samples on which the prior interval is based.
The greater the values of the strength interval, the more emphasis is placed on the prior, and the more data is needed to significantly change the prior when computing the posterior.
The greater the difference between the n i and n i , the greater the difference between a prior-data conflict and a prior-data agreement .
Definition 3 (Posterior interval computation) .
The interval [ P i , P i ] can be updated to [ P ′ i , P ′ i ] , using N = #( s, a ) and k i
=
#( s, a, s i ) , as follows:
[Equation]
The strength interval is updated by adding the number of samples N to it: [ n ′ i , n ′ i ] =
[ n i + N, n i + N ] .
The initial values for the priors of each state-action pair can be chosen freely subject to the constraints 0 < P i ≤ P i ≤ 1 , and n i ≥ n i ≥ 1 .
Key properties of linearly updating probability intervals.
• Convergence in the infinite run.
Under the assumption that the true MDP does not change, each interval will converge to the exact transition probability when the total number of samples processed tends to infinity, regardless of how many samples are processed per iteration [Walter and Augustin, 2009].
This assumption is, however, not required for our work.
If the true MDP changes over time, or is adversarial (i e., a uMDP), our method is still applicable, but will not converge to a fixed MDP.
• Prior-data conflict.
When the estimated probability k i / N lies outside the current interval, a so-called prior data conflict occurs.
Consequently, if at some point we derive an interval that does not contain the true transition probability, the method will correct itself later on.
• Closure properties under updating.
Finally, updating is closed in two specific ways.
First, any interval of probabilities is updated again to a valid interval of probabilities, and second, any set of intervals at a state-action pair that contains a valid distribution over the successor states will again
contain a
distribution over successor states after updating.
A key requirement for computing robust policies on uMDPs is that the lower bound of every interval is strictly greater than zero (see Definition 2).
This closure property is formalized as follows.
Theorem 1 (Closure of intervals under learning) .
For any valid prior interval [ P , P ] with 0 < P ≤
P ≤ 1 , we have that the posterior [ P ′ , P ′ ] computed via Definition 3 also satisfies 0 < P ′ ≤ P ′ ≤ 1 .
Furthermore, we also have closure properties at each state-action pair. In particular, if we choose our prior intervals such that there is at least one valid probability distribution at the state-action pair, then the posterior intervals will again contain a valid probability distribution.
We formalize this notion by examining the sum of the lower and upper bounds of the intervals in the following Theorem: Theorem 2 (Closure of distributions under learning) . We have the following bounds on the set of posterior distributions. In case of a prior data agreement, we have that the sum of the posterior bounds is bounded by the sum of the prior bounds, and the value 1 .
That is, [Equation] In case of a prior-data conflict, the sum of posterior bounds is no longer necessarily bounded by the prior, and we only have
[Equation]
Note, however, that this last constraint (5) is already sufficient to ensure that there is a valid probability distribution at the state-action pair.
The proofs for both Theorem 1 and 2 can be found in Appendix B.
5.3 Efficient exploration
Above, we assumed that a set of trajectories was given.
To actually obtain the trajectories, we use the well-established optimism in the face of uncertainty principle
[Munos, 2014]. We compute the optimal policy for the optimistic extension (see Section 3) of the specification φ , i.e. φ O , in the current uMDP and use this policy for exploration.
To make exploration specification-driven, we only sample transitions along trajectories towards the target state(s) of the specification.
When the last seen state has probability zero or one to reach the target for reachability, or reward zero or infinity, we restart.
States satisfying these conditions can be found by analyzing the graph of the true MDP [Baier and Katoen, 2008].
Trajectories and iterations.
As explained in Section 4, our method is iterative in terms of updating the uMDP M and computing a robust policy.
After updating the uMDP, we also compute a new exploration policy, based on the new uMDP.
Each iteration consists of processing at least one, but possibly more trajectories.
To determine how many trajectories to collect, we use a doubling-counting scheme, where we keep track of how often every state-action pair and transition is visited during exploration
[Jin et al., 2020].
An iteration is completed when any of the counters is doubled with respect to the previous iteration.
A detailed description of this schedule is given in Appendix C.
5.4 Learning under changing environments
Previously, we assumed a fixed unknown true MDP M ∗ to learn. But what if the transition probabilities of M ∗ suddenly change? More precisely, we assume two unknown true MDPs, M ∗ 1 and M ∗ 2 with the same underlying graph but (possibly) different transition probabilities.
After an unknown number of interactions with the true environment M ∗ 1 , we suddenly continue interacting with M ∗ 2 .
We modify our LUI approach by introducing a bound on the strength of the prior, n Max =
[ n Max , n Max ] , and update the strength intervals by the following rule
[Equation]
The probability intervals themselves are updated in the same way as before in Definition 3.
By limiting the prior strength in this way, we trade some rate of convergence for adaptability.
The weaker the prior, the greater the effect of a prior-data conflict, and hence adaptability to new data.
When suddenly changing environments, new data will likely lead to prior-data conflicts, and thus a higher adaptability of the overall learning method.
We add randomization to the pure optimistic exploration policy.
We introduce a hyperparameter ξ ∈ [0 , 1] , and follow with probability ξ the action of the optimistic policy, and distribute the remaining 1 − ξ uniformly over the other actions, yielding a memoryless randomized policy.
We implement our approach, with both linearly updating intervals (LUI) and PAC intervals (PAC), in Java on top of the verification tool PRISM [Kwiatkowska et al., 2011], together with a variant of value iteration to compute robust policies for uMDPs with convex uncertainties [Wolff et al., 2012].
3 We compare our method to point estimates derived via MAP-estimation (MAP) and with uMDPs learned by the UCRL2 reinforcement learning algorithm
[Jaksch et al., 2010] (UCRL2).
We modify UCRL to make it more comparable to our setting.
In particular, we use optimistic policies for exploration, but robust policies to compute the performance, in contrast to the standard UCRL2 setting which only uses optimistic policies, see Appendix E for further details.
Without knowledge about the true MDP apart from Assumption 1, we have to define an appropriate prior interval for every transition.
We set ε = 1e-4 as constant and define the prior uMDP with intervals P i =
[ ε, 1 − ε ] and strength intervals [ n i , n i ] =
[5 , 10] at every transition P ( s, a, s i ) , as in Figure 2c.
For MAP, we use a prior of α i = 10 for all i .
The same prior is used for the point estimates of both PAC and UCRL2, together with an error rate of γ = 0 .
Evaluation metrics.
We consider two metrics to evaluate the four learning methods.
• Performance.
How does the robust policy computed on the learned model perform on the true MDP?
We evaluate the probability of satisfying the given specification P Mπ ( ♢ T ) or expected reward R Mπ ( ♢ T ) of the robust policy π computed after each update of the model. • Performance estimation error.
How well do we expect a robust policy to perform on the true MDP based on the performance on the intermediate learned uMDP?
We compute the difference between the performance of the robust policy on the learned uMDP (the worst-case performance) and the performance on the true MDP.
While values closer to zero are preferable, we do not accept methods with positive estimation errors, since this indicates their estimated performance is not a lower (conservative) bound on the actual performance of the policy.
In particular, an estimation error above zero shows the policy is misleading in terms of predicting its performance
We benchmark our method using several well-known environments: the Chain Problem [Araya-López et al., 2011], Aircraft Collision Avoidance [Kochenderfer, 2015], a slippery Grid World [Derman et al., 2019], a 99-armed Bandit [Lattimore and Szepesvári, 2020], and two version of a Betting
Game [Bäuerle and Ott, 2011].
For details on all these environments we refer to Appendix D. We highlight the Betting Game and Chain Problem environments here, as they will be used to explain some of the key observations we make from our experimental results.
• Betting Game.
The agent starts with 10 coins and attempts to maximize the number of coins after 6 bets.
When a bet is won, the number of coins placed is doubled; when lost, the number of coins placed is removed.
The agent may bet 0 , 1 , 2 , 5 , or 10 coins.
We consider two versions of the game, one which is favourable to the player, with a win probability of 0 . 8 , and one that is unfavourable with win probability 0 .
After 6 bets the player receives a reward equal to the number of coins left.
The specification is to maximize the reward.
• Chain Problem.
We consider a chain of 30 states.
There are three actions, one progresses with probability 0 .
95 to the next state, and resets the model to the initial state with probability 0 .
The second action does the same, but with reversed probabilities.
The third action has probability 0 .
5 for both cases.
Every action gets a reward of 1 .
As specification, we minimize the reward to reach the last state of the chain.
Results
We present an excerpt of our experimental results here, and refer the reader to Appendix F for the full set of results, which in particular also includes the estimation error for all environments, an additional model error metric, and further experiments regarding different priors and changing environments.
All experiments were performed on a machine with a 4GHz Intel Core i9 CPU, using a single core.
Each experiment is repeated 100 times, and reported with a 95% confidence interval.
LUI MAP
[Figure] PAC [Figure] [Figure]
10101010101010 6 Trajectory − 0 .− 0 .− 0 .− 0 .0 .0 . E s ti m a ti on E rr o r
Bandit Figure 3 shows the performance of the robust policies computed via each learning method against the number of trajectories processed on the different environments. We first note that in all environments, our LUI method is the first to find an optimal policy. Depending on the environment, the performance of LUI and PAC may be roughly equivalent (Chain, Grid).
When also taking the estimation error into account (Figure 4), we see LUI outperforming other methods on that metric.
UCRL2 is the slowest to converge to an optimal policy.
This due to UCRL2 being a reinforcement learning algorithm, and thus it is slower in reducing the intervals in favour of a broader exploration.
Recovering from bad estimates.
On the Chain environment, we see LUI and PAC (around trajectory 5 ), and UCRL2 (around trajectory 10 3 ) choose the wrong action(s), with an decrease in performance as a result.
This is most likely due to getting a bad estimate on some of the transitions later on in the chain, leading to many resets to the initial state, and thus decreasing the performance significantly.
While all three methods manage to recover and then find the optimal policy, UCRL takes significantly longer: only after trajectory 10 5 , where LUI and PAC only need abouttrajectories.
MAP-estimation typically sits between LUI and PAC in terms of performance.
It is less sensitive to mistakes like the one discussed above, but is less reliable in providing a conservative bound on its performance, as will be discussed below.
Furthermore, we see that in the unfavourable Betting Game, only MAP-estimation gives sub-optimal performance, due to bad estimates.
It is able to recover from this, but needs almost 10 4 trajectories to do so.
Due to the low win probability in this Betting Game, a robust policy on the uMDPs is by default an optimal policy for the true MDP, and we see that LUI, PAC, and UCRL2 do not change to a sub-optimal policy.
Robust policies are conservative.
Consider Figure 4.
We note the undesirable behaviour of having an Estimation Error above zero, which means the performance of the policy on the learned model [Figure] was higher than the performance of that policy on the true MDP.
MAP-estimation is particularly susceptible to this, while all three uMDP methods yield policies that are conservative in general, though some exceptions exist as shown in the full results in Appendix F.
LUI is adaptive to changing environments.
Finally, we investigate the behaviour of the learning methods when after a fixed number of trajectories the probabilities of the true MDP change, as introduced in Section 5.4.
Figure 5 shows the performance of the robust policy for each learning method on the Chain environment, results for the same experiment on the Betting Game can be found in Appendix F. After † ∈ { 10 2 , . .
10 5 } trajectories, we change the environment by swapping the transition probabilities, for three different bounds on the strength intervals.
We similarly bound the
MAP-estimation priors for MAP and UCRL.
PAC is omitted from this experiment as PAC guarantees lose all meaning when changing the underlying distribution. After the change in environment, the new optimal policy has to use the opposite action from the previously optimal policy.
We see that
LUI is the only method capable of converging to optimal policies both before and after the change in environment. Furthermore, the lower the bounds on the prior strength, the faster it adapts to the change. We conclude that LUI is an effective approach to deal with learning an MDP under potential adversarial sampling conditions.
Conclusion and Future Work
We presented a new Bayesian method that learns uMDPs to approximate an MDP, either via linearly updating intervals, or PAC-intervals.
Robust policies computed on learned uMDPs are shown to be conservative and reliable in predicting their performance when applied on the MDP that is being learned.
The approach of linearly updating intervals is also effective at continuously learning a potentially changing environment.
For future work, we aim to extend our method to uncertain
POMDPs [Suilen et al., 2020, Cubuktepe et al., 2021].
While we do not see any immediate negative societal impacts of our work, we acknowledge that potential misuse of our work cannot be ruled out due to the generality of MDPs.
A MAP-estimation
We describe a general setup for learning point estimates of probabilities via maximum a-posteriori estimation (MAP-estimation).
For a fixed state-action pair ( s, a ) with m different successor states s 1 , . . .
, s m that is sampled N = #( s, a ) times, and where each successor state is observed
k i
=
#( s, a, s i ) times for i = 1 , . . .
, m , we have the multinomial likelihood
[Equation]
where the transition probabilities P ( s, a, s i ) are unknown and given by a Dirichlet distribution with parameters α 1 , . .
, α m [Bishop, 2007]:
[Equation]
The Dirichlet distribution is a conjugate prior to the multinomial likelihood, meaning that we do not need to compute the posterior distribution explicitly, but instead we just update the parameters of the prior Dirichlet distribution.
Formally, conjugacy is a closure property, see [Jacobs, 2020].
Given a prior Dirichlet distribution with parameters α 1 , . . .
, α m , and observing the i -th successor state k
i times, the posterior Dirichlet distribution is given by simply adding k i to parameter α i :
[Equation]
Having computed the posterior Dirichlet distribution, MAP-estimation can be used to infer the probabilities.
These estimates are given by the mode of each parameter of the posterior distribution:
[Equation]
When all parameters α i are equal, MAP-estimation yields uniform distributions.
B Proofs
The proof of Theorem 1 is straightforward and relies on the observation that for any amount of finite data, a single update can only grow closer to zero but not become zero, and that iterated updates converge to the true probability which is assumed to be non-zero.
Proof Theorem 1.
For any transition ( s, a, s i ) the following holds.
We assume a valid prior, that is, 0 < P i ≤ P i ≤ 1 . We have an empirical estimate of k i / N . Then we also have 0 < P ′ i ≤ P ′ i ≤ 1 , where the first inequality 0 <
P ′
i follows from the fact that Equation 2 can only be 0 when their nominator is zero, which is not possible when n i ≥ 1 (or n i ≥ 1 ) and P i > 0 . The second inequality, P ′ i ≤ P ′ i follows directly from Equations 2 and 3 together with P i ≤ P i .
The third inequality P ′ i ≤follows again from Equation 3 when P i < ≤ 1 and k i ≤ N .
All reasoning above is independent of prior-data agreement or conflict and thus applies to both cases in each of the equations.
The proof of Theorem 2 uses the following Lemma: Lemma 1. At a state-action pair with m successor states, there can be at most m − 1 prior-data conflicts on the upper (or lower) bound. Proof.
We prove the lemma for the upper bound, a proof for the lower bound follows by symmetry.
Assume a valid prior, that is, (cid:80) i P i ≥ 1 .
Suppose there is a prior-data conflict for every interval, i.e., ∀ i. k i N > P i . Then we also have [Equation]
which is clearly not possible.
The possibility for m − 1 prior-data conflicts is witnessed in the following example.
Take a state-action pair with two successor states, s 1 and s 2 .
Then m
= 2 .
Take one sample, i.e., N = 1 , and suppose we observe s 1 , such that k 1 = 1 and k 2 = 0 .
Then for any valid prior intervals I 1 = [ P 1 , P 1 ] and I 2 = [ P 2 , P 2 ] we have k 1 / N = 1 > P 1 and k 2 / N = 0 < P 2 . Hence, a prior-data conflict at I 1 but not at I 2 , thus m − 1 conflicts at the state-action pair in total.
We additionally have the following Lemma: Lemma 2. A prior-data conflict at the upper bound implies a prior-data agreement at the lower bound, and vice versa. Proof.
Assume a conflict at the upper bound P i .
Then k
i N > P
i ≥ P i , which is a prior-data agreement with
P i by definition.
The other way around follows by symmetry.
Now we prove Theorem 2.
Proof Theorem 2.
We start with the constraints in Equation 4. First, 1 ≤ (cid:80) i P ′ i . We use that there is a prior-data agreement, that is, ∀ i. k i N ≤ P i .
Then we derive (cid:88)
[Equation]
The bound (cid:80) i P ′ i ≤ (cid:80) i P i is derived using that
[Equation]
Then, it follows that
[Equation]
The proof for the bounds
[Equation]
is symmetrical to the one above.
Next, we consider the case for a prior-data conflict, that is, the bounds from Equation 5.
The existential condition ∃ j. k j N ≥ P j does not have to be unique, hence we make a case distinction on the indexes for which the existential quantification holds and for which it does not.
Let I = { 1 , . . .
, m } be the set of indices that enumerates the m successor states at the state-action pair we consider.
By
Lemma 1 we know that there are at most m − 1 prior-data conflicts.
Hence, we can partition I into two non-empty subsets, I A containing all indices where the point estimate agrees with the prior interval, and I C the set of indices where there is a prior-data conflict.
That is,
[Equation]
We use this partition to split the sum over all indices in two:
[Equation]
We now reason on each part separately.
For i ∈
I A
we have k i N ≤ P i , which also means N ≤
k i P i .
(cid:88) i ∈ I
A
[Equation]
Next, for i ∈
I C
we have k i N > P i , and thus also k i > P i N .
Then we have the following:
[Equation]
Finally, we put the two partitions back together using the inequalities derived on both, and conclude by using the assumption that the prior is valid, i.e., (cid:80) i P i ≥ 1 :
[Equation]
The proof for the lower bounds, that (cid:80) i P ′ i ≤ 1 , follows the same reasoning by symmetry.
C Exploration Scheme
We detail the exploration scheme in Algorithm 1 below. Algorithm 1 Exploration scheme.
A : # i ( s, a ) > =
#( s, a ) then 10: ▷ Compute new policies.
Give iteration counters
# i ( s, a ) and # i ( s, a, s ′ ) to A 12: Get sampling policy from A : π sampling 13: Get robust policy from A : π robust 14: Evaluate π robust on M according to φ 15: ▷ Update global counters 16:
#( s, a ) +
= # i
( s, a ) : ∀ s, a ∈ S ×
A 17: #( s, a, s ′ )
+= # i ( s, a, s ′ ) :
∀ s, a ∈ S ×
A × S 18: ▷ Reset iteration counters 19: # i ( s, a ) = 0 : ∀ s, a ∈ S
×
A 20: # i ( s, a, s ′ )
= 0 : ∀ s, a ∈ S ×
A × S 21: end if 22:
Sample τ from M following π sampling with max size H 23:
Increment # i ( s, a ) and # i ( s, a, s ′ )
according to τ .
24: end for
D Detailed Problem Domain Descriptions
We give a detailed description of each model we use in the experimental evaluation below, together with the specification and (if applicable) its source.
Chain problem.
We consider a larger version of the chain problem Araya-López et al.
[2011] with 30 -states.
There are three actions, one progresses with probability 0 .
95 to the next state, and resets the model to the initial state with probability 0 .
The second action does the same, but with reversed probabilities.
The third action has probability 0 .
5 for both progressing and resetting.
Every action gets a reward of 1 .
As specification, we minimize the reward to reach the last state of the chain:
R Min ( ♢ T ) .
This can be seen as an instance of the stochastic shortest path problem [Bertsekas, 2005].
Aircraft collision avoidance.
We model a small, simplified instance of the aircraft collision avoidance problem Kochenderfer [2015].
Two aircraft, one controlled, one adversarial, approach each other.
The controlled aircraft can increase, decrease, or stay at the current altitude with a success probability of 0 . 8 .
The adversarial aircraft can do the same, but does so with probabilities 0 .
4 respectively.
To goal is to maximize the probability of the two aircraft passing each other without a collision, expressed by the temporal logic specification P Max ( ¬ collision U passed ) .
Grid world.
We consider a slippery 10 × 10 grid world as in Derman et al.
[2019], where a robot starts in the north-west corner and has to navigate towards a target position.
The robot can move in each of the four cardinal directions with a success probability of 0 . 55 , and a probability of 0 .
15 to move in each of the other directions.
Throughout the grid, the robot has to avoid traps.
The model has 100 states and 1450 transitions.
We consider safety specifications that maximize the probability for reaching the north-east (NE) corner without getting trapped, i.e. P Max ( ¬ trapped U NE ) .
Bandit.
We consider a 99 -armed bandit Lattimore and Szepesvári [2020], where each arm (action) has an increased probability of success, 0 . 01 , 0 .
99 respectively.
The goal is to find the action that has the highest probability of success: P Max ( ♢ success ) .
Betting game.
We consider a betting game from [Bäuerle and Ott, 2011], in which an agent starts with 10 coins and attempts to maximize the number of coins after 6 bets.
When a bet is won, the amount of coins placed is doubled, when lost the amount of coins placed is removed.
The agent may place bets of 0 , 1 , 2 , 5 , and 10 coins.
We consider two versions of the game, one which is FAVOURABLE to the player, with a win probability of 0 . 8 , and one that is unFAVOURABLE to the player, with a win probability of 0 . 2 .
After six bets the player receives a state-based reward that equals the number of coins left.
This yields an MDP of 300 states and 1502 transitions.
The specification is to maximize the reward after for reaching a terminal state after these six bets.
E Comparison with UCRL2.
UCRL2 [Jaksch et al., 2010] is a reinforcement learning algorithm, meaning it is designed to collect reward while exploring, in contrast to our setting where we have a clear separation between exploration and policy computation (i.e. computing the reward).
We use UCRL2 to learn a uMDP, but then compute a robust policy on that learned model, instead of an optimistic policy as is standard for UCRL2.
Furthermore, we make the following changes to the UCRL2 algorithm to make it more comparable to our setting:
Just as with the PAC intervals, we use MAP-estimation instead of the frequentist approach to estimate the point estimates.
UCRL2 does not compute individual intervals, but a set of distributions around the distribution of point estimates.
In particular, it takes the set of distributions for which the ℓ 1 norm to the estimated distribution is less than or equal to
[Equation]
see [Jaksch et al., 2010] for details on this bound.
We use this bound for the individual intervals (bounded by ε to ensure lower bounds greater than zero).
As the robust value iteration for uMDPs restricts to valid distributions with the product of these intervals, we do not use the ℓ 1 norm but put in the intervals derived from MAP-estimation with this bound.
Finally, the UCRL2 algorithm assumes that the reward function is also unknown, and attempts to learn that as well.
We assume the reward function to be known in our setting.
F Complete Experimental Evaluation
In this Section we present the full experimental evaluation of our method.
For our main conclusions, we refer back to Section 6, and only comment here on additional experiments not found in the main text.
In Figure 7 we show the Performance, and Estimation Error for all six environments and all four learning methods. Additionally, we also define a model error :
For each transition, we compute the maximum distance between the true probability and the lower and upper bounds of the interval in the uMDP (or the point estimate for MAP-estimation), and then take the average over all these distances.
Figure 6 shows the performance of LUI on the Grid environment with different prior strength choices. We note little difference, and thus conclude that our LUI approach is not very sensitive to small changes in prior choices. Figures 8 and 9 shows the results for switching the probabilities on the Chain environment, for two different randomization parameters in the exploration: ξ = 0 . 8 and {+ξ = 1 . 
+}
(no randomization).
Figures 10 and 11 show the same experiment on the Betting Game, switching from a favourable game to an unfavourable one, again with randomization parameters ξ = 0 . 8 and ξ = 1 . 0 . We note the need for randomization during exploration, especially in the Chain environment. [Figure]
LUI
MAP
UCRL
PAC
[Figure]
Grid
[Figure]
[Figure]
[Figure]
[Figure]