Simple Algorithm
Reinforcement Learning · Bootstrapping · 22 min

Safe & Robust RL

Constraints, robustness, and keeping agents within bounds.

A reinforcement learning agent improves by trying things, and some things must never be tried: driving a robot down a staircase, overdosing a patient, tripping a power grid. "Make it safe" turns out to mean at least five different mathematical requirements. This lesson separates them and builds the standard tool for each: constrained MDPs with Lagrange multipliers, CVaR for bad tails, robust MDPs and domain randomization for wrong models, shields for exploration, and the study of objectives that say the wrong thing.

What you’ll learn

  • Classify a safety requirement as a constraint, a risk preference, robustness to model error, safe exploration or a specification problem, and name the formalism for each.
  • Write a constrained MDP, derive its Lagrangian relaxation and the primal–dual algorithm, and explain why the multiplier oscillates and the optimal policy may randomize.
  • Define the CVaR of a return, compute it for a small distribution, and relate it to robustness against perturbed dynamics.
  • State the robust Bellman equation, contrast worst-case robustness with domain randomization, and observe how much model error a feedback controller tolerates.
  • Explain how a shield keeps exploration safe, and why specification gaming and goal misgeneralization need remedies of a different kind.

Five ways to be unsafe

Safety requirements come in different mathematical shapes, and confusing them leads to the wrong tool. Five recur.

  1. Constraints. Some cost must stay within a budget however much reward is on offer: expected collisions per shift, energy used, time spent outside safe limits.
  2. Risk. The average outcome is acceptable but the bad tail is not. A policy that is excellent on 99 days and catastrophic on the 100th is ranked by its mean as if the 100th day were ordinary.
  3. Model error. The policy is optimal for the MDP it was trained in and is deployed in a different one: a simulator, an outdated model, a slightly different robot.
  4. Safe exploration. The final policy may be fine, but learning it means trying actions whose consequences are unknown, and some tries are unacceptable.
  5. Specification. The objective itself is wrong, or right only on the situations seen in training.
ProblemFormal questionStandard formalismWhere it is developed
ConstraintsIs Jc(π)≤bJ_c(\pi)\le b?Constrained MDP, Lagrangian methodsConstrained MDPs & Lagrangian Methods
RiskHow bad is the worst α\alpha fraction of returns?Risk measures such as CVaRRisk-Sensitive RL
Model errorWhat if PP is wrong?Robust MDPs, domain randomizationRobust MDPs & Sim-to-Real Transfer
Safe explorationIs every policy tried while learning acceptable?Constraints on the learning process: shields, safe setsthis lesson, step 5
SpecificationIs rr the right objective?No single formalism: gaming, goal misgeneralization, side effectsGoal Misgeneralization & Side Effects
Jc(π)J_c(\pi) is the expected discounted sum of a cost signal cc, defined like the return.

Before reaching for any of these, notice what ordinary expected-return maximization already does. When the catastrophe is in the reward and the dynamics are known, the optimal policy prices the danger by itself.

How much does the model matter? Take the edge path, optimal at noise 0, and run it in a world whose moves slip with probability 0.2. Solving for the probability of ending in the cliff exactly gives about 55%: more than half the episodes end in a fall. The policy planned for noise 0.2 never falls; it pays with about 30 steps per episode instead of 13. Nothing was wrong with the reward. The plan was optimal for the wrong MDP.

Check your understanding

The edge path is optimal when moves never slip. Executed in a world where they slip with probability 0.2, it falls 55% of the time, while the policy computed for that world never falls. Which of the five problems does the 55% illustrate?

  1. Specification: the reward should punish the edge more
  2. Risk: the mean return hides a heavy tail
  3. Model error: the policy was optimized for a different MDP
  4. Safe exploration: the agent fell while learning
Show the answer

C. Model error: the policy was optimized for a different MDP

The reward was right, and value iteration with the right noise is already cautious enough never to fall. The failure comes from planning with the wrong transition probabilities, which is what robust MDPs and domain randomization address.

Constraints and their prices

A constrained MDP keeps costs as separate signals c1,…,cKc_1,\dots,c_K with budgets b1,…,bKb_1,\dots,b_K in their own units: "at most 0.05 expected collisions per shift", not "a collision is worth −37-37 reward".

