e-COP : Episodic Constrained Optimization of Policies

Authors: akhil  agnihotri
rahul  jain
deepak  ramachandran
sahil  singla
Venue: NeurIPS_cc_2024_Conference
Published: 2024-05-10 20:18:06

Abstract: In this paper, we present the e-COP algorithm, the first policy optimization algorithm for constrained Reinforcement Learning (RL) in episodic (finite horizon) settings. Such formulations are applicable when there are separate sets of optimization criteria and constraints on a system's behavior. We approach this problem by first establishing a policy difference lemma for the episodic setting, which provides the theoretical foundation for the algorithm. Then, we propose to combine a set of established and novel solution ideas to yield the e-COP  algorithm that is easy to implement and numerically stable, and provide a theoretical guarantee on optimality under certain scaling assumptions. Through extensive empirical analysis using benchmarks in the Safety Gym suite, we show that our algorithm has similar or better performance than SoTA (non-episodic) algorithms adapted for the episodic setting. The scalability of the algorithm  opens the door to its application in safety-constrained Reinforcement Learning from Human Feedback for Large Language or Diffusion Models.

Main paper: 
 introduction: 
 RL problems may be formulated in order to satisfy multiple simultaneous objectives. These can include performance objectives that we want to maximize, and physical, operational or other objectives that we wish to constrain rather than maximize. For example, in robotics, we often want to optimize a task completion objective while obeying physical safety constraints. Similarly, in generative AI models, we want to optimize for human preferences while ensuring that the output generations remain safe (expressed perhaps as a threshold on an automatic safety score that penalizes violent or other undesirable content). Scalable policy optimization algorithms such as TRPO [31] , PPO [33] , etc have been central to the achievements of RL over the last decade [34, 38, 7] . In particular, these have found utility in generative models, e.g., in the training of Large Language Models (LLMs) to be aligned to human preferences through the RL with Human Feedback (RLHF) paradigm [2] . But these algorithms are designed primarily for the unconstrained infinite-horizon discounted setting: Their use for constrained problems via optimization of the Lagrangian often gives unsatisfactory constraint satisfaction results. This has prompted development of a number of constrained policy optimization algorithms for the infinite-horizon discounted setting [3, 39, 43, 41, 19, 6, 5] , and for the average setting [4] .However, many RL problems are more accurately formulated as episodic, i.e., having a finite time horizon. For instance, in image diffusion models [10, 21] , the denoising sequence is really a finite step trajectory optimization problem, better suited to be solved via RL algorithms for the episodic setting. When existing algorithms for infinite horizon discounted setting are used for such problem, they exhibit sub-optimal performance or fail to satisfy task-specific constraints by prioritizing short-term constraint satisfaction over episodic goals [11, 28, 17] . Furthermore, the episodic setting allows for objective functions to be time-dependent which the infinite-horizon formulations do not. Even when the objective functions are time-invariant, there is a key difference: for non-episodic settings, a stationary policy that is optimal exists whereas for episodic settings, the optimal policy is always non-stationary and time-dependent. This necessitates development of policy optimization algorithms specifically for the episodic constrained setting. We note that such policy optimization algorithms do not exist even for the unconstrained episodic setting.In this paper, we introduce e-COP, a policy optimization algorithm for episodic constrained RL problems. Inspired by PPO, it uses deep learning-based function approximation, a KL divergence-based proximal trust region and gradient clipping, along with several novel ideas specifically for the finite horizon episodic and constrained setting. The algorithm is based on a technical lemma (Lemma 3.1) on the difference between two policies, which leads to a new loss function for the episodic setting. We also introduce other ideas that obviate the need for matrix inversion thus improving scalability and numerical stability. The resulting algorithm improves performance over state-of-the-art baselines (after adapting them for the episodic setting). In sum, the e-COP algorithm has the following advantages: (i) Solution equivalence: We show that the solution set of our e-COP loss function is same as that of the original CMDP problem, leading to precise cost control during training and avoidance of approximation errors (see Theorem 3.3); (ii) Stable convergence: The e-COP algorithm converges tightly to safe optimal policies without the oscillatory behavior seen in other algorithms like PDO [13] and FOCOPS [43] ; (iii) Easy integration: e-COP follows the skeleton structure of PPO-style algorithms using clipping instead of steady state distribution approximation, and hence can be easily integrated into existing RL pipelines; and (iv) Empiricial performance: the e-COP algorithm demonstrates superior performance on several benchmark problems for constrained optimal control compared to several state-of-the-art baselines.Our Contributions and Novelty. We introduce the first policy optimization algorithm for episodic RL problems, both with and without constraints (no constraints is a special case). While some of the policy optimization algorithms can be adapted for the constrained setting via a Lagrangian formulation, as we show, they don't work so well empirically in terms of constraint satisfaction and optimality. The algorithm is based on a policy difference (technical) lemma, which is novel. We have gotten rid of Hessian matrix inversion, a common feature of policy optimization algorithms (see, for example, PPO [33] , CPO [3] , P3O [41] , etc.) and replaced it with a quadratic penalty term which also improves numerical stability near the edge of the constraint set boundary -a problem unique to constrained RL problems. We provide an instance-dependent hyperparameter tuning routine that generalizes to various testing scenarios. And finally, our extensive empirical results against an extensive suite of baseline algorithms (e.g., adapted PPO [33] , FOCOPS [43] , CPO [3] , PCPO [39] , and P3O [41] ) show that e-COP performs the best or near-best on a range of Safety Gym [12] benchmark problems. Related Work. A broad view of planning and model-free RL techniques for Constrained MDPs is provided in [27] and [18] . The development of SOTA policy optimization started with the TRPO algorithm [31] , which used a trust region to update the current policy, and was further improved in PPO by use of proximal ideas [33] . This led to works like CPO [3] , RCPO [36] , and PCPO [39] for constrained RL problems in the infinite-horizon discounted setting. ACPO [4] extended CPO to the infinite-horizon average setting. These methods typically require inversion of a computationally-expensive Fischer information matrix at each update step, thus limiting scalability. Lagrangian-based algorithms [29, 30] showed that you could incorporate constraints but constrained satisfaction remained a concern. Algorithms like PDO [13] and RCPO [36] also use Lagrangian duality but to solve risk-constrained RL problems and suffer from computational overhead. Some other notable algorithms include IPO [26] , P3O [41] , APPO [15] , etc. that use penalty terms, and hence do not suffer from computational overhead but have other drawbacks. For example, IPO assumes feasible intermediate iterations, which cannot be fulfilled in practice, P3O requires arbritarily large penalty factors for feasibility which can lead to significant estimation errors. We note that all the above algorithms are for the infinite-horizon discounted (non-episodic) setting (except ACPO [4] , which is for the average setting). We are not aware of any policy optimization algorithm for the episodic RL problem, with or without constraints.Question: Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope? Answer: [Yes] Justification: We make claims on developing the theory for episodic policy optimization for CMDPs and on presenting experimental validation of our approach. Please see Sections 3 and 4.Guidelines:• The answer NA means that the abstract and introduction do not include the claims made in the paper. • The abstract and/or introduction should clearly state the claims made, including the contributions made in the paper and important assumptions and limitations. A No or NA answer to this question will not be perceived well by the reviewers. • The claims made should match theoretical and experimental results, and reflect how much the results can be expected to generalize to other settings. • It is fine to include aspirational goals as motivation as long as it is clear that these goals are not attained by the paper. 
