Abstract
Reinforcement learning (RL) agents typically manage constraints by ensuring expected costs remain below a budget. However, real-world safety often requires "anytime" constraints, where the budget must never be exceeded at any point in time. This paper formalizes anytime-constrained RL, proves its NP-hardness, and proposes a state-augmentation framework with an efficient approximation scheme to find near-optimal, strictly safe policies.
Introduction
In standard Constrained Reinforcement Learning (CRL), constraints are usually formulated as expectations or high-probability "chance" constraints. For example, an agent might be constrained to keep its average fuel consumption below a certain level over many episodes.
But in the real world, a car cannot run on "expected" gas—if it hits an intermediate state where the tank is empty, the trip is over. The authors formalize this as anytime constraints: the requirement that an agent must never violate its budget at any point in time, almost surely. This introduces massive algorithmic challenges. Traditional "Markovian" policies, which only look at the current state to decide the next action, are no longer sufficient because the agent needs to remember how much budget it has already consumed.
The Complexity of Absolute Safety
The authors prove that computing an optimal policy for anytime constraints is NP-hard. This is because the problem essentially embeds the classic Knapsack problem into the Markov Decision Process (MDP): deciding which actions to take to maximize reward without exceeding an absolute budget over time is mathematically equivalent to the Knapsack/Partition problem. Consequently, any policy that does not track the full cost history can be arbitrarily suboptimal or unsafe.
Methods: State Augmentation and Approximation
To solve this, the authors show that an anytime-constrained MDP can be transformed into a standard, unconstrained MDP by augmenting the state space to include the cumulative cost.
Exact Reduction via Safe Exploration
They utilize a "forward induction" approach to build a finite set of augmented states (state + cumulative cost) that can be reached without violating the budget. If the precision of the costs is small (e.g., logarithmic), this exact method is computationally feasible (Fixed-Parameter Tractable).
Polynomial-Time Approximation Scheme
Because the exact method scales exponentially with the time horizon in the worst case, the authors introduce an approximation scheme. Instead of tracking every exact cumulative cost, the algorithm groups (projects) costs into discrete, evenly spaced intervals. Crucially, it uses the principle of optimism: it always underestimates the true cost slightly. This guarantees the policy achieves the optimal reward, at the cost of a strictly bounded, small budget violation.
For scenarios where strict safety is non-negotiable, the authors propose a Feasibility Scheme. By running the approximation algorithm with an artificially lowered budget, the optimistic underestimation is absorbed by the buffer, ensuring the true budget is never breached.
Key Insights
- Memory is Mandatory: Standard Markovian policies fail for anytime constraints because they cannot adapt to the costs seen so far.
- Deterministic Optimality: Unlike expectation-constrained RL, which often requires stochastic policies to hit a fractional budget, anytime constraints can always be solved optimally using deterministic policies.
- Optimistic Discretization: By slightly underestimating cumulative costs and projecting them onto a grid, the state space shrinks dramatically, bypassing the NP-hard bottleneck.
Results and Scalability
The authors evaluated their algorithms on synthetic "hard" cMDP instances designed to mimic the Knapsack problem.
- Efficiency: The exact state-augmentation method scales poorly; for a horizon of $H=15$, it takes over a minute to compute. In contrast, the approximation scheme handles $H=100$ in just 2 seconds (for $\epsilon=0.1$) and a mere 0.0008 seconds for $\epsilon=1$.
- Safety vs. Value: In tests of the "no-violation" scheme (artificially shrinking the budget), the algorithm still achieved the optimal value in nearly every trial, demonstrating that performance does not necessarily have to be sacrificed for guaranteed safety.
Conclusion and Future Work
While this work provides a robust framework for anytime-constrained RL, it relies on worst-case analysis and assumes single-step costs are polynomially bounded. A major remaining challenge is safe learning: while these algorithms produce a safe policy after computation, ensuring the agent does not violate the budget during the training process remains an open question for future research.
Summary updated