Why not fold the cost into the reward with a fixed weight, r−λcr-\lambda c? Because the budget is the specification, and the weight that meets it is unknown in advance. Too small a λ\lambda violates the budget; too large a λ\lambda gives up reward for nothing. Worse, a fixed penalty that meets the budget in one environment can violate it in another. Lagrangian methods learn the weight.

max⁡π Jr(π)subject toJck(π)=Eπ[∑t≥0γt ck(St,At)]≤bk,k=1,…,K\max_\pi\ J_r(\pi)\quad\text{subject to}\quad J_{c_k}(\pi)=\E_\pi\Big[\sum_{t\ge0}\gamma^t\,c_k(S_t,A_t)\Big]\le b_k,\qquad k=1,\dots,K
The constrained MDP (Altman, 1999), with Jr(π)J_r(\pi) the expected discounted return from S0∼μS_0\sim\mu. With K=0K=0 it is an ordinary MDP. Budgets are often written dkd_k; here bkb_k avoids a clash with occupancy measures dμπd^\pi_\mu.
DerivationLagrangian relaxation and dual descent
  1. L(π,λ)=Jr(π)−∑kλk(Jck(π)−bk)=Eπ[∑t≥0γt(r−∑kλkck)(St,At)]+∑kλkbk\mathcal L(\pi,\boldsymbol\lambda)=J_r(\pi)-\sum_{k}\lambda_k\big(J_{c_k}(\pi)-b_k\big)=\E_\pi\Big[\sum_{t\ge0}\gamma^t\Big(r-\sum_k\lambda_kc_k\Big)(S_t,A_t)\Big]+\sum_k\lambda_kb_k

    Attach a multiplier λk≥0\lambda_k\ge0 to each constraint. For a fixed λ\boldsymbol\lambda the Lagrangian is the value of an ordinary MDP with reward r−∑kλkckr-\sum_k\lambda_kc_k, plus a constant, so any RL algorithm can maximize it:

  2. g(λ)=max⁡πL(π,λ) ≥ max⁡π feasibleJr(π)=P⋆g(\boldsymbol\lambda)=\max_\pi\mathcal L(\pi,\boldsymbol\lambda)\ \ge\ \max_{\pi\ \text{feasible}}J_r(\pi)=P^\star

    Weak duality. A feasible policy has Jck(π)−bk≤0J_{c_k}(\pi)-b_k\le0, so the penalty is never negative and L(π,λ)≥Jr(π)\mathcal L(\pi,\boldsymbol\lambda)\ge J_r(\pi). Maximizing over all policies can only add, so the dual function bounds the constrained optimum P⋆P^\star for every λ≥0\boldsymbol\lambda\ge0:

  3. g(λ′) ≥ g(λ)+∑k(λk′−λk)(bk−Jck(πλ))g(\boldsymbol\lambda')\ \ge\ g(\boldsymbol\lambda)+\sum_k(\lambda'_k-\lambda_k)\big(b_k-J_{c_k}(\pi_{\boldsymbol\lambda})\big)

    gg is a maximum of functions affine in λ\boldsymbol\lambda, hence convex. If πλ\pi_{\boldsymbol\lambda} attains the maximum, then for any λ′\boldsymbol\lambda', g(λ′)≥L(πλ,λ′)g(\boldsymbol\lambda')\ge\mathcal L(\pi_{\boldsymbol\lambda},\boldsymbol\lambda'), which rearranges to a subgradient inequality with slope b−Jc(πλ)\mathbf b-J_{\mathbf c}(\pi_{\boldsymbol\lambda}):

  4. λk ← max⁡(0, λk+η (Jck(πλ)−bk))\lambda_k\ \leftarrow\ \max\Big(0,\ \lambda_k+\eta\,\big(J_{c_k}(\pi_{\boldsymbol\lambda})-b_k\big)\Big)

    Projected subgradient descent on gg gives the multiplier update. The price of cost kk rises while the current policy overspends and falls while it has slack:

text
λ ← 0                                         # one multiplier per cost; K = 1 here
repeat:
    collect episodes with π_θ
    estimate Ĵ_c and the advantages A_r, A_c (two critics, as in actor–critic)
    θ ← PPO step on the advantage A_r − λ·A_c   # primal: best response to the price λ
    λ ← max(0, λ + η_λ · (Ĵ_c − b))            # dual: raise the price while over budget

Lagrangian PPO, a workhorse of deep safe RL as of the mid-2020s. The policy step uses a small learning rate and the multiplier moves slowly, so the two updates approximate the alternation of best response and dual descent.

DerivationA three-route example: why the optimum randomizes
  1. P⋆=max⁡p≤1/3(10p+6(1−p))=6+43=223≈7.33 > 6P^\star=\max_{p\le1/3}\big(10p+6(1-p)\big)=6+\tfrac43=\tfrac{22}3\approx7.33\ >\ 6

    A one-step decision, so JJ is just an expectation. Route A pays reward 10 at expected cost 0.2, route B pays 6 at cost 0.05, route C pays 2 at cost 0. The budget is b=0.1b=0.1. A is infeasible, B is the best deterministic choice, and mixing A with probability pp and B otherwise meets the budget while 0.2p+0.05(1−p)≤0.10.2p+0.05(1-p)\le0.1, that is, p≤13p\le\tfrac13:

  2. g(λ)=max⁡(10−0.2λ, 6−0.05λ, 2)+0.1λ={10−0.1λλ≤8036+0.05λ803≤λ≤802+0.1λλ≥80g(\lambda)=\max\big(10-0.2\lambda,\ 6-0.05\lambda,\ 2\big)+0.1\lambda=\begin{cases}10-0.1\lambda & \lambda\le\tfrac{80}3\\[2pt] 6+0.05\lambda & \tfrac{80}3\le\lambda\le80\\[2pt] 2+0.1\lambda & \lambda\ge80\end{cases}

    The dual function takes the best route for the price λ\lambda. A beats B when 10−0.2λ>6−0.05λ10-0.2\lambda>6-0.05\lambda, i.e. λ<803\lambda<\tfrac{80}{3}, and B beats C when λ<80\lambda<80:

  3. f=13(the optimal mixture, recovered only on average)f=\tfrac13\qquad\text{(the optimal mixture, recovered only on average)}

    The minimum is at λ⋆=803\lambda^\star=\tfrac{80}3, where g=223=P⋆g=\tfrac{22}3=P^\star: no duality gap, as linear-programming duality guarantees for finite CMDPs. But no single best response is the answer. Below λ⋆\lambda^\star the best response is A, which overspends by 0.1, so λ\lambda rises; above it the best response is B, with slack 0.05, so λ\lambda falls. The iterates alternate, and their long-run frequency of A solves 0.1f=0.05(1−f)0.1f=0.05(1-f):

Predict before you look

In the three-route example, at what price λ\lambda of expected cost is the agent indifferent between routes A and B?

Show the answer

26.7

10−0.2λ=6−0.05λ10-0.2\lambda=6-0.05\lambda gives λ=4/0.15=803≈26.7\lambda=4/0.15=\tfrac{80}3\approx26.7. It is also the marginal value of the budget: with bb slightly larger, p=(b−0.05)/0.15p=(b-0.05)/0.15 and P⋆=6+4pP^\star=6+4p grows at rate 4/0.15≈26.74/0.15\approx26.7 per unit of budget. A Lagrange multiplier is a shadow price.

Risk: how bad is the tail?

A constraint on an expected cost controls the average, and the average can hide rare disasters. Risk measures look at the tail of the return distribution instead. The most used is the conditional value at risk: at level α∈(0,1]\alpha\in(0,1], CVaR⁡α(G)\operatorname{CVaR}_\alpha(G) is the expected return over the worst α\alpha fraction of outcomes. α=1\alpha=1 gives the mean, and α→0\alpha\to0 approaches the worst case. Rockafellar and Uryasev gave a formula for it (2000), and later showed that it holds for any distribution, discrete ones included (2002):

CVaR⁡α(G)=max⁡ν∈R{ν−1α E[(ν−G)+]},attained at ν=VaR⁡α(G)=inf⁡{x:Pr⁡(G≤x)≥α}\operatorname{CVaR}_\alpha(G)=\max_{\nu\in\R}\Big\{\nu-\frac1\alpha\,\E\big[(\nu-G)_+\big]\Big\},\qquad\text{attained at }\nu=\operatorname{VaR}_\alpha(G)=\inf\{x:\Pr(G\le x)\ge\alpha\}
(x)+=max⁡(x,0)(x)_+=\max(x,0). For rewards the bad tail is the lower one; for costs, flip the signs. Equivalently, CVaR⁡α(G)\operatorname{CVaR}_\alpha(G) is the smallest expectation E[ξG]\E[\xi G] over reweightings ξ≥0\xi\ge0 with E[ξ]=1\E[\xi]=1 and ξ≤1/α\xi\le1/\alpha: the worst distortion that multiplies the probability of any outcome by at most 1/α1/\alpha.
DerivationSame ranking by mean, opposite ranking by tail
  1. E[GA]=0.95⋅10−0.05⋅100=4.5 > 4=E[GB]\E[G_A]=0.95\cdot10-0.05\cdot100=4.5\ >\ 4=\E[G_B]

    Policy A returns 10 with probability 0.95 and −100-100 with probability 0.05. Policy B returns 4 always. By the mean, A wins:

  2. CVaR⁡0.1(GA)=10−10.1⋅0.05⋅(10−(−100))=10−55=−45\operatorname{CVaR}_{0.1}(G_A)=10-\frac{1}{0.1}\cdot0.05\cdot\big(10-(-100)\big)=10-55=-45

    At α=0.1\alpha=0.1: Pr⁡(GA≤−100)=0.05<0.1\Pr(G_A\le-100)=0.05<0.1 and Pr⁡(GA≤10)=1\Pr(G_A\le10)=1, so VaR⁡0.1(GA)=10\operatorname{VaR}_{0.1}(G_A)=10. Plug ν=10\nu=10 into the formula:

  3. CVaR⁡0.1(GB)=4 ≫ −45=CVaR⁡0.1(GA)\operatorname{CVaR}_{0.1}(G_B)=4\ \gg\ -45=\operatorname{CVaR}_{0.1}(G_A)

    The worst 10% of A's outcomes are half disasters and half ordinary days, averaging (−100+10)/2=−45(-100+10)/2=-45, while every outcome of B is 4. Under CVaR⁡0.1\operatorname{CVaR}_{0.1}, B wins by a wide margin.

Check your understanding

Two insulin-dosing policies are scored by a weekly cost: hours of dangerously low blood sugar. Policy 1 has 20 such hours in 2% of weeks and none otherwise; policy 2 has 0.4 hours every week. Which criterion prefers policy 2?

  1. The expected weekly cost
  2. The worst-case cost over a rectangular uncertainty set around the true dynamics
  3. The discounted cost with γ=0.99\gamma=0.99
  4. The CVaR at level 0.05 of the weekly cost (the mean of the worst 5% of weeks)
Show the answer

D. The CVaR at level 0.05 of the weekly cost (the mean of the worst 5% of weeks)

Both expected costs are 0.02×20=0.40.02\times20=0.4. The worst 5% of policy 1's weeks are the 2% with 20 hours and 3% with none, averaging 0.4/0.05=80.4/0.05=8 hours, against 0.4 for policy 2. Only a tail criterion separates a steady small cost from a rare large one.

Two facts make CVaR harder and more interesting than it looks. It is not time-consistent: how much risk is left to take depends on the return collected so far, so the optimal policy is generally not Markov in StS_t alone. For a fixed threshold ν\nu in the formula above, adding to the state a running quantity built from ν\nu and the reward collected so far restores a Markov problem, and an outer search over ν\nu finishes the job (Bäuerle & Ott, 2011). And CVaR is robustness in disguise: the reweighting form above already reads as an adversary that may inflate the probability of bad outcomes by up to 1/α1/\alpha, and Chow, Tamar, Mannor & Pavone (2015) showed that the CVaR of an MDP's return equals its worst-case expected return when an adversary may perturb the transition probabilities within a budget. Risk-Sensitive RL develops the distributional methods that estimate such quantities.

Robustness: when the model is wrong

The cliff showed the cost of planning with the wrong noise. A robust MDP plans against every model it cannot rule out. An uncertainty set P\mathcal P contains the transition kernels consistent with what is known, for example every kernel within ℓ1\ell_1 distance κ\kappa of an estimate, and the agent maximizes its worst-case value,

max⁡π min⁡P∈P JP(π).\max_\pi\ \min_{P\in\mathcal P}\ J_P(\pi).

If the set is (s,a)(s,a)-rectangular, a product P=×s,aPs,a\mathcal P=\times_{s,a}\mathcal P_{s,a} of separate sets for each state–action pair, nature's choices decouple across pairs, and dynamic programming survives with one extra minimization inside the backup (Iyengar, 2005; Nilim & El Ghaoui, 2005).

VP⋆(s)=max⁡a[r(s,a)+γmin⁡p∈Ps,a∑s′p(s′) VP⋆(s′)]V^\star_{\mathcal P}(s)=\max_a\Big[r(s,a)+\gamma\min_{p\in\mathcal P_{s,a}}\sum_{s'}p(s')\,V^\star_{\mathcal P}(s')\Big]
The robust Bellman equation. Its right-hand side is a γ\gamma-contraction in the max norm, so robust value iteration converges from any start, and a deterministic stationary policy greedy for VP⋆V^\star_{\mathcal P} is robust-optimal. For an ℓ1\ell_1 ball of radius κ\kappa the inner minimum has a closed form: move up to κ/2\kappa/2 of probability from the best next states onto the worst one.

Robustness has a price: the larger the set, the more conservative the policy. Domain randomization takes an average instead of the worst case. A simulator's parameters ξ\xi (masses, friction, delays, textures, lighting) are drawn from a distribution ν\nu at the start of each episode, and the agent maximizes Eξ∼ν[Jξ(π)]\E_{\xi\sim\nu}\big[J_\xi(\pi)\big]. Tobin et al. (2017) randomized textures and lighting so that an object detector trained only on rendered images worked on real camera images; Peng et al. (2018) randomized the dynamics so that a pushing policy trained in simulation worked on a real arm; OpenAI et al. (2019) widened the ranges automatically as training progressed, to manipulate a Rubik's cube with a robot hand.

The average needs a distribution rather than a set and can neglect rare parameter values. A policy with memory can do better than either, by identifying ξ\xi from its own history; Robust MDPs & Sim-to-Real Transfer analyzes when that matters.

Why is LQR so tolerant? It never commits to a plan. At every step it measures the state and pushes against the remaining error, so an underestimate of what a push does is corrected by the next measurement. Continuous-time LQR provably stays stable when its input gain is multiplied by any factor above 12\tfrac12 (Safonov & Athans, 1977), and a model mass that is 90% too large is exactly an input gain error of 1.9. A planner that trusts its model over a short horizon has less to fall back on: on the same cart, MPC with a 1-second horizon loses 16% under the same error.

Safe exploration: shields and safe sets

Every constraint so far is a property of a policy. Learning visits a whole sequence of policies, and an ε-greedy agent beside a cliff falls during training however good its greedy policy is. In Sutton and Barto's cliff walk, Q-learning learns the edge path and keeps falling off while it explores, while SARSA, which evaluates the exploring policy it actually follows, learns a route further from the edge (SARSA & Q-Learning). Safe exploration asks for guarantees during learning itself. Safety Gym (Ray, Achiam & Amodei, 2019) made the question measurable: it reports the average cost per step over all of training (the cost rate) alongside the final return and cost.

A shield (Alshiekh et al., 2018) is a small, verified component between agent and environment. From a temporal-logic specification of what must never happen and a conservative abstraction of the dynamics (one that over-approximates what can happen), it computes the actions from which the specification can still be guaranteed. A preemptive shield offers the agent only those actions; a post-posed shield lets the agent choose and replaces an unsafe choice by a safe one. Learning continues inside the safe envelope, and the guarantee is exactly as good as the abstraction.

python
import numpy as np

def shielded_action(policy_probs, allowed, rng):
    """Preemptive shield: sample only among the actions the shield allows here.
    policy_probs: the agent's action probabilities (numpy array);
    allowed: boolean mask computed by the shield, with at least one True."""
    p = np.where(allowed, policy_probs, 0.0)
    if p.sum() == 0.0:                  # the agent put no mass on any safe action
        p = allowed.astype(float)       # fall back to uniform over safe actions
    return rng.choice(len(p), p=p / p.sum())

The learning algorithm is unchanged; only the actions it may execute are filtered. With rng = np.random.default_rng(0) this runs as written. Computing allowed is the hard part: it comes from solving a safety game on the abstraction before learning starts.

Other approaches start from a known safe policy and expand cautiously: a model with calibrated uncertainty certifies a region of states from which the system provably returns to safety, and exploration stays inside it while the region grows (Berkenkamp et al., 2017); or new policies are deployed only when a high-confidence bound says they are no worse than the current one (High-Confidence Evaluation & Safe Improvement). All of them buy safety with prior knowledge: a specification and an abstraction, a model with honest uncertainty, a safe starting policy, or logged data. Without any of these, an agent cannot know that an action is unsafe before it has seen what the action does.

When the objective is wrong

The last problem is the hardest to formalize, because the formalism is what has failed.

  • Specification gaming. An optimizer finds the cheapest way to score, which need not be what the designer meant. In a boat-racing game scored by targets hit, an RL agent learned to loop forever around a small lagoon, knocking over the same targets each time they reappeared, catching fire and colliding as it went, and scored more than finishing the race would have (Clark & Amodei, 2016). Krakovna et al. (2020) keep a list of dozens of such cases, and with learned reward models the optimizer exploits the model's errors (Reward Overoptimization & Goodhart's Law).
  • Goal misgeneralization. The reward is right, but training cannot distinguish the intended goal from a proxy. In CoinRun the coin always sat at the right end of the level during training; with the coin moved at test time, agents mostly ignored it and kept heading for the level's right end (Langosco et al., 2022).
  • Side effects. A reward is silent about everything it does not mention, such as the vase on the shortest path.

None of the earlier tools repairs these. A constraint limits only the costs someone wrote down, a robust MDP guards against wrong dynamics rather than a wrong goal, and a shield needs a specification. The remedies are of another kind: better objectives (learned from human feedback, with failure modes of their own), training distributions that separate intended goals from proxies, penalties on impact, and agents that can be corrected or interrupted.

Check your understanding

A cleaning robot is rewarded for the amount of dust its sensor registers being sucked up. It learns to empty its bin onto the floor and vacuum the same dust again. Which problem is this?

  1. Goal misgeneralization
  2. Specification gaming
  3. Model error
  4. A side effect of an otherwise correct objective
Show the answer

B. Specification gaming

The reward pays for dust collected, not for a clean floor, and the loophole is exploitable in training as well as at deployment. The behavior is optimal for the reward as written, which is the signature of specification gaming.

Key takeaways

  • Safety splits into constraints, risk, model error, safe exploration and specification; each has its own formalism, and the wrong one fixes nothing.
  • A constrained MDP keeps costs separate with budgets. Its Lagrangian is an MDP with reward r−∑kλkckr-\sum_k\lambda_kc_k, and dual descent raises each price while its constraint is violated; the optimum may randomize, and primal–dual iterates then reach it only on average.
  • CVaR⁡α\operatorname{CVaR}_\alpha averages the worst α\alpha fraction of returns. It can reverse the ranking by the mean, needs the running return in the state, and equals a worst case over budgeted perturbations of the dynamics.
  • Robust MDPs with (s,a)(s,a)-rectangular uncertainty sets keep a contracting Bellman operator; domain randomization optimizes an average over simulators instead, and feedback such as LQR tolerates large model errors.
  • Safety during learning needs prior knowledge: a shield's specification and abstraction, a calibrated model, a safe starting policy or data. Wrong objectives need other remedies: better rewards, data that separate goals from proxies, impact penalties and correctability.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

In Lagrangian PPO with one cost, the estimated cost J^c\hat J_c has exceeded the budget bb for many iterations. What happens to λ\lambda, and to the policy's incentives?

  1. λ\lambda falls, so the policy cares less about cost
  2. λ\lambda keeps rising, so the effective reward r−λcr-\lambda c penalizes cost more and more
  3. λ\lambda stays fixed; only the policy changes
  4. λ\lambda jumps straight to infinity, so the policy ignores reward
Show the answer

B. λ\lambda keeps rising, so the effective reward r−λcr-\lambda c penalizes cost more and more

The update λ←max⁡(0,λ+η(J^c−b))\lambda\leftarrow\max\big(0,\lambda+\eta(\hat J_c-b)\big) integrates the violation: every iteration over budget raises the price. The policy's effective reward r−λcr-\lambda c makes cost more expensive until the constraint holds, and because the price reacts with a lag it usually overshoots.

Question 2

For a CMDP with optimal value P⋆P^\star, the dual function is g(λ)=max⁡π[Jr(π)−λ(Jc(π)−b)]g(\lambda)=\max_\pi\big[J_r(\pi)-\lambda\big(J_c(\pi)-b\big)\big]. Which statement holds for every λ≥0\lambda\ge0?

  1. g(λ)≤P⋆g(\lambda)\le P^\star
  2. g(λ)=P⋆g(\lambda)=P^\star
  3. g(λ)g(\lambda) is the return of a feasible policy
  4. g(λ)≥P⋆g(\lambda)\ge P^\star
Show the answer

D. g(λ)≥P⋆g(\lambda)\ge P^\star

On feasible policies the penalty −λ(Jc−b)-\lambda(J_c-b) is nonnegative, so L≥Jr\mathcal L\ge J_r there, and maximizing over all policies only adds. Equality holds at the minimizing λ⋆\lambda^\star when there is no duality gap, as for finite CMDPs and, under Slater's condition, in general.

Question 3

Robust value iteration puts a minimization over p∈Ps,ap\in\mathcal P_{s,a} inside each backup. Why does that need the uncertainty set to be (s,a)(s,a)-rectangular?

  1. Only rectangular sets are convex
  2. Rectangular sets contain the true model with high probability
  3. The minimization is done separately at each state–action pair, which is valid only if nature's choice at one pair does not restrict its choice at another
  4. Without rectangularity the robust value is always −∞-\infty
Show the answer

C. The minimization is done separately at each state–action pair, which is valid only if nature's choice at one pair does not restrict its choice at another

A rectangular set is a product of per-pair sets, so the worst kernel can be assembled pair by pair and the minimization moves inside the backup. If the models are coupled, say the friction is the same in every state, the worst case is one global choice, and computing robust policies for general non-rectangular sets is NP-hard (Wiesemann, Kuhn & Rustem, 2013).

Question 4

Policy X returns 0 with probability 0.9 and 50 with probability 0.1. Policy Y returns 4 always. Which ranking is correct?

  1. X has the higher mean, and Y the higher CVaR⁡0.2\operatorname{CVaR}_{0.2}
  2. X wins on both criteria
  3. Y wins on both criteria
  4. They tie on CVaR⁡0.2\operatorname{CVaR}_{0.2}
Show the answer

A. X has the higher mean, and Y the higher CVaR⁡0.2\operatorname{CVaR}_{0.2}

E[GX]=5>4\E[G_X]=5>4. Nine tenths of X's outcomes are 0, so its worst 20% are all 0 and CVaR⁡0.2(GX)=0<4\operatorname{CVaR}_{0.2}(G_X)=0<4. A risk-averse criterion gives up the lottery's upside to avoid its likely zero.

Question 5

How does domain randomization differ from a robust MDP?

  1. It maximizes the worst case over a set of simulators
  2. It needs no simulator at all
  3. It maximizes the average return over a distribution of simulator parameters, so it needs a distribution rather than a set and can neglect rare parameter values
  4. It guarantees transfer to any real system inside the randomization ranges
Show the answer

C. It maximizes the average return over a distribution of simulator parameters, so it needs a distribution rather than a set and can neglect rare parameter values

Domain randomization samples ξ∼ν\xi\sim\nu each episode and maximizes Eξ[Jξ(π)]\E_\xi[J_\xi(\pi)], an average case; a robust MDP maximizes the worst case over a set. Neither guarantees transfer by itself, and a policy with memory can adapt to the parameters it actually meets.

Go deeper

Further reading

  • E. Altman, Constrained Markov Decision Processes (Chapman & Hall/CRC, 1999).
  • J. García & F. Fernández, "A comprehensive survey on safe reinforcement learning," Journal of Machine Learning Research 16, 1437–1480 (2015).
  • A. Nilim & L. El Ghaoui, "Robust control of Markov decision processes with uncertain transition matrices," Operations Research 53(5), 780–798 (2005).
  • M. Alshiekh, R. Bloem, R. Ehlers, B. Könighofer, S. Niekum & U. Topcu, "Safe reinforcement learning via shielding," AAAI (2018).