preliminaries: 
 An episodic, or fixed horizon Markov decision process (MDP) is a tuple, M :" pS, A, r, P, µ, Hq, where S is the set of states, A is the set of actions, r : S ˆA ˆS Ñ R is the reward function, P : S ˆA ˆS Ñ r0, 1s is the transition probability function such that P ps 1 |s, aq is the probability of transitioning to state s 1 from state s by taking action a, µ : S Ñ r0, 1s is the initial state distribution, and H is the time horizon for each episode (characterized by a terminal state s H ).A policy π : S Ñ ∆pAq is a mapping from states to probability distributions over the actions, with πpa|sq denoting the probability of selecting action a in state s, and ∆pAq is the probability simplex over the action space A. However, due to the temporal nature of episodic RL, the optimal policies are generally not stationary, and we index the policy at time h by π h , and denote π 1:H " pπ h q H h"1 . Then, the total undiscounted reward objective within an episode is defined asJpπ 1:H q :" E τ "π 1:H « H ÿ h"1rps h , a h , s h`1 q ff where τ refers to the sample trajectory ps 1 , a 1 , s 2 , a 2 , . . . , s H q generated when following a policy sequence, i.e., a h " π h p¨|s h q, s h`1 " P p¨|s h , a h q, and s 1 " µ.Let R h:H pτ q denote the total reward of a trajectory τ starting from time h until episode terminal time H generated by following the policy sequence π h:H . We also define the state-value function of a state s at step h as V π h psq :" E τ "π rR h:H pτ q | s h " ss and the action-value function as Q π h ps, aq :" E τ "π rR h:H pτ q | s h " s, a h " as. The advantage function is A π h ps, aq :" Q π h ps, aq ´V π h psq. We also define P π h ps | s 1 q " ř aPA P π h ps, a | s 1 q, where the term P π h ps, a | s 1 q is the probability of reaching ps, aq at time step h following π and starting from s 1 .Constrained MDPs. A constrained Markov decision process (CMDP) is an MDP augmented with constraints that restrict the set of allowable policies for that MDP. Specifically, we have m cost functions, C 1 , ¨¨¨, C m (with each function C i : S ˆA ˆS Ñ R mapping transition tuples to costs, similar to the reward function), and bounds d 1 , ¨¨¨, d m . And similar to the value function for the reward objective, we define the expected total cost objective for each cost function C i (called cost value for the constraint) asJ Ci pπ 1:H q :" E τ "π 1:H « H ÿ h"1 C i ps h , a h , s h`1 q ff .The goal then, in each episode, is to find a policy sequence π ‹ 1:H such that Jpπ ‹ 1:H q :" maxπ 1:H PΠ CJpπ 1:H q, where Π C :" tπ 1:H P Π : J Ci pπ 1:H q ď d i , @ i P r1 : msu (1)is the set of feasible policies for a CMDP for some given class of policies Π. Lastly, analogous to V π h , Q π h , and A π h , we can also define quantities for the cost functions C i p¨q by replacing, and denote them by V π Ci,h , Q π Ci,h , and A π Ci,h . Proofs of theorems and statements, if not given, are available in Appendix A. Notation. rN s denotes t1, . . . , N u for some N P N. π h refers to the policy at time step h within an episode. Denote π s:t :" pπ s , π s`1 , . . . , π t q for some s ď t with s, t P rHs. We shall only write π k,h when it is necessary to differentiate policies from different episodes but at the same time h. It then naturally follows to define π k,s:t to be the sequence π s:t in episode k. We will denote π k " π k,1:H , and where not needed drop the index for the episode so that π " π k .Question: Does the paper discuss the limitations of the work performed by the authors? Answer: [Yes] Justification: While there are no algorithmic limitations, potential limitations can occur while applying our work to very high dimensional real-life scenarios, for instance, in large language models or the denoising process in image and video diffusion tasks. We have developed this work with the above two applications in mind, and plan to explore that direction of future research. Guidelines:• The answer NA means that the paper has no limitation while the answer No means that the paper has limitations, but those are not discussed in the paper. • The authors are encouraged to create a separate "Limitations" section in their paper.• The paper should point out any strong assumptions and how robust the results are to violations of these assumptions (e.g., independence assumptions, noiseless settings, model well-specification, asymptotic approximations only holding locally). The authors should reflect on how these assumptions might be violated in practice and what the implications would be. • The authors should reflect on the scope of the claims made, e.g., if the approach was only tested on a few datasets or with a few runs. In general, empirical results often depend on implicit assumptions, which should be articulated. • The authors should reflect on the factors that influence the performance of the approach. For example, a facial recognition algorithm may perform poorly when image resolution is low or images are taken in low lighting. Or a speech-to-text system might not be used reliably to provide closed captions for online lectures because it fails to handle technical jargon. • The authors should discuss the computational efficiency of the proposed algorithms and how they scale with dataset size. • If applicable, the authors should discuss possible limitations of their approach to address problems of privacy and fairness. • While the authors might fear that complete honesty about limitations might be used by reviewers as grounds for rejection, a worse outcome might be that reviewers discover limitations that aren't acknowledged in the paper. The authors should use their best judgment and recognize that individual actions in favor of transparency play an important role in developing norms that preserve the integrity of the community. Reviewers will be specifically instructed to not penalize honesty concerning limitations. 
episodic constrained optimization of policies (e-cop): 
 In this section, we propose a constrained policy optimization algorithm for episodic MDPs. Policy optimization algorithms for MDPs have proven remarkably effective given their ability to computationally scale up to high dimensional continuous state and action spaces [31] [32] [33] . Such algorithms have also been proposed for infinite-horizon constrained MDPs with discounted criterion [1] as well as the average criterion [4] but not for the finite horizon (or as it is often called, the episodic) setting.We note that finite horizon is not simply a special case of infinite-horizon discounted setting since the reward/cost functions in the former can be time-varying while the latter only allows for time-invariant objectives. Furthermore, even with time-invariant objectives, the optimal policy is time-dependent, while for the latter setting there an optimal policy that is stationary exists.A Policy Difference Lemma for Episodic MDPs. Most policy optimization RL algorithms are based on a value or policy difference technical lemma [23] . Unfortunately, the policy difference lemmas that have been derived previously for the infinite-horizon discounted [31] and average case [4] are not applicable here and hence, we derive a new policy difference lemma for the episodic setting. Lemma 3.1. For an episode of length H and two policies, π and π 1 , the difference in their performance assuming identical initial state distribution µ (i.e., s 1 " µ) is given byEQUATIONThe proof can be found in Appendix A.1. A key difference to note between the above and similar results for infinite-horizon settings [31, 4] is that considering stationary policies (and hence corresponding occupation measures) is not enough for the episodic setting since, in general, such a policy may be far from optimal. This explains why Lemma 3.1 looks so different (e.g., see (2) in [31] , and Lemma 3.1 in [4] ). Indeed, the lemma above indicates that policy updates do not have to recurse backwards from the terminal time as dynamic programming algorithms do for episodic settings, which is somewhat surprising.A Constrained Policy Optimization Algorithm for Episodic MDPs. Iterative policy optimization algorithms achieve state of the art performance [33, 36, 39] on RL problems. Most such algorithms maximize the advantage function based on a suitable policy difference lemma, solving an unconstrained RL problem. Some additionally ensure satisfaction of infinite horizon expectation constraints [3, 4] . However, given that our policy lemma for the episodic setting (Lemma 3. EQUATIONend for8: Set π k Ð ´π‹ k,1 , π ‹ k,2 , . . . , π ‹ k,H¯.The iterative constrained policy optimization algorithm introduced above uses the current iterate of the policy π k to collect a trajectory τ , and use them to evaluate Aπ k´1 h and A π k´1Ci,h for h P rHs. At the end of the episode, we solve H optimization problems (one for each h P rHs) that result in a new sequence of policies π. As is natural in episodic problems, we do backward iteration in time, i.e., solve the problem in step (6) at h " H, and then go backwards towards h " 1.Note that the expectation of advantage functions in equation ( 3) is with respect to the policy π (the optimization variable) and its corresponding time-dependent state occupation distribution ρ π h . In the infinite-horizon settings, the expectation is with respect to the steady state stationary distribution, but that does not exist in the episodic setting.Using current policy for action selection. Algorithm 1 represents an exact principled solution tothe constrained episodic MDP, but the intractable optimization performed in (3) makes it impractical (as in the case of infinite horizon policy optimization algorithms [31, 3, 39] ). We proceed to introduce a sequence of ideas that make the algorithm practical (e.g., by avoiding computationally expensive Hessian matrix inversion for use with trust-region methods [33, 14, 41] ). However, getting rid of trust regions leads to large updates on policies, but PPO [33] and P3O [41] successfully overcome this problem by clipping the advantage function and adding a ReLU-like penalty term to the minimization objective. Motivated by this, we rewrite the optimization problem in (3) where ρpθ h q "π θ k,h π θ k´1,his the importance sampling ratio, λ t,i is a penalty factor for constraint C i , and π k,θ h " π k,h " θ k,h . Note that the ReLU-like penalty term above is different from the traditional first-order and second-order gradient approximations that are employed in trust-region methods [3, 39] . In essence, the penalty is applied when the agent breaches the associated constraint, while the objective remains consistent with standard policy optimization when all constraints are satisfied.Introducing quadratic damping penalty. It has been noted in such iterative policy optimization algorithms that the behaviour of the learning agent when it nears the constraint threshold is quite volatile during training [3, 39, 42] . This is because the penalty term is active only when the constraints are violated which results in sharp behavior change for the agent. To alleviate this problem, we introduce an additional quadratic damping term to the objective above, which provides stable cost control to compliment the lagged Lagrangian multipliers. This has proved effective in physics-based control applications [16, 25, 20] resulting in improved convergence since the damping term provides stability, while keeping the solution set the same as for the original Problem (3) and the adapted Problem (4) (as we prove later).For brevity, we denote the constraint term in Problem (4) asΨ Ci,t pπ k´1 , π k q :" ř H h"t E s"ρπ k,h a"π k´1,h " ρpθ h qA π k´1Ci,h ps, aq ‰ `JCi pπ k´1 q ´di . Now introduce a slack variable x t,i ě 0 for each constraint to convert the inequality constraint (Ψ Ci,t p¨, ¨q ď 0) to equality by letting w t,i pπ k q :" Ψ Ci,t pπ k´1 , π k q `xt,i " 0.With this notation, we restate Problem (4) as:π ‹ k,t " min πk,t L t pπ k , λq :" ř H h"t E s"ρπ k,h a"πk´1,h " ´ρpθ h qA πk´1 h ps, aq ‰ `řm i λ t,i maxt0, Ψ Ci,t pπ k´1 , π k qu.Now we introduce the quadratic damping term and the intermediate loss function then takes the form,EQUATIONwhere β is the damping factor, λ t " pλ t,i q m i"1 , and x t " px t,i q m i"1 . We can then construct a primal-dual solution to the max-min optimization problem. The need for a slack variable x can be obviated by setting the partial derivative of L t p¨q with respect to x equal to 0. This leads to a ReLU-like solution: x ‹ t,i " max `0, ´ΨCi,t pπ k´1 , π k q ´λt,i β ˘. The intermediate problem then takes the form as below. Proposition 3.2. The inner optimization problem in (5) with respect to x is a convex quadratic program with non-negative constraints, which can be solved to yield the following intermediate problem:EQUATION)The proof can be found in Appendix A.1. One can see that the cost penalty is active when Ψ Ci,t pπ k´1 , π k q ě ´λt,i β rather than when Ψ Ci,t pπ k´1 , π k q ě 0. This allows the agent to act in a constrained manner even before the constraint is violated. Further, as we show next, the introduction of the damping factor and the RELU-like penalty does not change the solution of the problem (under some suitable assumptions): Theorem 3.3. Let π (3) ‹ be a solution to Problem (3), and let `π(6) ‹ , λ (6) ‹ ˘be a solution to Problem (6). Then, for sufficiently large β ą β and λ t,i ą λ @ i, π (3) ‹ is a solution to Problem (6), and π (6) ‹ is a solution to Problem (3).We refer the reader to Appendix A.1 for the proof. This theorem implies that we can search for the optimal feasible policies of the CMDP Problem (1) by iteratively solving Problem (6) . Next, we make some further modifications to Problem (6) that give us our final tractable algorithm.Removing Lagrange multiplier dependency. Problem (6) requires a primal-dual algorithm that will iteratively solve over the policies and the dual variable λ. But from the Lagrangian, we can actually take a derivative with respect to λ, and then solve for it, which yields the following update rule for it:EQUATIONThis update rule simplifies the optimization problem and updates the Lagrange multipliers in the kth episode based on the constraint violation in the pk ´1qth episode.Clipping the advantage functions. Solving the optimization problem presented in equation ( 6) is intractable since we do not know ρ π beforehand. Hence, we replace ρ π by the empirical distribution observed with the policy of the previous episode, π k´1 , i.e., ρ π k,h « ρ π k´1,h @ h. Similar to [33] for PPO, we also use clipped surrogate objective functions for both the reward and cost advantage functions. Thus, the final problem combining equation ( 4) and equation ( 6) can be constructed as follows.If we letL t pθq " H ÿ h"t E s"ρπ k´1,h a"πk´1,h " ´min ␣ ρpθ h qA πk´1 h ps, aq, clippρpθ h q, 1 ´ϵ, 1 `ϵqA πk´1 hps, aq (‰ and,L Ci,t pθq " H ÿ h"t E s"ρπ k´1,h a"πk´1,h " ´min ␣ ρpθ h qA πk´1 Ci,h ps, aq, clippρpθ h q, 1 ´ϵ, 1 `ϵqA πk´1 Ci,h ps, aq (‰then, the final loss function r L t p¨q of the final problem is:π ‹ k,t " arg min πk,t r L t pπ θ , λ, βq :" arg min πk,t L t pθq `m ÿ i λ t,i max ␣ 0, L Ci,t pθq ``J Ci pπ k´1 q ´di ˘( `β 2 m ÿ i ˆmax " 0, L Ci,t pθq ``J Ci pπ k´1 q ´di ˘`λ t,i β * 2 ´λ2 t,i β 2 ˙(8)Usually for experiments, Gaussian policies with means and variances predicted from neural networks are used [31, 3, 33, 39] . We employ the same approach and since we work in the finite horizon setting, the reward and constraint advantage functions can easily be calculated from any trajectory τ " π. The surrogate problem in equation ( 8) then includes the pessimistic bounds on Problem (6) , which is unclipped.Adaptive parameter selection. The value of β is required to be larger than the unknown β according to Theorem 3.3, but we also know that too large a β decays the performance (as seen in harmonic oscillator kinetic energy formulations [25, 20, 40] ). To manage this tradeoff, we provide an instance-dependent adaptive way to adjust the damping factor as a hyperparameter. In each episode k, we update the damping parameter whenever a secondary constraint cost value denoted by Cpπ k q is larger than some threshold c k . Using Proposition 3.2, we provide the following definitions.Cpπ k q :" H ÿ t"1 m ÿ i max " J Ci pπ k q ´di , ´λpkq t,i β * and c k :" ? m β ¨max tPrHs › › λ pkq t › › 8 Algorithm 2 Episodic Constrained Optimization of Policies (e-COP)1: Input: Initial policy θ 0 :" π 0 :" π θ0 , critic networks V ϕ0 and V ψ0 Ci @ i, penalty factor β, number of episodes K, episode horizon H, learning rate α, penalty update factor p.2: for k " 1, 2, . . . , K do 3:Collect a set of trajectories D k´1 with policy π k´1 and update the critic network.Get updated λ pkq using equation (7).for t " H, H ´1, . . . , 1 doUpdate the policy θ k,t Ð θ k,t`1 ´α∇ θ r L t pθ, λ pkq , βq using equation (8).end for 8:if Cpθ k q ě c k then 9:β " minpβ max , pβq Hence, we increase β by a constant factor p ą 1 after every episode if Cpπ k q ě c k until a stopping condition is fulfilled, typically a constant β max . This leads to constraint-satisfying iterations that are more stable, and we show that it enables a fixed β to generalize well across various tasks. The initial β can simply be selected by a quantified line-search to obtain a feasible β ą β [3, 4] .We note that the final loss function in equation ( 8) is differentiable almost everywhere, so we could easily solve it via any first-order optimizer [24] . The final practical algorithm, e-COP is given in Algorithm 2.Question: For each theoretical result, does the paper provide the full set of assumptions and a complete (and correct) proof?Answer: [Yes] Justification: All our lemmas and theorems have proofs, some which are available in the main text, and some in Appendix A. Guidelines:• The answer NA means that the paper does not include theoretical results.• All the theorems, formulas, and proofs in the paper should be numbered and crossreferenced. • All assumptions should be clearly stated or referenced in the statement of any theorems.• The proofs can either appear in the main paper or the supplemental material, but if they appear in the supplemental material, the authors are encouraged to provide a short proof sketch to provide intuition. • Inversely, any informal proof provided in the core of the paper should be complemented by formal proofs provided in appendix or supplemental material. • Theorems and Lemmas that the proof relies upon should be properly referenced. 
experiments: 
 We conducted extensive experimental evaluation on the relative empirical performance of the e-COP algorithm to arrive at the following conclusions: (i) The e-COP algorithm performs better or nearly as well as all baseline algorithms for infinite-horizon discounted safe RL tasks in maximizing episodic return while satisfying given constraints. (ii) It is more robust to stochastic and complex environments [30] , even where previous methods struggle. (iii) It has stable behavior and more accurate cost control as compared to other baselines near the constraint threshold due to the damping term.Environments. For a comprehensive empirical evaluation, we selected eight scenarios from wellknown safe RL benchmark environments -Safe MuJoCo [43] and Safety Gym [30] , as well as MuJoCo environments. These include: Humanoid, PointCircle, AntCircle, PointReach, AntReach, Grid, Bottleneck, and Navigation. See Figure 1 for an overview of the tasks and scenarios. Note that Navigation is a multi-constraint task and for the Reach environment, we set the reward as a function of the Euclidean distance between agent's position and goal position. In addition, we make it impossible for the agent to reach the goal before the end of the episode. For more information see Appendix A.2.1.Baselines. We compare our e-COP algorithm with the following baseline algorithms: CPO [3] , PCPO [39] , FOCOPS [43] , PPO with Lagrangian relaxation [33, 35] , and penalty-based P3O [41] . Since the above state-of-the-art baseline algorithms are already well understood to outperform other algorithms such as PDO [13] , IPO [26] , and CPPO-PID [35] in prior benchmarking studies, we do not compare against them. Moreover, since PPO does not originally incorporate constraints, for fair comparison, we introduce constraints using a Lagrangian relaxation (called PPO-L). In addition, for each algorithm, we report its performance with the discount factor that achieves the best performance. See Appendix A.3.1 for more details.Evaluation Details and Protocol. For the Circle task, we use a a point-mass with S Ď R 9 , A Ď R 2 and for the Reach task, an ant robot with S Ď R 16 , A Ď R 8 . The Grid task has S Ď R 56 , A Ď R 4 . We use two hidden layer neural networks to represent Gaussian policies for the tasks. For Circle and Reach, size is (32, 32) for both layers, and for Grid and Navigation the layer sizes are (16, 16) and (25, 25) . We set the step size δ to 10 ´4, and for each task, we conduct 5 independent runs of K " 500 episodes each of horizon H " 200. Since there are two objectives (rewards in the objective and costs in the constraints), we show the plots which maximize the reward objective while satisfying the cost constraint.Table 1 lists the numerical performance of all tested algorithms in seven single constraint scenarios, and one multiple constraint scenario. We find that overall, the e-COP algorithm in most cases outperforms (green) all other baseline algorithms in finding the optimal policy while satisfying the constraints, and in other cases comes a close second (light green).From Figure 2 , we can see how the e-COP algorithm is able to improve the reward objective over the baselines while having approximate constraint satisfaction. We also see that updates of e-COP are faster and smoother than other baselines due to the added damping penalty, which ensures smoother convergence with only a few constraint-violating behaviors during training. In particular, e-COP is the only algorithm that best learns almost-constraint-satisfying maximum reward policies across all tasks: in simple Humanoid and Circle environments, e-COP is able to almost exactly track the cost constraint values to within the given threshold. However, for the high dimensional Grid environment we have more constraint violations due to complexity of the policy behavior, leading to higher variance in episodic rewards as compared to other environments. Regardless, overall in these environments, e-COP still outperforms all other baselines with the least episodic constraint violation. For the multiple constraint Navigation environment, see Figure 3 .In this section, we take a deeper dive into the empirical performance of e-COP. We discuss its dependence on various factors, and try to verify its merits.Generalizability. From the discussion above, it's clear that e-COP demonstrates accurate safety satisfaction across tasks of varying difficulty levels. From Figure 4 , we further see that e-COP satisfies the constraints in all cases and precisely converges to the specified cost limit. Furthermore, the fluctuation observed in the baseline Lagrangian-based algorithms is shown not to be tied to a specific cost limit.We also conducted a set of experiments wherein we study how e-COP effectively adapts to different cost thresholds. For this, we use the hyperparameters of a pre-trained e-COP agent, which is trained with a particular cost threshold in an environment, for learning on different cost thresholds within the same environment. Figure 6 Sensitivity. The effectiveness and performance of e-COP would not be justified if it was not robust to the damping hyperparameter β, which varies across tasks depending on the values of Cp¨q and c h . Since this damping penalty enables e-COP to have stable continuous cost control, we update it adaptively as described in Algorithm 2. As seen in Table 2 , damping penalty indeed stabilizes the training process and helps in converging to an optimal safe policy.Question: Does the paper fully disclose all the information needed to reproduce the main experimental results of the paper to the extent that it affects the main claims and/or conclusions of the paper (regardless of whether the code and data are provided or not)? Answer: [Yes] Justification: We provide the evaluation protocol and baseline comparison metrics in Section 4. More information is also available in Appendix A.2. Guidelines:• The answer NA means that the paper does not include experiments.• If the paper includes experiments, a No answer to this question will not be perceived well by the reviewers: Making the paper reproducible is important, regardless of whether the code and data are provided or not. • If the contribution is a dataset and/or model, the authors should describe the steps taken to make their results reproducible or verifiable. • Depending on the contribution, reproducibility can be accomplished in various ways. For example, if the contribution is a novel architecture, describing the architecture fully might suffice, or if the contribution is a specific model and empirical evaluation, it may be necessary to either make it possible for others to replicate the model with the same dataset, or provide access to the model. In general. releasing code and data is often one good way to accomplish this, but reproducibility can also be provided via detailed instructions for how to replicate the results, access to a hosted model (e.g., in the case of a large language model), releasing of a model checkpoint, or other means that are appropriate to the research performed. • While NeurIPS does not require releasing code, the conference does require all submissions to provide some reasonable avenue for reproducibility, which may depend on the nature of the contribution. , with an open-source dataset or instructions for how to construct the dataset). (d) We recognize that reproducibility may be tricky in some cases, in which case authors are welcome to describe the particular way they provide for reproducibility. In the case of closed-source models, it may be that access to the model is limited in some way (e.g., to registered users), but it should be possible for other researchers to have some path to reproducing or verifying the results. 
conclusion: 
 In this paper, we have introduced an easy to implement, scalable policy optimization algorithm for episodic RL problems with constraints due to safety or other considerations. It is based on a policy difference lemma for the episodic setting, which surprisingly has quite a different form than the ones for infinitehorizon discounted or average settings. This provides the theoretical foundation for the algorithm, which is designed by incorporating several time-tested, practical as well as novel ideas. Policy optimization algorithms for Constrained MDPs tend to be numerical unstable and non-scalable due to the need for inverting the Fisher information matrix. We sidestep both of these issues by introducing a quadratic damping penalty term that works remarkably well. The algorithm development is well supported by theory, as well as with extensive empirical analysis on a range of Safety Gym and Safe MuJoco benchmark environments against a suite of baseline algorithms adapted from their non-episodic roots.Question: Does the paper provide open access to the data and code, with sufficient instructions to faithfully reproduce the main experimental results, as described in supplemental material? Answer: [Yes] Justification: We have provided the code. 
experimental setting/details: 
 Question: Does the paper specify all the training and test details (e.g., data splits, hyperparameters, how they were chosen, type of optimizer, etc.) necessary to understand the results?Answer: [Yes]Justification: We detail our experimental procedure and details in Sections 4 and A.2.Guidelines:• The answer NA means that the paper does not include experiments.• The experimental setting should be presented in the core of the paper to a level of detail that is necessary to appreciate the results and make sense of them. • The full details can be provided either with the code, in appendix, or as supplemental material. 
experiment statistical significance: 
 Question: Does the paper report error bars suitably and correctly defined or other appropriate information about the statistical significance of the experiments?Answer: [Yes] Justification: All our results are reported with 1 standard deviation across multiple seeds. Please see Section 4.Guidelines:• The answer NA means that the paper does not include experiments.• The authors should answer "Yes" if the results are accompanied by error bars, confidence intervals, or statistical significance tests, at least for the experiments that support the main claims of the paper. • The factors of variability that the error bars are capturing should be clearly stated (for example, train/test split, initialization, random drawing of some parameter, or overall run with given experimental conditions). • The method for calculating the error bars should be explained (closed form formula, call to a library function, bootstrap, etc.) • The assumptions made should be given (e.g., Normally distributed errors).• It should be clear whether the error bar is the standard deviation or the standard error of the mean. • It is OK to report 1-sigma error bars, but one should state it. The authors should preferably report a 2-sigma error bar than state that they have a 96% CI, if the hypothesis of Normality of errors is not verified. • For asymmetric distributions, the authors should be careful not to show in tables or figures symmetric error bars that would yield results that are out of range (e.g. negative error rates). • If error bars are reported in tables or plots, The authors should explain in the text how they were calculated and reference the corresponding figures or tables in the text. 
experiments compute resources: 
 Question: For each experiment, does the paper provide sufficient information on the computer resources (type of compute workers, memory, time of execution) needed to reproduce the experiments?Answer: [Yes] Justification: In Section A.2 we detail the compute resources used.Guidelines:• The answer NA means that the paper does not include experiments.• The paper should indicate the type of compute workers CPU or GPU, internal cluster, or cloud provider, including relevant memory and storage. • The paper should provide the amount of compute required for each of the individual experimental runs as well as estimate the total compute. • The paper should disclose whether the full research project required more compute than the experiments reported in the paper (e.g., preliminary or failed experiments that didn't make it into the paper). 
code of ethics: 
 Question: Does the research conducted in the paper conform, in every respect, with the NeurIPS Code of Ethics https://neurips.cc/public/EthicsGuidelines? 
broader impacts: 
 Question: Does the paper discuss both potential positive societal impacts and negative societal impacts of the work performed?Answer: [Yes]Justification: In the Introduction Section 1 we detail the potential applications of our work.Guidelines:• The answer NA means that there is no societal impact of the work performed.• If the authors answer NA or No, they should explain why their work has no societal impact or why the paper does not address societal impact. • Examples of negative societal impacts include potential malicious or unintended uses (e.g., disinformation, generating fake profiles, surveillance), fairness considerations (e.g., deployment of technologies that could make decisions that unfairly impact specific groups), privacy considerations, and security considerations. • The conference expects that many papers will be foundational research and not tied to particular applications, let alone deployments. However, if there is a direct path to any negative applications, the authors should point it out. For example, it is legitimate to point out that an improvement in the quality of generative models could be used to generate deepfakes for disinformation. On the other hand, it is not needed to point out that a generic algorithm for optimizing neural networks could enable people to train models that generate Deepfakes faster. • The authors should consider possible harms that could arise when the technology is being used as intended and functioning correctly, harms that could arise when the technology is being used as intended but gives incorrect results, and harms following from (intentional or unintentional) misuse of the technology. • If there are negative societal impacts, the authors could also discuss possible mitigation strategies (e.g., gated release of models, providing defenses in addition to attacks, mechanisms for monitoring misuse, mechanisms to monitor how a system learns from feedback over time, improving the efficiency and accessibility of ML). 
safeguards: 
 Question: Does the paper describe safeguards that have been put in place for responsible release of data or models that have a high risk for misuse (e.g., pretrained language models, image generators, or scraped datasets)?Answer: [NA] Justification: Our work needs no such safeguards for responsible release of assets.Guidelines:• The answer NA means that the paper poses no such risks.• Released models that have a high risk for misuse or dual-use should be released with necessary safeguards to allow for controlled use of the model, for example by requiring that users adhere to usage guidelines or restrictions to access the model or implementing safety filters. • Datasets that have been scraped from the Internet could pose safety risks. The authors should describe how they avoided releasing unsafe images. • We recognize that providing effective safeguards is challenging, and many papers do not require this, but we encourage authors to take this into account and make a best faith effort.12. Licenses for existing assets Question: Are the creators or original owners of assets (e.g., code, data, models), used in the paper, properly credited and are the license and terms of use explicitly mentioned and properly respected?Answer: [NA] Justification: We do not use existing assets. Proper references for existing results and algorithms are provided throughout the main text.Guidelines:• The answer NA means that the paper does not use existing assets.• The authors should cite the original paper that produced the code package or dataset.• The authors should state which version of the asset is used and, if possible, include a URL.• The name of the license (e.g., CC-BY 4.0) should be included for each asset.• For scraped data from a particular source (e.g., website), the copyright and terms of service of that source should be provided. • If assets are released, the license, copyright information, and terms of use in the package should be provided. For popular datasets, paperswithcode.com/datasets has curated licenses for some datasets. Their licensing guide can help determine the license of a dataset. • For existing datasets that are re-packaged, both the original license and the license of the derived asset (if it has changed) should be provided. • If this information is not available online, the authors are encouraged to reach out to the asset's creators. 
new assets: 
 Question: Are new assets introduced in the paper well documented and is the documentation provided alongside the assets?Answer: [NA] Justification: We do not release new assets. Our results, both theoretical, algorithmic, and empirical, are properly referenced and explained in the main text. Guidelines:• The answer NA means that the paper does not release new assets.• Researchers should communicate the details of the dataset/code/model as part of their submissions via structured templates. This includes details about training, license, limitations, etc. • The paper should discuss whether and how consent was obtained from people whose asset is used. • We recognize that the procedures for this may vary significantly between institutions and locations, and we expect authors to adhere to the NeurIPS Code of Ethics and the guidelines for their institution. • For initial submissions, do not include any information that would break anonymity (if applicable), such as the institution conducting the review. 
 
 Appendix: A.1 Proofs Lemma A.1. For an episode of length H and two policies, π and π 1 , the difference in their performance assuming identical initial state distribution µ (i.e., s 1 " µ) is given byEQUATIONProof. Let us consider s 1 " µ and categorize the value function difference between the two policies. Also define P π h ps | s 1 q " ř aPA P π h ps, a | s 1 q, where the term P π h ps, a | s 1 q is the probability of reaching ps, aq at time step h following π and starting from s 1 .V π 1 ps 1 q ´V π 1 1 ps 1 q " E a1,s2 " rps 1 , a 1 q `V π 2 ps 2 q|s 1 ‰ `E s2 " V π 1 2 ps 2 q ´V π 1 2 ps 2 q|s 1 ‰ ´V π 1 1 ps 1 q " E s2 " V π 2 ps 2 q ´V π 1 2 ps 2 q|s 1 ‰ `E a1,s2 " rps 1 , a 1 q `V π 1 2 ps 2 q ´V π 1 1 ps 1 q|s 1 ‰ " E s2 " V π 2 ps 2 q ´V π 1 2 ps 2 q|s 1 ‰ `E a1 " Q π 1 1 ps 1 , a 1 q ´V π 1 1 ps 1 q|s 1 ‰ " E s2 " V π 2 ps 2 q ´V π 1 2 ps 2 q|s 1 ‰ `E a1 " A π 1 1 ps 1 , a 1 q|s 1 ‰ ,where a 1 " π 1 p¨|s 1 q, s 2 " P p¨|s 1 , π 1 ps 1 qq and s 1 " µ, the initial state distribution.Now recursively apply the same procedure to the term V π h ps h q ´V π 1 h ps h q @ h P t2, . . . , Hu to obtain the following:V π 1 psq ´V π 1 1 psq " H ÿ h"1 E s h ,a h "P π h p¨,¨| sq " A π 1 h ps h , a h q|s ‰ Now we know that Jpπq " E s"µrV π 1 psqs, this means that we combine this with the above to obtain the final result.Proposition A.2. The inner optimization problem in (5) with respect to x is a convex quadratic program with non-negative constraints, which can be solved to yield the following intermediate problem:EQUATIONProof. As in Equation ( 4), we have the following equivalent problem:π ‹ k,t " arg min πk,t H ÿ h"t E s"ρπ k,h a"πk´1,h " ´ρpθ h qA πk´1 h ps, aq ‰ `m ÿ i λ t,i max " 0, H ÿ h"t E s"ρπ k,h a"πk´1,h " ρpθ h qA πk´1 Ci,h ps, aq ‰ `pJ Ci pπ k´1 q ´di q * . Letting Ψ Ci,t pπ k´1 , π k q :" ř H h"t E s"ρπ k,h a"π k´1,h " ρpθ h qA π k´1Ci,h ps, aq ‰ `pJ Ci pπ k´1 q ´di q, and introducing slack variables x t,i ě 0 and defining w t,i pπ k q :" Ψ Ci,t pπ k´1 , π k q `xt,i " 0, we get the quadratic damped problem same as Equation ( 5) below.EQUATIONLike the Lagrangian method, we can alternately update π, λ, and x to find the optimal triplet. Consider updating π and x by minimizing L t pπ, λ, x, βq at any iteration:`π‹ k,t , x ‹ t ˘" arg min πk,t min xią0 H ÿ h"t E s"ρπ k,h a"πk´1,h " ´ρpθ h qA πk´1 h ps, aq ‰ `m ÿ i"1 λ t,i `ΨCi,t pπ k´1 , π k q `xt,i ˘`β 2 m ÿ i"1`ΨCi,t pπ k´1 , π k q `xt,i ˘2The inner optimization problem with respect to x is a convex quadratic programming problem with non-negative constraints,EQUATIONThe optimal solution is x ‹ t,i " max ! 0, ´λt,i β ´ΨCi,t pπ k´1 , π k q) . Then,EQUATIONSubstituting back into Equation ( 9), we getL t pπ k , λ, x, βq " H ÿ h"t E s"ρπ k,h a"πk´1,h " ´ρpθ h qA πk´1 h ps, aq ‰ `m ÿ i λ t,i w t,i pπ k q `β 2 m ÿ i w 2 t,i pπ k q " H ÿ h"t E s"ρπ k,h a"πk´1,h " ´ρpθ h qA πk´1 h ps, aq ‰ `m ÿ i"1 λ t,i ˆmax " 0, λ t,i β `ΨCi,t pπ k´1 , π k q * ´λt,i β β 2 m ÿ i"1 ˆmax " 0, λ t,i β `ΨCi,t pπ k´1 , π k q * ´λt,i β ˙2 " H ÿ h"t E s"ρπ k,h a"πk´1,h " ´ρpθ h qA πk´1 h ps, aq ‰ `β 2 m ÿ i"1 ˜max " 0, λ t,i β `ΨCi,t pπ k´1 , π k q * 2 ´λ2 t,i β 2Ḩence, we finally getpπ ‹ k,t , λ ‹ t q " max λě0 min πk,t L t pπ k , λ, βq " max λě0 min πk,t H ÿ h"t E s"ρπ k,h a"πk´1,h " ´ρpθ h qA πk´1 h ps, aq ‰ `β 2 m ÿ i"1 ˆmax " 0, Ψ Ci,t pπ k´1 , π k q `λt,i β * 2 ´λ2 t,i β 2Lemma A.3. Consider two problems, Problem (P) and Problem (Q) below. For sufficiently large λ i ą λ @ i and β ą β for some finite λ and finite β, the optimal solution set of Problem (Q) (equivalent version of Problem (6)) is identical to the optimal solution set of Problem (P).Problem (P) :EQUATION, where x `:" maxp0, xq, andΨ Ci,t pπ k´1 , π k , θq :" H ÿ h"t E s"ρπ k,h a"π k´1,h " ρpθ h qA π k´1Ci,h ps, aq ‰ `pJ Ci pπ k´1 q ´di q.Proof. This proof uses some ideas given in [41] for Part 1 below.Part 1 -Solution of Problem (P) is solution of Problem (Q).Suppose θt is the optimum of the constrained Problem (P) augmented with the quadratic penalty. Let λt be the corresponding Lagrange multiplier vector for its dual problem, and β be the additive quadratic penalty coefficient. Then for λ t,i ě || λ|| 8 @ i and β ě || β|| 8 , θ is also a minimizer of its ReLU-penalized optimization Problem (Q) as below. Let Ωpθ t q :" řH h"t E s"ρπ k,h a"π k´1,h " ´ρpθ h qA π k´1 hps, aq ‰ . Then it follows that:Ωpθ t q `m ÿ i λ t,i Ψ Ci,t pπ k´1 , π k , θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π k , θq 2 ě Ωpθ t q `m ÿ i λi Ψ Ci,t pπ k´1 , π k , θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π k , θq 2 ě Ωpθ t q `m ÿ i λi Ψ Ci,t pπ k´1 , π k , θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π k , θq 2By assumption, θt is a Karush-Kuhn-Tucker point in the constrained Problem (P), at which KKT conditions are satisfied with the Lagrange multiplier vector λ and β. We then have:Ωpθ t q `m ÿ i λi Ψ Ci,t pπ k´1 , π k , θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π k , θq 2 ě Ωp θt q `m ÿ i λi Ψ Ci,t pπ k´1 , π k , θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π, θq 2 " Ωp θt q `m ÿ i λi Ψ Ci,t pπ k´1 , π k , θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π k , θq 2 " Ωp θt q `m ÿ i λ t,i Ψ Ci,t pπ k´1 , π k , θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π k , θq 2, where the first line holds because θt minimizes the Lagrange function, and the second line is derived from the complementary slackness. Thus, we conclude that for the objective function of Problem (Q), call it L Q pθ t q, we have L Q pθ t q ě L Q p θt q for all θ t P Θ, which means θt is a minimizer of the quadratic damped optimization Problem (Q).Part 2 -Solution of Problem (Q) is solution of Problem (P).Let r θ t be an optimal point of the quadratic damped Problem (Q), with θt and λ being the same as defined above. Then, if r θ t is in the set of feasible solutions S feasible " tθ | Ψ Ci,t pπ k´1 , π k , θq ď 0 @ iu, we have:Ωp r θ t q " Ωp r θ t q `m ÿ i λ t,i Ψ Ci,t pπ k´1 , π k , r θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π k , r θq ď Ωpθ t q `m ÿ i λ t,i Ψ Ci,t pπ k´1 , π k , θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π k , θq " Ωpθ t qThe inequality above indicates r θ t is also optimal in the constrained Problem (P). Now, if r θ is not feasible, we have:Ωp θt q `m ÿ i λ t,i Ψ Ci,t pπ k´1 , π k , θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π k , θq 2 " Ωp θt q `m ÿ i λi Ψ Ci,t pπ k´1 , π k , θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π k , θq 2 " Ωp θt q `m ÿ i λi Ψ Ci,t pπ k´1 , π k , θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π k , θq 2 ď Ωp r θ t q `m ÿ i λi Ψ Ci,t pπ k´1 , π k , r θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π k , r θq 2 ď Ωp r θ t q `m ÿ i λi Ψ Ci,t pπ k´1 , π k , r θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π k , r θq 2 ď Ωp r θ t q `m ÿ i λ t,i Ψ Ci,t pπ k´1 , π k , r θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π k , r θq 2, which is a contradiction to the assumption that r θ t is a minimizer of the penalized optimization Problem (Q). Thus, r θ t can only be the feasible optimal solution for Problem (P).Lemma A.4. Consider two problems, Problem (P') and Problem (R). For sufficiently large β ą β for some finite β, the feasible optimal solution set of Problem (R) (equivalent version of Problem (3)) is identical to the solution set of Problem (P').Problem (P') :L P 1 t pπ k , λ, x, βq :" H ÿ h"t E s"ρπ k,h a"π k´1,h " ´ρpθ h qA π k´1 h ps, aq ‰ `m ÿ i λ t,i w t,i pπ k q `β 2 m ÿ i w 2 t,i pπ k q Then, pπ ‹ k,t , λ ‹ t , x ‹ t q " max λě0 min π k,t ,x L P 1 t pπ k , λ, x, βq (P') Problem (R) : L R t pπ k , λ, xq :" H ÿ h"t E s"ρπ k,h a"π k´1,h " ´ρpθ h qA π k´1 h ps, aq ‰ `m ÿ i λ t,i w t,i pπ k q Then, pπ ‹ k,t , λ ‹ t , x ‹ t q " max λě0 min π k,t ,x L R t pπ k , λ, xq (R)Proof. Recall that we are using parameterized policies, hence we overload notation as θ " π frequently. For brevity, denote Ω t pπq :"ř H h"t E s"ρπ k,h a"π k´1,h " ρpθ h qA π k´1 hps, aq ‰ . We will also go back and forth between the equivalent problems of Problem (P') and Problem (6) of the main paper in Section 3.Suppose that π ‹ is the optimal feasible policy for the primal Problem (R), which is a Lagrangian version of Problem (3) . Consider the corresponding Langrangian dual parameter λ ‹ of π ‹ , which satisfies the KKT conditon,∇ π L R t `π‹ k,t , λ ‹ , x ‹ ˘" ´∇π Ω t `π‹ k,t ˘`m ÿ i"1 λ * t,i ∇ π w t,i pπ ‹ k q " 0and the second-order sufficient condition that for all non-zero vectors u that satisfy u T ∇ π w t,i pπ ‹ k q " 0 , we haveu T ∇ 2 π L R t `π‹ k,t , λ ‹ , x ‹ ˘u ą 0 (A)Compare Equation (R) and Equation (P'), we have,∇ π L P 1 t `π‹ k,t , λ ‹ , x ‹ , β ˘" ´∇π Ω t `π‹ k,t ˘`m ÿ i"1 λ ‹ t,i ∇ π w t,i pπ ‹ k q `β m ÿ i"1 w t,i pπ ‹ k q ∇ π w t,i pπ ‹ k q " ∇ π L R t `π‹ k,t , λ ‹ , x ‹ ˘`β m ÿ i"1 w t,i pπ ‹ k q ∇ π w t,i pπ ‹ k q " 0, where we use w t,i pπ ‹ k q :" Ψ Ci,t pπ k´1 , π ‹ q `x‹ t,i " 0 with the feasible policy π ‹ . Moreover,∇ 2 π L P 1 t `π‹ k,t , λ ‹ , x ‹ , β ˘" ´∇2 π Ω t `π‹ k,t m ÿ i"1 λ ‹ t,i ∇ 2 π w t,i pπ ‹ k q `β∇ π w t pπ ‹ k q ∇ π w t pπ ‹ k q T "∇ 2 π L R t `π‹ k,t , λ ‹ , x ‹ ˘`β∇ π w t pπ ‹ k q ∇ π w t pπ ‹ k q T .To prove that pπ ‹ k,t , λ ‹ q is a strict minimum solution to L P 1 t pπ k , λ, x, βq, we only need to prove the following is true for sufficiently large β,∇ 2 π L P 1 t pπ ‹ k , λ ‹ , x ‹ , βq ą 0.If the above is not true, then for any large β, there exists u t such that }u t } " 1 and satisfiesu T t ∇ 2 π L P 1 t pπ ‹ k , λ ‹ , x ‹ , βq u t " u T t ∇ 2 π L R t pπ ‹ k , λ ‹ , x ‹ q u t `β › › ›∇πwt pπ ‹ k q T u t › › › 2 ď 0 ñ › › ›∇πwt pπ ‹ k q T u t › › › 2 ď ´1 β u T t ∇ 2 π L R t pπ ‹ k , λ ‹ , x ‹ q u t Ñ 0, as β Ñ 8.Therefore, tu h u is a bounded sequence and there must be a limit point, denoted by 8 u. Then∇ π w t pπ ‹ k q T 8 u " 0 8 u T ∇ 2 π L R t pπ ‹ k , λ ‹ , x ‹ q 8 u ď 0.The above contradicts Equation (A), so the conclusion. Hence, π ‹ k,t is also the optimal feasible policy for the primal-dual Problem (P').This part is straightforward since it is a standard result. Please see Chapter 2 and Chapter 9 of [9] , and Chapter 2 and Chapter 4 of [8] for the proof. For completeness, we provide the result below. Suppose π ‹ k,t in the feasible optimal solution set of the primal-dual Problem (P'). Let λ ‹ be the corresponding dual parameter of π ‹ k,t . Consider Problem (6) , which is an equivalent version of Problem (P'). For any feasible π k , we haveL t pπ ‹ k , λ ‹ , βq ď L t pπ k , λ ‹ , βq .Case 1. Whenλ ‹ t,iβ `ΨCi,t pπ k´1 , π ‹ k q ą 0, we haveL t pπ k , λ ‹ , βq " ´Ωt pπ k,t q `m ÿ i"1 λ ‹ t,i Ψ Ci,t pπ k´1 , π k q `β 2 m ÿ i"1 Ψ 2 Ci,t pπ k´1 , π k q " ´Ωt pπ k,t q `m ÿ i"1 βΨ Ci,t pπ k´1 , π k q ˆλ‹ t,i β `ΨCi,t pπ k´1 , π k q ˙´β 2 m ÿ i"1 Ψ 2 Ci,t pπ k´1 , π k q ď ´Ωt pπ k,t qwhere the last step uses β ą 0, Ψ Ci,t pπ k´1 , π k q ă 0, andλ ‹ t,iβ `ΨCi,t pπ k´1 , π k q ą 0.Case 2. Whenλ ‹ t,iβ `ΨCi,t pπ k´1 , π ‹ k q ď 0, we haveL t pπ k , λ ‹ , βq " ´Ωt pπ k,t q ´1 2β m ÿ i"1 λ ‹2 t,i ď ´Ωt pπ k,t q.Now, combining both cases above, we have L t pπ k , λ ‹ , βq ď ´Ωt pπ k,t q. On the other hand,L t pπ ‹ k , λ ‹ , βq " L t pπ ‹ k , λ ‹ , x ‹ , βq " ´Ωt pπ ‹ k,t q.Thus, the combining all of the above we get´Ωt pπ ‹ k,t q " L t pπ ‹ k , λ ‹ , βq ď L t pπ k , λ ‹ , βq ď ´Ωt pπ k,t q.Theorem 3.3. Let π (3) ‹ be a solution to Problem (3), and let `π(6) ‹ , λ (6) ‹ ˘be a solution to Problem (6) .Then, for sufficiently large β ą β and λ t,i ą λ @ i, π (3) ‹ is a solution to Problem (6), and π (6) ‹ is a solution to Problem (3).Proof. We prove this result as a two-step process.First, we show that the solution sets of the below problems are identical. See Lemma A.3 for the proof.L P t pπ k , λ, x, βq :"H ÿ h"t E s"ρπ k,h a"π k´1,h " ´ρpθ h qA π k´1 h ps, aq ‰ `m ÿ i λ t,i w t,i pπ k q `β 2 m ÿ i w 2 t,i pπ k q Then, pπ ‹ k,t , λ ‹ t , x ‹ t q " max λě0 min π k,t ,x L P t pπ k , λ, x, βq (P) Problem (Q). L Q t pπ k , λ, x, βq :" H ÿ h"t E s"ρπ k,h a"π k´1,h " ´ρpθ h qA π k´1 h ps, aq ‰ `m ÿ i λ t,i Ψ Ci,t pπ k´1 , π k , θq `β 2 m ÿ i Ψ Ci,t pπ k´1 , π k , θq 2 Then, pπ ‹ k,t , λ ‹ t , x ‹ t q " max λě0 min π k,t ,x L Q t pπ k , λ, x, βq (Q)Second, we show that the solution sets of the below problems are identical. See Lemma A.4 for the proof.Problem (P') : The agent is rewarded for moving in a specified circle but is penalized if the diameter of the circle is larger than some value [3] . (c) Reach: The agent is rewarded for reaching a goal while avoiding obstacles (cost constraints) that are placed to hinder the agent [30] . (d) Grid: The agent controls traffic lights in a 3x3 road network and is rewarded for high traffic throughput but is constrained to let lights be red for at most 5 consecutive seconds [37] . (e) Bottleneck: The agent controls vehicles (red) in a merging traffic situation and is rewarded for maximizing the number of vehicles that pass through but is constrained to ensure that white vehicles (not controlled by agent) have "low" speed for no more than 10 seconds [37] . (f) Navigation: The agent is rewarded for reaching the target area (green) but is constrained to avoid hazards (light purple) and impassible pillars (dark purple). The cost for hazards and pillars is different [30] .L P 1 t pπ k , λ, x, βq :" H ÿ h"t E s"ρπ k,h a"π k´1,h " ´ρpθ h qA π k´1 h ps, aq ‰ `m ÿ i λ t,i w t,i pπ k q `β 2 m ÿ i w 2 t,i pπ k q Then, pπ ‹ k,t , λ ‹ t , x ‹ t q " max λě0 min π k,t ,x L P 1 t pπ k , λ, x, βq (P')Problem (R) :EQUATIONNow, it follows from equivalency that the optimal solution of Problem (Q) and Problem (R), and hence Problem (6) and Problem (3), is the same.Below we detail the experimental attributes that we used in benchmarking. See Figure 5 for the environment details. All our experiments are run in the omnisafe module [22] .Comprehensively, our experiments consist of eight tasks ranging from more superficial (Run and Circle tasks) to relatively more stochastic and sophisticated (Bottleneck and Grid tasks), each training different robots. They come from three well-known safe RL benchmark environments, Safe MuJoCo, Bullet-Safety-Gym, and Safety-Gym. For agents maneuvering on a two-dimensional plane, the cost is calculated as Cps, aq " b v 2x `v2 y . For agents moving along a straight line, the cost is calculated as Cps, aq " |v x |, where v x and v y are the velocities of the agent in the x and y directions.Circle This environment is inspired by [3] . Reward is maximized by moving along a circle of radius d: R " v T r´y, xs 1 `ˇa x 2 `y2 ´dˇˇ, but the safety region x lim is smaller than the radius d : C " 1rx ą x lim s.Navigation This environment is inspired by [30] . Reward is maximized by getting close to the destination R " Distptarget, s t´1 q ´Distptarget, s t q, but it yields a cost of +1 when the agent hits the hazard or the pillar. The two different types of cost functions are returned separately and have different thresholds. In out setting, d 1 " 25 for the hazard constraint and d 2 " 20 for the pillar constraint.Since the main goal in MuJoCo is to train the robot to locomote on the plane, we call it the "Run" task in our article. Initial log std 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 an environment, and test its performance on different cost thresholds within the same environment. Figure 6 illustrates the training curves of these pre-trained agents, and we see that while e-COP can generalize well across different cost thresholds, other baseline algorithms may require further tuning to accommodate different constraint thresholds. NeurIPS Paper Checklist• The answer NA means that paper does not include experiments requiring code. • Providing as much information as possible in supplemental material (appended to the paper) is recommended, but including URLs to data and code is permitted.Justification: We have read the code of ethics and our work satisfies it in every respect.Guidelines:• The answer NA means that the authors have not reviewed the NeurIPS Code of Ethics.• If the authors answer No, they should explain the special circumstances that require a deviation from the Code of Ethics. • The authors should make sure to preserve anonymity (e.g., if there is a special consideration due to laws or regulations in their jurisdiction). 


Decision: The manuscript presents e-COP a novel policy optimization algorithm for constraint episodic Reinforcement Learning (RL). e-COP combines ideas from constrained numerical optimization and proposes a practical algorithm. Overall, the paper is well-written, extensive experiments are provided and the performance of e-COP is solid.

A few minor issues:
- The authors should discuss the limitations of their approach in more detail in the text
- A few words about fairness of comparisons in the text would be appreciated
- Releasing the source code is important

Despite the above minor issues and some novelty issues, most reviewers (and myself) believe that e-COP can be a valuable contribution to the RL community. As such I recommend "Accept (poster)".

Reviews: review: paper_summary: paper_summary: The authors introduce a policy optimization algorithm for episodic constrained RL problems, e-COP. In general, Lagrangian formulation is used for constrained optimization problems, however, the constraints are not always satisfied in real world applications. The solution approach avoids Hessian matrix inversion. The algorithm approach uses deep learning-based function approximation, a KL divergence-based proximal trust region and gradient clipping popular in improving the generalization and avoiding vanishing gradients in proximal policy optimization algorithms. The authors use SafeGym to benchmark their algorithm against the state-of-the-art algorithms such as PPO, FOCOPS, CPO, PCPO, and P3O.
strength_weakness: strength_weakness: The authors do not talk about the limitations of the algorithms. There is a mention on the complexity of the Grid environment resulting the e-COP not to perform as best. It will be good for the completion of the paper to have a short section on limitations.
questions: questions: I would like to know whether any hyper-parameter tuning has been done for the baseline algorithms? It is possible that the Lagrangian formulation may perform better after tuning.
limitations: limitations: The authors do not adequately address limitations.
paper_summary: paper_summary: The paper proposes a new algorithm for finite-horizon constrained RL problems. The algorithm is based on three ideas: PPO-like updates for the finite-horizon setting, P3O-like treatment of constraints with adaptive penalty coefficient, and quadratic damping penalty. The proposed algorithm outperformed previous algorithms in some benchmark tasks.
strength_weakness: strength_weakness: Performance difference lemma for the finite-horizon setting is already known. See Kakade's thesis. Since PPO-like update is based on the performance difference lemma and PPO's idea, I do not see it is novel. P3O-like treatment of constraints with adaptive penalty coefficient is also not novel.

There are some parts I do not really understand. In particular I wonder if the proposed algorithm really does what Algorithm 2 states. Concretely Algorithm 2 suggests to save policy parameters for each time step, which sounds to be unusual. (Also I guess Line 6 of the algorithm has a type: $\pi_{k, t} \gets \pi_{k, t+1}$ should be $\pi_{k, t} \gets \pi_{k-1, t}$.)

If the algorithm is implemented as above, it is unfair to compare to previous algorithms, because previous algorithms use a much fewer number of parameters. If the algorithm is not implemented as above, there is a serious issue in presentation.

Eq 8 seems to contain many typos. For example $\min_{\pi_{k, t}} L(\theta, \lambda, \beta)$ does not make sense since the loss do not have $\pi_{k, t}$. (Sorry for the sloppy notation, but I believe the authors can understand what I mean.) Also $\pi_{k, t}^\star = \min_{\pi_{k, t}} L(\theta, \lambda, \beta)$ does not make sense since $\min_{\pi_{k, t}} L(\theta, \lambda, \beta)$ is a scalar.
questions: questions: - Does the proposed algorithm what Algorithm 2 states? Algorithm 2 suggests to save policy parameters for each time step, which sounds to be unusual.
- I looked into the code, but it seems it will not run since `_episodic_reward_loss` and `_get_surr_cadv` methods  are undefined. I checked if the Github repo of omnisafe, but I cannot find those functions. Is the code intended only for reference? (Indeed the code is provided as a text file, not python file.)
- I currently think the main contribution of the paper is the introduction of quadratic penalty dumping to safe RL. Therefore I would like to see results of ablation studies to prove the importance of quadratic penalty dumping. Is there any result? (Or am I missing?)
limitations: limitations: If the proposed algorithm really does what Algorithm 2 states, there is an issue of huge memory requirement as the horizon gets larger. I think it should be discussed. Otherwise I do not see any potential negative societal impact.
paper_summary: paper_summary: In this paper, the authors propose a policy optimization algorithm for constrained Reinforcement Learning (RL) problem in a finite horizon setting. First, the authors develop a policy difference lemma for the finite horizon MDP problem. Following that, the authors combine a set of ideas to propose the e-COP algorithm. The authors show that the proposed algorithm is numerically much stable compared to the state-of-the-art solutions. Optimality of the proposed scheme is established under certain assumptions. Extensive simulations have demonstrated that the performance of the algorithm is better than existing methods.
strength_weakness: strength_weakness: The idea of using a quadratic penalty term to improve the stability near the edge of the constraint set boundary is a purely heuristic based approach. The idea of approximating $\rho_{\pi}$ by the empirical distribution from the policy of the previous episode does not appear to be a good approximation. The idea of allowing the agent to act in a constrained manner even before the constraint is violated may lead to suppression in the original objective function.
questions: questions: 1. The idea of using a quadratic penalty term to improve the stability near the edge of the constraint set boundary is a purely heuristic based approach. Is there any strong theoretical argument supporting such a choice?

2. In the related work section, the authors have discussed about drawbacks of using penalty terms in existing methods. Are these drawbacks applicable to the scheme proposed in the paper?

3. It is not clear how the time-dependent state occupation distribution is computed. The idea of approximating $\rho_{\pi}$ by the empirical distribution from the policy of the previous episode does not appear to be a good approximation. Although such approach may work well in infinite horizon problems where the optimality of stationary policy holds, it may not work well in the finite horizon setting.

4. The approach of using the second order penalty is not very novel and is widely used in practice for practical RL algorithms. What is the novelty of the proposed approach?

5. The idea of allowing the agent to act in a constrained manner even before the constraint is violated may lead to suppression in the original objective function. In other words, when the constraint is not too tight, the proposed scheme may unnecessarily impose additional level of constraint on the system.

6. How to ensure that we have sufficiently large $\beta$ and $\lambda_{t,i}$ which are well above the given lower bounds? The adaptive parameter selection process is just a heuristic.

7. The symbol in the last term of equation (7) is not clearly defined.

8. The algorithm proposed in the paper is an amalgamation of many ideas. Many of these ideas involve approximation and many are just driven from intuition without any formal guarantee of optimality. It is hard to see how this fusion work together in theory (e.g., satisfying the conditions given in Theorem 3.3).
limitations: limitations: Yes

Comments: comment: Thank you for the rebuttal comments. It will good to include in the paper that the baselines were implemented and optimized to the best of the author's abilities along with reference to the Appendix.
> Would you explain this a bit more? ... 

It is highly nontrivial due to the absence of a stationary state distribution. With a finite horizon, the time-dependent state occupation measure needs to be treated differently, as is done in e-COP. This different treatment requires completely new analysis to show that this approach is principled, and needs our main result (Theorem 3.3) to showcase that using occupation measure from the previous episode along with the quadratic penalty does not change the solution set of the original problem. This entire part is new and different when compared to P3O.

> Yes, I know in theory a non-stationary policy is required ...

There are two reasons why this approach is **theoretically** not correct (empirically maybe ok):
1. Augmenting a time dimension to the state space leads to sparse transitions, which causes the time-dependent state occupation measures to break down.
2. Time Limits in Reinforcement Learning paper deals with PPO in discounted episodic ($\gamma=0.99$) and un-discounted episodic ($\gamma=1$) setting. Comments: Firstly, for episodic RL, (un-discounted) cumulative episodic rewards are considered as metrics, rather than discounted rewards. Secondly, if you set $\gamma=1$, the policy difference lemma for discounted RL (as in Kakade's thesis) breaks down (see [1] for the solution to this problem). Due to this, no theoretical convergence or correctness statements can be made, which is why there are no theoretical justifications for such an approach. 

We, on the other hand, provide theoretical correctness proof and empirically showcase the effectiveness of our approach on various environments, showcasing the superior performance of e-COP compared to baselines.

> Solving Eq 8 with a first-order optimizer ...

See Lines 5-6 of Algorithm 2 for this. Eq. 8 is first-order solvable, and then backward recursion is done as part of the algorithm. From a careful look at Algorithm 2, it should be clear what is happening.

> But gradually removing some components ... 

This is not correct: The introduction of quadratic penalty and backward recursion structure of the algorithm is not a linear addition, i.e., if one sets $\beta=0$ (so as to "remove" the quadratic penalty), one does not recover **any** previous algorithm. A novelty of our work lies in introducing the quadratic penalty for episodic settings and formalizing the policy update rule, all of which are independent of the baselines we have used.

> Your SHA is different from the one ...

We have **not** provided any readme.md with the supplementary material. Could you please tell which file are you referring to? For the code release, we are currently in the process of obtaining code release permission: We will make the code public once it is received, and before the paper is finalized.

> Thanks, but where is it? Maybe reviewers cannot see updated version yet...

The ablation studies are available in Section 4.2 ("Secondary Evaluation") of the submitted manuscript, with further details in Appendix A.3.4.

We would also like to add that we very much appreciate the care and attention with which the reviewer has read the paper; the probing questions they ask will make our draft stronger ; and the willingness to engage with our response and cross-check our experimental data !

[1] Agnihotri, A. et al. ACPO: A Policy Optimization Algorithm for Average MDPs with Constraints. ICML 2024.
Thank you very much for the rebuttal!

> However, how to incorporate this treatment into episodic settings was unknown, as was how to update the policy network in the finite horizon setting.

Would you explain this a bit more? I do not really see why converting algorithms for the infinite-horizon setting to the finite-horizon setting is untrivial. In my experience it is easy in theory, especially given performance difference lemma for the finite-horizon setting. For example which part of the derivation of e-COP is challenging in comparison to P3O?

> Note that we have a time-dependent policy (hence parameters are saved at each step). This is not a bug but a feature as stationary policies for the episodic setting are known to be sub-optimal... 

Yes, I know in theory a non-stationary policy is required. However one can explicitly provide the remaining time to a policy network, as is done in Time Limits in Reinforcement Learning by Pardo et al.

> Line 6 of Algorithm 2 is correct, since we use the idea of backward recursion as is done in the classical dynamical programming algorithms.

Would you explain this point a bit more? Solving Eq 8 with a first-order optimizer as explained in Line 229-230 does not seem to result in backward recursion.

> The concern of fairness of comparison to these other algorithms designed for non-episodic settings is valid... Nevertheless, these are the closest baselines available and we show that their usage in the episodic setting will result in subpar performance...

But gradually removing some components from e-COP recover previous algorithms, no?

> Ques 2: Yes, we had to code the two functions you mentioned, and we use commit SHA

Your SHA is different from the one in readme.md of the supplementary material. Also would tell me where `_get_surr_cadv` is? I cannot find it. Maybe would you give me a github link to the file in which the method actually appears?

> Ques 3: We have included ablation

Thanks, but where is it? Maybe reviewers cannot see updated version yet...
Thank you for your detailed response which has resulted in a better understanding of the paper. However, I still feel novelty of the paper is limited as it incorporates various ideas already existing in the literature, for a episodic setting.  I am happy to raise my score.