Robust MDPs & Sim-to-Real Transfer
Uncertainty sets, robust Bellman operators and domain randomization.
A simulator is a model, and every model is wrong somewhere. Robust MDPs plan against the worst model in a set; domain randomization plans for the average over a distribution; a feedback controller plans for one model and corrects itself as it goes. This lesson proves when worst-case planning keeps the structure of dynamic programming and when it becomes NP-hard, computes the worst case in closed form for the usual uncertainty sets, places risk, entropy and adversarial training on the same map, and derives the oldest robustness guarantee of all: the margins of LQR.
What you’ll learn
- Define -rectangular robust MDPs, prove that the robust Bellman operator is a -contraction, and show that under rectangularity a stationary adversary is as strong as one that changes the model at every visit.
- Solve the inner worst-case problem in closed form for and KL uncertainty sets, and explain why coupled (non-rectangular) uncertainty is both hard and over-approximated by rectangular sets.
- Compare domain randomization, distributionally robust, CVaR, adversarial and maximum-entropy formulations as answers to the same question.
- Derive LQR's guaranteed gain and phase margins from the return-difference equality, and use them to explain how the cart controller tolerates a wrong mass.
Rectangularity and the robust Bellman operator
Let attain the inner minimum for . Then , because is a probability vector; the symmetric argument bounds the difference from below. So the inner minimum is a non-expansion:
The maximum over actions is a non-expansion too, and the discount multiplies by . Robust value iteration therefore converges geometrically to a unique fixed point, exactly as in Bellman Operators & Contraction:
A stationary adversary suffices. Fix a stationary . Its robust evaluation operator (an average over in place of the max) is also a contraction, and its fixed point is the value against an adversary that may choose a new kernel at every visit. Pick for every pair. By rectangularity the assembled kernel lies in , and
One fixed kernel already does as much damage as the dynamic adversary, and every fixed is one of the dynamic adversary's options, so the two worst cases coincide. Without rectangularity, may lie outside , and both the argument and the decomposition into per-pair minimizations fail:
Rectangularity says that nature's choices at different state–action pairs are unrelated. Physical uncertainty rarely is: one unknown mass or one friction coefficient affects every transition at once. The rectangular hull of such a family, the product of its per-pair slices, lets the adversary combine a heavy robot in one state with a light one in the next. It is tractable and safe (it contains the true set) but can be far more pessimistic than reality.
Planning against the coupled set itself is hard. Wiesemann, Kuhn & Rustem (2013) showed that computing an optimal robust policy for general uncertainty sets is NP-hard, even to approximate, while convex -rectangular sets remain tractable at a price: their robust-optimal policies may need to randomize, as an adversary that can couple the actions of a state can exploit any deterministic choice.
A robot's mass kg is unknown and fixed, and every transition probability depends on it. Let . What can you say about planning against ?
- is -rectangular, so robust value iteration on it is exact
- Robust planning is impossible for any set indexed by a parameter
- is not rectangular; robust value iteration on its rectangular hull is tractable but more conservative, because it lets the adversary use different masses in different states
- The worst case over is always the heaviest mass
Show the answer
C. is not rectangular; robust value iteration on its rectangular hull is tractable but more conservative, because it lets the adversary use different masses in different states
Each pair has its own slice , but the family ties all slices to one , so it is not their product. The hull contains every combination of slices, so its robust value is a lower bound on the true worst case: safe, but possibly much too pessimistic.
Solving the inner problem
Robust value iteration needs at every backup. For the sets used in practice the minimization is cheap, and its solution shows what the adversary does.
Let around a nominal . Moving mass from one next state to another changes the distance by , so the adversary may move up to . To lower it adds to the worst state and removes from the states with the highest values, highest first:
The operation takes a sort, per pair. It mirrors the optimistic backup of UCRL2, which moves mass the other way, onto the best state (Optimism in MDPs: UCRL2 & UCBVI).
Same nominal distribution and values , but now . What is the worst-case expected next value ?
Show the answer
3.2
The adversary moves onto the worst state, taking it all from the best one, which holds 0.5: and . The nominal value was 6.2, so this radius costs almost half of it.
For the inner problem is convex with one constraint, and Slater's condition holds for , so it equals its Lagrangian dual with a multiplier :
The inner minimization is the Gibbs variational principle: it is attained by tilting exponentially toward low values, and its value is a log-partition function:
What remains is a one-dimensional concave maximization over , solved by bisection. A large budget leads to a small , a sharp tilt, and a worst case near :
Where do the sets come from? From data: with samples of a pair, the empirical distribution is within distance of order of the truth, up to logarithmic factors, with high probability. Planning against these confidence sets is pessimism in the face of uncertainty, the mirror image of the optimism that drives exploration, and it is the basis of offline RL theory (Pessimism: The Theory of Offline RL). Per-pair confidence sets are rectangular by construction, which is convenient; the union bound over all pairs needed to cover every pair at once makes them conservative.
Average, worst case, risk and entropy
Domain randomization draws simulator parameters (masses, friction, latencies, textures) from a distribution at the start of each episode. For a memoryless policy it maximizes the average : one compromise behavior for every . For a policy with memory it is a POMDP whose hidden state includes , a latent MDP, and the optimal policy uses its history to infer : implicit system identification. Chen, Hu, Jin, Li & Wang (2022) take exactly this view, with the real system as one unknown member of the simulator family, and study the sim-to-real gap: how much worse the domain-randomized policy does on the real system than that system's own optimal policy. Under assumptions on the family they bound the gap using no real data at all, and history-dependent policies turn out to be essential for keeping it small. OpenAI et al. (2019) used a recurrent policy on a robot hand, with randomization ranges that grow automatically whenever the policy copes with the current ones, and reported signs of emergent meta-learning: adaptation within an episode.
The formulations differ in what they need and what they promise.
| Formulation | Objective | Needs | Character |
|---|---|---|---|
| Nominal (certainty equivalence) | one model | optimal if the model is right, brittle otherwise (the cliff's 55% falls) | |
| Domain randomization | a distribution | good on average, may neglect rare ; with memory, adapts | |
| Robust MDP | a set | guarantee on the worst member; conservative; needs rectangularity to be tractable | |
| Distributionally robust (Xu & Mannor, 2010) | a set of distributions | interpolates between average and worst case | |
| CVaR of the return | one model | equals a worst case over budgeted perturbations of the dynamics (Chow et al., 2015) | |
| Maximum entropy | one model | a worst case over perturbed rewards, and a bound for some perturbed dynamics (Eysenbach & Levine, 2022) | |
| Adversarial training (RARL) | a disturbance channel | a zero-sum Markov game against a learned adversary |
RARL (Pinto, Davidson, Sukthankar & Gupta, 2017) makes the adversary a learner. A second policy applies disturbance forces through a channel built into the simulator and is rewarded with the negative of the protagonist's return; alternating policy-gradient updates seek the max–min of a two-player zero-sum Markov game (Zero-Sum Markov Games). The authors reported MuJoCo policies that tolerated test-time changes of mass and friction better than baselines, and performed better even with no adversary present. That is an empirical finding without a guarantee, since alternating gradient play need not reach the max–min.
Maximum-entropy RL is robust by construction, in a precise sense (Eysenbach & Levine, 2022). For every policy, the entropy-regularized objective equals the worst-case expected return over a set of adversarially perturbed reward functions, a set that depends on the policy. For perturbed dynamics, MaxEnt RL run on a pessimistic, log-transformed version of a positive reward maximizes a lower bound on the robust objective for the original reward, over a set of dynamics whose size is at least the policy's entropy. Entropy is a cheap hedge: it buys robustness to unspecified perturbations without naming a set (Maximum-Entropy RL & Soft Actor–Critic).
During training, a simulator's friction coefficient is drawn uniformly from at the start of each episode, and the policy sees only the current state, with no memory. Which objective does training optimize?
- The worst-case return over frictions in
- The return of a single memoryless policy, averaged over frictions
- The return at the average friction, 1.0
- The Bayes-optimal adaptive return, which identifies the friction from the history
Show the answer
B. The return of a single memoryless policy, averaged over frictions
Randomization averages the return over the sampled parameters, and without memory one behavior must serve every friction. A recurrent policy could do better by inferring the friction from its history, which turns the problem into a latent MDP.
Feedback margins: what LQR guarantees
Control theory measured robustness long before RL, through margins: how far the loop gain can be scaled, or its phase delayed, before the closed loop goes unstable. Take continuous-time LQR with one input: dynamics , cost with and , and optimal feedback with , where is the stabilizing solution of the algebraic Riccati equation (The Linear–Quadratic Regulator). Cutting the loop at the input gives the loop transfer function , with .
Add and subtract in the Riccati equation, and use :
Multiply on the left by and on the right by . Since , the three terms on the left become , and ; add to both sides:
At , is the complex conjugate of (all matrices are real), and the right side is plus a squared norm. This is Kalman's inequality:
So the Nyquist plot of never enters the unit disk around . Scaling the gain by moves the critical point to , which for stays inside that disk, so the encirclement count, and with it stability, is unchanged. Where , the inequality forces the phase to stay at least from :
The widget's cart is a sampled system (steps of 0.1 s), to which the continuous-time theorem does not apply verbatim; discrete-time LQR has guaranteed margins too, but smaller ones that depend on the sampling. For this loop one can check directly: with designed for the 1.9 kg model and that model's input matrix, the closed-loop matrix keeps both eigenvalues inside the unit circle for every gain factor , so the true factor 1.9 is far inside the stable range. MPC's loss is one of performance, not stability: a short plan with no terminal cost pushes gently, and a model that underestimates the pushes makes it gentler still.
The lesson for RL is double. Feedback, which re-measures and re-acts at every step, is itself a robustness mechanism, and a short open-loop plan is not. And the margins are a property of a structure, optimality for a quadratic cost with exact state feedback. A policy learned by deep RL carries no such certificate: small, carefully chosen perturbations of the observations can change its actions drastically (Huang et al., 2017), and robustness has to be trained in or verified.
A continuous-time LQR controller is designed for an actuator that turns out to be 3 times as strong as modeled, while a second copy is installed where the actuator is only 0.4 times as strong. What does the margin theorem guarantee?
- Stability in both cases
- Stability with the weaker actuator only
- Stability with the stronger actuator; nothing for the weaker one
- Nothing in either case, since margins concern measurement noise
Show the answer
C. Stability with the stronger actuator; nothing for the weaker one
The guaranteed gain range is : a factor of 3 is inside it, and 0.4 is below . Outside the range the theorem is silent: the loop may still be stable, but nothing guarantees it.
Key takeaways
- With -rectangular sets, is a -contraction; deterministic stationary policies are robust-optimal, and a stationary adversary is as strong as a dynamic one.
- Coupled uncertainty is not rectangular: general sets make robust planning NP-hard, -rectangular sets may need randomized policies, and the rectangular hull is tractable but pessimistic.
- The inner problem is closed-form: an ball moves up to of mass onto the worst state, a KL ball tilts the nominal distribution by ; data-driven confidence sets make robust planning the pessimistic twin of optimistic exploration.
- Domain randomization averages over simulators; distributionally robust, CVaR, maximum-entropy and adversarial formulations sit between average and worst case, and memory lets a policy identify the parameters it faces.
- LQR's return-difference equality guarantees gain margins and of phase in continuous time, which is why a wrong mass barely matters; LQG has no guaranteed margins, and learned policies carry no comparable certificate.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Which fact makes the robust Bellman operator a -contraction?
- The uncertainty sets are convex
- For each pair, is a non-expansion in the max norm, because every is a probability vector
- The worst-case kernel is unique
- The rewards are nonnegative
Show the answer
B. For each pair, is a non-expansion in the max norm, because every is a probability vector
A minimum of averages changes by at most when changes, and so does the maximum over actions; the discount supplies the factor . Convexity, uniqueness and the sign of rewards play no role.
Under -rectangularity, what does it add, for a stationary policy, to let nature change the transition kernel at every visit instead of fixing one kernel?
- Nothing: one stationary kernel in attains the same worst case
- It makes the worst case strictly worse in general
- It makes evaluating the policy NP-hard
- It forces the agent to randomize
Show the answer
A. Nothing: one stationary kernel in attains the same worst case
The kernel assembled from per-pair minimizers for the dynamic adversary's value lies in by rectangularity and reproduces that value, so the static and dynamic worst cases coincide. Without rectangularity they can differ.
For a KL uncertainty set of radius around , what is the worst-case next-state distribution?
- itself: KL balls are too small to matter
- The uniform distribution
- Always a point mass on the worst state, whatever
- tilted exponentially toward low values, , with set by the radius
Show the answer
D. tilted exponentially toward low values, , with set by the radius
The Gibbs variational principle solves the inner problem for each multiplier , and the dual picks to use up the budget . A small radius gives a gentle tilt; once the point mass on the worst state becomes affordable.
Why does a model mass that is 90% too large barely hurt the LQR cart?
- LQR estimates the mass online
- LQR's gain does not depend on the mass, so the error cancels
- The mass error acts as an input-gain error of 1.9, well inside the range in which the feedback loop stays stable and near-optimal, and every new measurement corrects a misjudged push
- The cost function does not involve the mass
Show the answer
C. The mass error acts as an input-gain error of 1.9, well inside the range in which the feedback loop stays stable and near-optimal, and every new measurement corrects a misjudged push
The real cart responds 1.9 times as strongly as the model expects, which scales the loop gain. The continuous-time theorem covers any factor above , and for the sampled cart the loop stays stable up to about 18. Cost rises only 2.6%; settling slows from 4.7 to 6.7 s.
Further reading
- G. N. Iyengar, "Robust dynamic programming," Mathematics of Operations Research 30(2), 257–280 (2005).
- A. Nilim & L. El Ghaoui, "Robust control of Markov decision processes with uncertain transition matrices," Operations Research 53(5), 780–798 (2005).
- W. Wiesemann, D. Kuhn & B. Rustem, "Robust Markov decision processes," Mathematics of Operations Research 38(1), 153–183 (2013).
- L. Pinto, J. Davidson, R. Sukthankar & A. Gupta, "Robust adversarial reinforcement learning," ICML (2017).
- M. G. Safonov & M. Athans, "Gain and phase margin for multiloop LQG regulators," IEEE Transactions on Automatic Control 22(2) (1977).