Constrained Policy OptimizationConstrained Policy Optimization
The authors propose Constrained Policy Optimization (CPO), a policy search algorithm for CMDPs with a per-step approximate constraint satisfaction guarantee, and compare it with PDO and TRPO on 5 simulated robotic tasks.
- Policy search algorithms for deep reinforcement learning do not consider constraints, yet in settings such as physical systems cohabited with humans it is important to satisfy safety constraints throughout training; existing methods cannot guarantee that every iteration's policy satisfies the constraints in continuous CMDPs.
- The authors prove a new bound that bounds the difference in return using the average divergence between two policies, and based on this propose CPO: maximizing a linear approximation of the return advantage within a trust region while constraining the auxiliary cost upper bound, solved via duality and with a recovery step when infeasible.
- On 5 environments in total across two task types, Circle and Gather, and three robots, the authors state that CPO approximately satisfies the constraints in all environments, with constraint returns close to the limit, and overall outperforms PDO without sacrificing return; fixed-penalty methods are sensitive to the penalty coefficient.
- The authors note that the theoretically guaranteed update step is too small and that CPO is a principled approximation to it; approximation error may produce infeasible iterates, requiring a recovery mechanism; the experiments cover only 5 simulated environments with a single constraint, and the paper does not report statistical significance tests.
- Benchmarks
- Circle(Point-mass、Ant、Humanoid)Gather(Point、Ant)
- Metrics
- discounted returnconstraint return(C-return 与 C+-return)
Joshua Achiam et al. propose Constrained Policy Optimization (CPO), a general-purpose policy search algorithm for constrained reinforcement learning that can provide near-constraint-satisfaction guarantees at each iteration. Its guarantees are based on a new theoretical result that gives the relationship between the expected returns of two policies and the average divergence between them. The authors validate the method on simulated robot locomotion tasks with safety constraints.
Paper analysis
What problem does this paper attempt to solve?
The authors state that they propose the first general policy search algorithm for CMDPs that approximately satisfies the constraints at every iteration and is applicable to neural network policies.
Core problem: how to guarantee that, when training high-dimensional (neural network) policies with policy search, every iteration's policy throughout training (approximately) satisfies the safety constraints.
- Problem setting and importance: The authors note that deep RL assumes the agent can freely explore any behavior during learning, but in settings involving physical interaction with humans (e.g. a robotic arm in a factory) this is unacceptable, and safe exploration is important; incorporating safety via constraints (rather than only reward design) is a natural approach.
- Shortcomings of existing methods: Finite CMDPs can be solved for the optimal policy via linear programming, but methods are lacking for high-dimensional control; existing heuristic or primal-dual methods (Uchibe & Doya, 2007; Chow et al., 2015) cannot guarantee that every policy during learning satisfies the constraints; the method of Bou Ammar et al. (2015) contains a semidefinite programming inner loop and assumes constraints are linear in the policy parameters, making it unsuitable for deep RL.
- Core observation: The authors prove a new theoretical result bounding the difference in expected return (or constraint return) between two policies using the average divergence between them, and this bound tightens existing bounds for trust region policy search (Kakade & Langford, 2002; Pirotta et al., 2013; Schulman et al., 2015).
- What the paper proposes: Based on this bound, a policy improvement step is derived that simultaneously guarantees return improvement and constraint satisfaction, forming the Constrained Policy Optimization (CPO) algorithm, validated on safety-motivated simulated robotic locomotion tasks.
- Problem setting (not attack/defense, no threat model): The CMDP framework (Altman, 1999), in which the agent must maximize return subject to the constraint that the expected discounted return of auxiliary costs does not exceed the limit d_i; the paper's experiments have only one constraint.
What related research exists?
Related work is divided into three groups: safe RL surveys, safe policy search, and methods specific to deep RL; the baselines are PDO and TRPO.
Safe RL survey
- García & Fernández (2015)—provide a comprehensive survey of safe reinforcement learning; Moldovan & Abbeel (2012) and Amodei et al. (2016) are cited as background on the importance of safe exploration.
Safe policy search
- Uchibe & Doya (2007)—a policy gradient algorithm that enforces active constraints via gradient projection; the paper notes its drawback is that it cannot prevent the policy from becoming unsafe at the outset.
- Bou Ammar et al. (2015)—a safe policy gradient method for lifelong learning; the paper notes its inner loop requires solving a semidefinite program, which is costly, and it assumes safety constraints are linear in the policy parameters, making it unsuitable for deep RL.
- Chow et al. (2015)—a primal-dual subgradient method for risk-constrained RL that can converge to a policy satisfying the constraints; the paper notes it does not guarantee that intermediate policies satisfy the constraints.
Methods for deep RL
- Held et al. (2017)—safety in robotic manipulation settings; the paper states its assumptions limit applicability. Lipton et al. (2017)—uses an "intrinsic fear" heuristic rather than constraints to avoid rare catastrophic events. Shalev-Shwartz et al. (2016)—decomposes "desires" from trajectory planning, with a non-learning planner enforcing safety constraints.
Trust region and theoretical foundations
- Kakade & Langford (2002), Pirotta et al. (2013), Schulman et al. (2015)—the paper's new bound extends and tightens the policy improvement bounds of these works; TRPO (Schulman et al., 2015) is the trust region framework on which CPO is based.
Baselines and benchmarks: The comparison baselines are PDO (primal-dual optimization, implemented per the paper's Equation (16), Appendix 10.3.3) and TRPO (unconstrained baseline, used to verify that unconstrained optimal behavior violates the constraints); the experimental environments are the Circle and Gather tasks designed by the authors, implemented based on rllab (Duan et al., 2016).
Authors' positioning: Compared with prior work, this paper's method is a policy search algorithm for CMDPs that both guarantees constraint satisfaction throughout training and applies to arbitrary policy classes (including neural networks); the key difference from PDO is that the dual variables are solved exactly from scratch at each step rather than learned statefully.
How does the paper address this problem?
CPO uses a new performance bound to approximate the CMDP update as a convex optimization within a trust region, solves it via the dual, and pairs it with a recovery step and cost shaping.
Overall approach: first prove a new bound that uses the average divergence to bound the difference in returns between two policies, then approximate the local policy update of the CMDP as a trust-region problem in which both the objective and the constraints can be estimated from samples of the current policy, yielding Constrained Policy Optimization (CPO).
Problem setting and theoretical bounds
- CMDP: add auxiliary cost functions C1..Cm and limits d1..dm to an MDP; the feasible policy set is the set of stationary policies satisfying each constraint return JCi(π) ≤ di; the experiments have only one constraint.
- The core result is the bound in Theorem 1: Dπ,f+(π′) ≥ J(π′) − J(π) ≥ Dπ,f−(π′), where the D terms contain the average TV divergence of the two policies under dπ; the authors state that this bound tightens the bounds of Kakade & Langford (2002), Pirotta et al. (2013), and Schulman et al. (2015), and that it is tight when π'=π.
- Via Pinsker's inequality (Corollary 3), the TV divergence is replaced by the average KL divergence, making the bound applicable to trust-region methods; Corollary 2 gives the upper-bound form for the auxiliary cost, used for safety guarantees.
From guaranteed updates to CPO
- The update with a divergence penalty can guarantee that the return is monotonically non-decreasing and satisfies the original constraints, but the authors point out that when the discount factor is close to 1 the penalty is too steep and the step size too small, so they instead use a trust region to obtain the CPO update (Equation 10): maximize the return advantage within D̄KL(π||πk) ≤ δ, and constrain the sample approximation of each JCi to not exceed di.
- Proposition 1 gives a lower bound on the per-step performance decrease of the trust-region update J(πk+1) − J(πk) ≥ (−√(2δ)γϵπk+1)/((1−γ)2); Proposition 2 gives an upper bound on the worst-case constraint violation of the CPO update; both depend on the step size δ.
Practical solution (Section 6)
- Linearizing the objective and constraints at πk and expanding the KL constraint to second order yields a convex problem (Equation 11); since the Fisher information matrix H is positive definite, it can be solved via the dual: the dual is a convex program in m+1 variables (Equation 12), and after solving for λ* and ν*, the update is given by Equation (13).
- With a single constraint there is an analytical solution (Appendix Theorem 2), avoiding an inner-loop optimization; the inverse of H is approximated using conjugate gradient; the proposed step is followed by a backtracking line search to ensure the constraints are satisfied under the sample estimates.
- Approximation error may produce infeasible iterations: if the problem is still feasible it recovers automatically; otherwise a recovery step (Equation 14) updates along the direction of pure constraint decrease, followed by a line search.
Cost shaping to tighten constraints
- To build in a safety margin, the constraint acts on the upper-bound cost Ci+ = Ci + ∆i (Equation 15) rather than on Ci itself; in the experiments states are divided into safe/unsafe, the unsafe cost is 1, and ∆ is taken as "the probability of entering an unsafe state within a fixed time horizon T", given by a learned model updated at each step (a failure prediction network); the authors state that this can also smooth sparse constraints.
Algorithm flow and evaluation method
- Algorithm 1: sample trajectories → form sample estimates of g, b, H, c → if feasible, solve the dual and propose an update, otherwise take a recovery step → backtracking line search to obtain the new policy.
- Success criterion: measured by whether the C+-return (the upper-bound cost return actually constrained) is close to the limit d and whether the return improves; Point-Gather does not use cost shaping because of its short time horizon and looks directly at the C-return.
What experiments did the paper conduct?
CPO, PDO and TRPO are compared on 5 simulated environments, with additional cost shaping ablation and fixed penalty comparison; results are presented as learning curves.
Experimental setup
- Tasks and agents: Two task types, Circle (reward for running along the large circle, constraint to stay within a smaller safe zone) and Gather (reward for collecting green apples, avoid red bombs); three agents: point-mass (S⊆R9, A⊆R2), quadruped ant (S⊆R32, A⊆R8), humanoid (S⊆R102, A⊆R10); all combinations trained except Humanoid-Gather, 5 environments in total.
- Policy and implementation: Neural network policy with two hidden layers (64, 32) (Gaussian policy, tanh activation), implemented based on rllab; GAE-λ estimates the advantage, γ=0.995, λGAE=0.95, δKL=0.01 (Appendix 10.3.2).
- Constraint parameters: Constraint limits d are Point-Circle 5, Ant-Circle 10, Humanoid-Circle 10, Point-Gather 0.1, Ant-Gather 0.2; failure prediction horizon T is 5/20/20/–/20; cost bonus coefficient α is 1 except for Ant-Gather, where it is 0.01.
- Baselines: PDO (dual variables updated statefully per Equation (16), learning rate α=0.01, default ν0=0, additionally tried ν0=1000 in the Point environments); TRPO as the unconstrained baseline.
- Metrics and evaluation: Return and constraint return (C+-return, C-return for Point-Gather); Figure 1 shows the average learning curves over multiple random seeds (5 seeds for the Point environments, 10 for the rest); the paper does not report statistical significance tests.
Main results
Main results are given as the learning curves in Figure 1 (average return and constraint values for CPO, PDO, TRPO on the 5 environments); the converted text contains no readable numerical values, so no table is given; the following is the authors' interpretation of Figure 1:
- CPO approximately satisfies the constraints: The authors state that CPO approximately satisfies the constraints in all environments, and in the simpler Point-Circle and Point-Gather the constraint return tracks the limit value almost exactly.
- PDO is unstable: The authors state that PDO usually eventually converges to a policy that satisfies the constraints, but does not consistently satisfy them throughout training, e.g. the constraint value spikes in Ant-Circle, and it is sensitive to the initialization of the dual variables; ν0=1000 guarantees constraint satisfaction but harms return.
- Overall comparison: The authors state that CPO overall outperforms PDO's constraint enforcement without sacrificing return; the TRPO curves are used to show that the unconstrained optimal behavior in these environments violates the constraints.
Cost shaping ablation (Figure 3)
- What was tested: In Ant-Circle and Ant-Gather, compliance with the true constraint C-return for CPO with and without cost shaping (CS).
- Results and authors' interpretation: The authors state that cost shaping helps, almost completely offsetting CPO's inherent approximation error; but even without cost shaping, CPO nearly satisfies the constraints.
Constraints vs fixed penalty (Figure 4)
- What was tested: On Ant-Circle, TRPO with a fixed penalty (reward R+λC+, λ∈{1, 5, 50}) compared with CPO.
- Results and authors' interpretation: The authors state that the fixed penalty is sensitive to the coefficient: with λ=1 the policy maximizes return but accumulates large constraint cost, with λ=5 the policy minimizes cost but fails to learn to obtain reward; CPO instead automatically selects the penalty coefficient to achieve the desired trade-off.
Other ablations and analyses
- PDO dual variable learning rate: α=0.001 and 0.01 were tried, the authors state 0.01 performs better, and all reported results use 0.01 (Appendix 10.3.3).
- λGAE_C for the constraint advantage: insensitive in the Point environments, needs to be <1 in high-dimensional environments; searched over {0.5, 0.92, 1} and set to 0.5, the authors state 0.92 is almost as good; without discounting, the constraint gradient magnitude is overestimated, leading to unsafe steps (Appendix 10.3.2).
- Environment parameters: Circle task d and xlim parameters (Point 15/2.5, Ant 10/3, Humanoid 10/2.5); Gather task apple +10, bomb cost 1, Ant-Gather falling −10 (Appendix 10.3.1).
What are some points that can be further explored?
The authors note that the theoretical update step is too small and that approximation error requires a recovery mechanism; the experiments cover only 5 single-constraint simulated environments.
Limitations and future directions noted by the authors
- The theoretically guaranteed update step is too small: Section 5.3 notes that when the discount factor is close to 1, the penalty on policy divergence is too steep and the guaranteed update step may be very small, so CPO instead uses a trust region as a practical approximation.
- Approximation error may lead to constraint violations: Section 6.2 notes that due to approximation error CPO may take bad steps and produce infeasible iterates, requiring a recovery mechanism; Proposition 2 also only gives a worst-case violation upper bound for approximate constraint satisfaction.
- The paper has no dedicated Limitations or Future Work section; the Discussion (Section 9) calls the work "a step towards applying RL in the real world" and does not list specific future directions.
Scope of experimental coverage
- The tested environments are 5 simulated environments designed by the authors: Point-Circle, Ant-Circle, Humanoid-Circle, Point-Gather, Ant-Gather; Humanoid-Gather was not run (Section 8).
- Each environment has only one constraint; multi-constraint cases do not appear in the experiments (Section 8).
- The comparison methods are PDO and TRPO, plus a fixed penalty (λ∈{1,5,50}) comparison and a cost shaping ablation (Sections 8.1–8.3).
- Results are average learning curves over 5 or 10 random seeds (Figure 1 caption); the paper does not report statistical significance tests or wall-clock time per run.
- Evaluation is based on C+-return (the constrained upper-bound cost), with C-return used only for Point-Gather (Section 8.1).
Summarize the main content of the paper
CPO approximates the CMDP policy update as a trust-region convex optimization, and the authors state that it approximately satisfies the safety constraints when training neural network policies.
A training-method paper on safe reinforcement learning: addressing the problems that deep RL policy search does not consider constraints and that existing methods cannot guarantee constraint satisfaction throughout training, the authors propose Constrained Policy Optimization (CPO).
- Theoretical basis: prove a new bound that uses the average divergence between two policies to bound the difference in returns (Theorem 1), which the authors state tightens the existing bounds of Kakade & Langford (2002), Pirotta et al. (2013), and Schulman et al. (2015), and give a per-step performance lower bound for the trust-region update (Proposition 1) and an upper bound on the worst-case constraint violation (Proposition 2).
- Method highlights: within the KL trust region, maximize a linear approximation of the return advantage and constrain the upper bound of the auxiliary cost; after linearizing the objective and constraints, obtain a convex problem and solve it via the dual (with an analytical solution for a single constraint), together with a backtracking line search, a recovery step when infeasible, and cost shaping using a failure prediction network to tighten the constraints.
- Experiments: on 5 simulated environments in total across two task types, Circle and Gather, and three robots, point-mass/ant/humanoid, using a two-layer (64, 32) neural network policy, compared with PDO and TRPO; the results are average learning curves over 5–10 seeds (Figure 1).
- Main results (in the authors' words): CPO approximately satisfies the constraints in all environments, and in Point-Circle and Point-Gather the constraint return tracks the limit almost exactly; PDO satisfies the constraints inconsistently throughout training (e.g., spikes in Ant-Circle) and is sensitive to the initialization of the dual variables; cost shaping almost completely cancels the approximation error; fixed-penalty methods are sensitive to the coefficient (λ=1 and λ=5 behave very differently), whereas CPO automatically adjusts the trade-off.
- Authors' conclusion: CPO can train neural network policies with thousands of parameters, approximately satisfying constraints while maximizing reward, and is a step toward RL for real-world safety applications.