e-COP : Episodic Constrained Optimization of Policies

In this paper, we present the $\texttt{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 $\texttt{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.

Paper

Similar papers

Peer review

Reviewer p2dY5/10 · confidence 5/52024-07-12

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.

Strengths

The paper is well-written and easy to follow. The results and claims presented in the paper appears to be correct.

Weaknesses

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

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).

Rating

5

Confidence

5

Soundness

3

Presentation

2

Contribution

2

Limitations

Yes

Reviewer p2dY2024-08-10

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.

Reviewer 4GCx4/10 · confidence 2/52024-07-12

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.

Strengths

A strong empirical performance of the proposed algorithm. The introduction of quadratic damping penalty to safe RL seems to be a new idea. The paper is easy to follow except some typos.

Weaknesses

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

- 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?)

Rating

4

Confidence

2

Soundness

3

Presentation

2

Contribution

2

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.

Authorsrebuttal2024-08-13

> 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.

Reviewer kuft7/10 · confidence 4/52024-07-13

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.

Strengths

The e-COP algorithm in most cases outperforms all other baseline algorithms but fails on Humanoid, AndReach, and Grid where it provides the second best optimal results. The authors used an extensive set of baselines -- few using Lagrangian approximations. The idea is original. In general, the paper is well-written and clear. There are few grammatical errors and typos.

Weaknesses

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

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.

Rating

7

Confidence

4

Soundness

3

Presentation

3

Contribution

3

Limitations

The authors do not adequately address limitations.

Reviewer 4GCx2024-08-13

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...

Reviewer kuft2024-08-14

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.

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC