SafeOR-Gym: A Benchmark Suite for Safe Reinforcement Learning Algorithms on Practical Operations Research Problems

## Abstract

Abstract Most existing safe reinforcement learning (RL) benchmarks focus on robotics and control tasks, offering limited relevance to high-stakes domains that involve structured constraints, mixed-integer decisions, and industrial complexity. This gap hinders the advancement and deployment of safe RL in critical areas such as energy systems, manufacturing, and supply chains. To address this limitation, we present SafeOR-Gym, a benchmark suite of nine operations research (OR) environments tailored for safe RL under complex constraints. Each environment captures a realistic planning, scheduling, or control problems characterized by cost-based constraint violations, planning horizons, and hybrid discrete-continuous action spaces. The suite integrates seamlessly with the Constrained Markov Decision Process (CMDP) interface provided by OmniSafe. We evaluate several state-of-the-art safe RL algorithms across these environments, revealing a wide range of performance: while some tasks are tractable, others expose fundamental limitations in current approaches. SafeOR-Gym provides a challenging and practical testbed that aims to catalyze future research in safe RL for real-world decision-making problems. The SafeOR-Gym framework and all accompanying code are available at: https://github.com/li-group/SafeOR-Gym.

## 1 Introduction

Real-world reinforcement learning (RL) applications often demand that agents respect strict safety requirements at all times. Safe reinforcement learning [7, 8] addresses this need by maximizing long-term rewards while satisfying safety constraints. In contrast to standard RL, which might treat safety violations as mere negative rewards, safe RL explicitly enforces constraints throughout training and deployment. This capability is vital in safety-critical domains such as autonomous driving, robotics, and power systems, where an agent’s actions can lead to irreversible damage or hazards if constraints such as speed limits, stability margins, or resource capacities are violated. The formalism of constrained Markov decision processes (CMDPs) [2] provides a natural framework for such problems, requiring the learned policy to remain within a set of safe outcomes at all times. In practice, safe RL algorithms incorporate cost signals or penalties for unsafe behavior and aim to ensure constraint satisfaction during both learning and execution. This paradigm has gained traction as a cornerstone for deploying RL in high-stakes environments.

Progress in safe RL has been accelerated by the development of specialized libraries and benchmark suites. A prominent example is OmniSafe [14], an open-source infrastructure designed specifically for safe RL research. OmniSafe offers a unified, modular framework with built-in support for constraint handling and a comprehensive collection of constrained RL algorithms. Notably, it extends the standard OpenAI Gym interface by supporting constrained Markov decision processes (CMDPs), enabling explicit modeling of safety constraints through cost signals. These capabilities make OmniSafe and similar frameworks highly valuable for evaluating safe RL methods in a standardized and extensible setting. However, despite advances in algorithms and software infrastructure, the diversity and realism of benchmark environments tailored for safe RL remain limited.

Most existing RL benchmarks were not designed with safety constraints in mind. Classic control tasks and popular continuous control domains such as CartPole, Pendulum, and MuJoCo locomotion simulations [27, 4] offer simple dynamics with no explicit safety constraints. Crucially, these environments rarely involve the mixed discrete–continuous decision-making or constraints that characterize real operational problems. Even specialized safe RL environment suites focus primarily on robotic control and do not capture the structured complexity of industrial decision problems. This gap in benchmarks makes it challenging to rigorously evaluate how well safe RL algorithms would perform on realistic, safety-critical tasks that involve complex constraints and decision structures.

Operations research (OR) problems [24] present an appealing opportunity to fill this gap. OR encompasses a broad class of decision-making tasks with rich combinatorial structure, explicit constraints, and often long planning horizons. These problems inherently require balancing long-term objectives with immediate feasibility and safety. For instance, planning the operation of an energy storage system demands making multi-year investments and dispatch decisions that remain robust to short-term operational constraints and rare events[23, 16]. In general, OR formulations like scheduling, resource allocation, and supply chain management force agents to respect resource capacities, timing deadlines, and logical constraints at every step, exactly the kind of requirements safe RL is meant to handle. Moreover, OR problems frequently arise in safety-critical domains such as energy systems, transportation, supply chains, and chemical process operations. In these settings, violating a constraint such as overloading a network, missing a maintenance schedule, running a process outside safe limits, etc., can lead to severe real-world consequences. The structured nature and practical relevance of OR tasks make them well-suited as benchmark environments to stress-test safe RL algorithms on realistic problems that go beyond the toy examples commonly used.

We introduce SafeOR-Gym, a benchmark suite for safe reinforcement learning that features a diverse set of operations research environments spanning industrial planning and real-time control. The suite includes nine environments with varying structures, time horizons, and decision complexities.

In summary, this work makes the following contributions:

- 1.
We develop a suite of nine OR-based benchmark environments tailored for safe RL, addressing the need for more realistic and structured evaluation tasks.
- 2.
We release Gym-compatible implementations of these environments with native integration into the OmniSafe framework, enabling out-of-the-box use of constraint-handling algorithms.
- 3.
We evaluate the environments using several on-policy algorithms in OminiSafe and discuss the current limitations of existing safe RL algorithms in solving highly constrained OR problems.

## 2 Related Work

Standard RL benchmarks, such as the OpenAI Gym toolkit [4] with classic control and MuJoCo-based continuous control tasks, have been foundational for evaluating reinforcement learning algorithms. However, they typically lack built-in safety constraints or the structured decision-making found in operations research (OR) problems. Most environments are designed as simplified tasks with minimal realism or constraints.

To address the need for safety-aware evaluation, specialized benchmark libraries have emerged. OpenAI’s Safety Gym [25] introduced a set of environments that simulate continuous control tasks with hazards, cost signals, and explicit safety constraints. More recently, the Safety Gymnasium [13] suite has extended this idea to include both single- and multi-agent safety-critical environments. The OmniSafe [14] framework further consolidates these contributions by integrating a variety of safe RL environments and algorithms into a unified and modular platform. It supports constraint-handling algorithms, constrained policy optimization methods, and provides compatibility with Gym-style APIs.

In parallel, a growing body of work has focused on bringing OR and classical control problems into Gym-compatible environments. OR-Gym [11] provides a library of OR formulations, such as knapsack, bin packing, and supply chain management, as RL tasks, enabling comparison between RL policies and traditional optimization techniques. PC-Gym [3] and [19] introduce environments that model realistic chemical process dynamics, control disturbances, and enforce operational safety. SustainGym [30] contributes several sustainability-focused environments such as electric vehicle charging and data center scheduling, which feature complex operational constraints, distribution shifts, and hybrid discrete-continuous action spaces.

Despite these efforts, existing benchmarks for operations research problems exhibit important limitations. Existing works are only compatible with standard Gym environments, rather than the CMDP interface required by frameworks like OmniSafe. They typically handle constraint violations by penalizing the reward function, rather than modeling them as explicit cost signals. Furthermore, many environments simplify or abstract away industrial complexity, limiting their utility for evaluating algorithms in realistic, safety-critical scenarios. OR-Gym, for example, primarily consists of toy problems such as knapsack and bin packing, which lack the structural and constraint richness of real-world applications. PC-Gym focuses exclusively on continuous control problems, omitting discrete decisions and combinatorial logic. SustainGym centers on sustainability-oriented problems, but does not incorporate the nonlinear, nonconvex constraints and logical decision-making present in many OR applications, such as those found in the blending problem. These gaps motivate the development of a benchmark suite featuring rich, constrained, and practically relevant OR problems that can serve as a rigorous testbed for safe RL algorithms.

## 3 Environments

This section provides an overview of a few of the environments in SafeOR-Gym. The detailed descriptions of all the environments can be found in the supplementary material.

### 3.1 Resource Task Network ( RTNEnv )

Problem Description The Resource Task Network (RTN) is a foundational model for scheduling production operations in process industries such as chemical processes [18]. It represents the system as a network of materials (e.g., raw materials, intermediates, and final products) and processing steps, called tasks, which transform input materials into outputs. Each task is executed in discrete quantities known as batches and requires specific equipment units (e.g., reactors or mixers) to operate. In RTNEnv, the agent controls the batch size of each task at every time step across a finite horizon, aiming to fulfill product demand, minimize cost, and respect system constraints. The environment simulates the dynamics of a batch-processing facility, where materials are produced, consumed, and stored, and where the reuse of equipment is delayed by task durations. Safety is embedded into the environment: the agent must prevent actions that deplete material inventories below safe levels or allocate tasks to unavailable equipment, thereby avoiding operational failures and constraint violations.

State Space The state includes current inventory levels of all materials (reactants, intermediates, products, equipment); scheduled future deliveries of products and intermediates from in-progress tasks; upcoming product demands from time $t$ to $T$ right-padded with zeros.

Action Space The action is a continuous vector with one entry per task, representing the batch size to be executed.

Transition Dynamics applies task stoichiometry to update inventories; schedules delivery of materials and consumption and return of equipment, clips or nullifies actions to enforce inventory bounds and equipment availability;.

Cost The environment penalizes: falling below the minimum or exceeding the maximum inventory for any material; dispatching a task when insufficient equipment is available;

Reward The reward includes: revenue from fulfilled product demand; minus utility cost for running tasks; minus penalty for unmet demand; minus reactant ordering cost when inventory goes negative.

### 3.2 Unit Commitment ( UCEnv )

Problem Description The Unit Commitment problem is a cornerstone optimization task in power systems. It determines when to turn power generators on or off and how much electricity each should produce, aiming to minimize operational cost while ensuring supply-demand balance and meeting system reliability constraints [15]. In UCEnv, the agent controls binary on/off decisions and continuous dispatch levels for each generator over a finite planning horizon. These decisions must satisfy safety constraints such as ramping limits, minimum up/down times, and transmission capacity bounds. The environment captures realistic power grid dynamics under uncertainty, reflecting the challenges of operating with variable demand and fluctuating renewable generation.

State Space The state includes generator on/off sequences; power output of each generator; voltage angles at each bus; and forecast electricity demand for future time steps.

Action Space The action includes on/off status and power dispatch level for each generator, along with voltage angle assignments at each bus.

Transition Dynamics Applies feasibility checks and automatic repairs to enforce minimum up/down times and ramp rate limits; update load unfulfillment and power reserve; clips power output and voltage angles to stay within generator and grid limits; updates generator status sequences and forecasts.

Cost The environment penalizes violations of minimum up/down time constraints; ramp rate limit violations; tranmision capacity violations.

Reward The reward is the negative of total operating cost, including: quadratic generation costs; startup and shutdown costs; load shedding penalties for unmet demand; and reserve shortfall penalties for failing to maintain spinning reserves.

### 3.3 Multiperiod Blending Problem ( BlendingEnv )

Problem Description The multiperiod blending problem arises in industries such as refining and chemical processing, where raw materials with different properties must be blended over time to produce saleable products meeting strict quality constraints [6]. In BlendingEnv, the agent decides how much of each source stream to purchase, how to route flows through a network of blenders, and how much product to sell at each time step. Safety constraints include property bounds on final products and storage limits on inventories. The environment reflects operational complexities such as nonlinear blending effects, capacity limits, and quality enforcement.

State Space The state includes current inventory levels of sources, blenders, and demand nodes; material properties of blender; future availability of sources and product demand over a lookahead window, and the current time step.

Action Space The action specifies: source stream purchase quantities; product sale quantities; flow rates from source inventories to blenders, between blenders, and from blenders to product inventories.

Transition Dynamics Updates inventories using material balances; clips values to inventory bounds; updates material properties in blenders based on flow composition; rolls forward source availability and demand forecasts.

Cost The environment penalizes: violating inventory bounds; violating the no simultaneous “in-out” flow rule for blenders; and producing out-of-spec blends.

Reward The reward includes: revenue from product sales; minus cost of purchasing source streams; minus variable and fixed costs for flow operations.

### 3.4 Multi-Echelon Inventory Management ( InvMgmtEnv )

Problem Description The multi-echelon inventory management problem models the operation of complex supply chains involving multiple interconnected tiers such as suppliers, producers, distributors, retailers, and markets [20]. In InvMgmtEnv, the agent decides ordering quantities across various routes to satisfy uncertain market demand while minimizing operational costs and penalties. The environment features fixed lead times, capacity constraints, and stochastic demand, simulating real-world supply chain dynamics and risks. Safe operations require respecting bounds on order volumes, inventory capacities, and maintaining service levels under varying demand.

State Space The state includes current inventory levels at all nodes; quantities in pipeline inventory by route and lead time; historical and forecasted market demand; backlog of unmet demand; and sales at the current period.

Action Space The action specifies continuous reorder quantities along each supply chain route.

Transition Dynamics Orders enter pipelines and propagate forward according to lead times; arrivals update on-hand inventories; update demand forecast; sales and backlog are computed based on available inventory.

Cost Penalties are incurred for orders exceeding quantity or capacity limits, for any state (inventory or pipeline) falling outside its valid bounds, for negative or infeasible inventory levels, and for backlogs beyond the allowed threshold.

Reward The reward includes: revenue from market sales; minus procurement costs, inventory holding costs (both on-hand and in-transit), operating expenses, and backlog penalties.

### 3.5 Grid-Integrated Energy Storage ( GridStorageEnv )

Problem Description
Grid-Integrated Energy Storage problem simulates hourly dispatch on a transmission grid where batteries share buses with thermal generators and a prescheduled subset of lines may be switched off. During each hour the agent selects generator set-points, battery charge and discharge rates, deliberate load-shedding, and controllable voltage angles at all non-reference buses; the DC power-flow equations then determine line flows, and any de-energised line is forced to zero. Batteries evolve through a simple state-of-charge (SOC) recursion that applies round-trip efficiency and an inter-period carry-over factor, and the episode spans a fixed horizon without early termination.

State Space
State space contains normalised battery SOC, voltage-angle differences, line-loading flows, slack generation, a rolling demand-forecast window, and a normalised time. Each component is clipped to its admissible interval, with the clipping distance recorded for later penalties.

Action Space
The policy emits a normalised vector that is affinely mapped to physical generator outputs, battery charge and discharge rates, load-shedding, and bus angles. Values that exceed their limits are clipped, and every excess contributes to an action-bound penalty.

Transition Dynamics
After decoding and clipping the action, the environment updates battery SOC, caps load-shedding, solves the DC power flow with zero flow on de-energised lines, introduces slack generation to balance each bus, reconstructs the next observation, and logs penalties for any bound, flow, SOC, angle, or power-balance violation encountered along the way

Cost
At each step the environment charges three kinds of penalties: the action-bound penalty for any control component that is clipped, the aggregated observation-bound penalty for state variables that drift outside their safe intervals, and a network-balance penalty that scales with the absolute mismatch between nodal injections and the DC power-flow equations.

Reward
The reward delivered to the agent is the negative sum of generator fuel cost, slack-generation cost, and load-shedding cost, so maximising reward is equivalent to minimising these economic charges. This formulation steers the policy toward meeting demand with the lowest feasible operating expense while respecting all system constraints.

### 3.6 Integrated Scheduling and Maintenance ( SchedMaintEnv )

Problem Description The Integrated Scheduling and Maintenance environment models the daily operation of compressors in an Air Separation Unit (ASU), where gaseous product demand must be met without inventory buffers [28]. The agent must coordinate production and maintenance actions for each compressor while optionally procuring external supply to satisfy demand. At each time step, the agent decides the fraction of each compressor’s capacity to operate, whether to initiate maintenance, and how much external product to purchase. Maintenance policies are constrained by compressor-specific conditions, such as mean time to failure (MTTF), maintenance duration, and cooldown periods. Safety arises from the need to avoid compressor breakdowns due to delayed maintenance, premature maintenance interventions, or ramping during repair periods.

State Space The state includes: forecasted product demand and electricity prices over a fixed horizon; compressor-level indicators for time since last maintenance, time remaining to complete maintenance, and eligibility to enter maintenance.

Action Space The action at each time step consists of: a binary vector for maintenance decisions (schedule or not); a continuous vector for compressor production rates; and a continuous external purchase action representing the fraction of a predefined maximum external capacity.

Transition Dynamics Compressor state evolves based on maintenance initiation, progress, and cooldown periods. Upate electricity prices and product demand follow forecasts. Maintenance eligibility resets once a cooldown period has elapsed. The environment enforces repair continuity and halts production during repair.

Cost The environment penalizes: early maintenance actions; failure to perform maintenance before MTTF; ramping while under maintenance; and disruption of ongoing maintenance. Additionally, unmet or overmet demand incurs a penalty proportional to the deviation from forecast.

Reward The agent receives a negative reward equal to the total cost incurred: production cost (based on power price and compressor load), external purchase cost.

## 4 Experiments

We evaluate a suite of safe reinforcement learning (RL) algorithms across multiple environments subject to safety constraints. Each experiment involves one or more deterministic case studies, designed to test algorithmic robustness and generalization. We adopt the CMDP formulation used in the OmniSafe package [14]. We adapt the safe RL algorithms in OmniSafe, which supports parallelized training and evaluation via its Experimental Grid feature. The safe RL algorithms tested include Constrained Policy Optimization (CPO) [1], TRPOLag [26], Penalized Proximal Policy Optimization (P3O) [31], Constraint Rectified Policy Optimization (OnCRPO) [29], and DDPGLag [17]. All the experiments were conducted on AWS servers using g4dn.xlarge instances equipped with NVIDIA T4 GPUs, providing sufficient computational resources for training and evaluation of all the algorithms. The training times for the various algorithms across different experiments are provided in the supplementary material.

### 4.1 Results and Discussion

We benchmark each algorithm’s performance across environments during both training and evaluation. Figure [1](https://arxiv.org/html/2506.02255v1#S4.F1) presents the average reward and cost per training epoch, with shaded regions indicating one standard deviation around the mean. Table [1](https://arxiv.org/html/2506.02255v1#S4.T1) summarizes evaluation results, averaged over 10 episodes, for a representative subset of experiments and environments. The standard deviation of the evaluation rewards and costs is generally small, indicating consistent performance in the determinstic environments.

Optimal reward of the environments: One of the advantages of benchmarking safe RL algorithms using environments based on deterministic opeartions research problems is that state-of-the-art optimization solvers such as Gurobi [9] can be used to solve the nonconvex problems to global optimality while strictly enforcing all the constraints. The optimal reward from the optimization solvers can be seen as the “ground truth” of the envrionments, shown in the first column of Table [1](https://arxiv.org/html/2506.02255v1#S4.T1).

Evaluation Criteria: To evalute the safe RL algorithms, for each environment, we identify the best- and worst-performing algorithms using a systematic selection criterion. In the table, values highlighted in green correspond to the evaluation reward and cost of the best-performing algorithms, and values in red indicate those of the worst-performing algorithms. This subset of results is chosen to illustrate key behavioral differences among algorithms and to highlight environment-specific challenges that affect learning and generalization. Results for additional case studies are included in the supplementary material. To identify the best and worst performing algorithms in each environment, we adopt a two-step filtering strategy based on evaluation cost and reward. This approach is motivated by the fact that reward and cost can differ significantly in scale, making it inappropriate to combine them into a single metric without normalization or weighting. To select the best algorithm, we first filter those with evaluation costs either within five times the lowest cost or within 25 units of the lowest cost. If the lowest cost is zero, we instead include all algorithms with costs below a fixed threshold of 25. Among this filtered set, the algorithm with the highest evaluation reward is selected as the best. To determine the worst algorithm, if an algorithm’s evaluation cost is at least ten times greater than the second-highest and 100 units greater than the second-highest, it is directly selected as the worst. Otherwise, we consider all algorithms whose costs fall within the three highest unique values and select the one with the lowest reward.

A gap is considered significant if the absolute difference between training and evaluation results exceeds 100, and the relative difference (calculated as the absolute gap divided by the magnitude of the training result) exceeds 30%. When the magnitude of the training result is less than 0.1, only the absolute difference is considered. The training result refers to the average episode reward from the final epoch. Additionally, we say an algorithm solves an environment to reasonable-optimality if it consistently achieves reasonably high rewards (less than 35% gap with the optimal reward) while maintaining low costs, allowing for a small number of constraint violations.

#### 4.1.1 Environments with reasonable performance

The following environments illustrate scenarios in which at least one algorithm successfully trains a policy that yields a reasonably high rewards with low associated cost:

- •
GTEPEnv: This case study involves a five-region power system with two generators and possible transmission lines between all region pairs over a 10-period planning horizon. We train with 100 episodes per epoch. P3O shows a significant gap between training and evaluation in both reward and cost. Notably, DDPGLag learns a policy that achieves high rewards at the expense of significantly increased costs. To preserve clarity in visual comparisons, we omit the training curve for DDPGLag in Figure [1(a)](https://arxiv.org/html/2506.02255v1#S4.F1.sf1).
- •
InvMgmtEnv: This case study involves a multi-echelon inventory network comprising one market, one retailer, two distributors, three producers, and two raw-material suppliers, connected via eleven reorder routes and governed by one-period lead times. Each episode spans 30 days, and training is performed with 10 episodes per epoch. P3O exhibits a significant gap between training and evaluation in terms of cost.
- •
SchedMaintEnv: We consider an air separation unit with three compressors and optional external product purchases to compensate for maintenance downtime. The planning horizon is 30 days, and each episode is 31 days long. Training is conducted using 25 episodes per epoch. A significant gap between training and evaluation costs is observed for P3O.
- •
UCEnv: This example considers a single-bus unit commitment power system with five generators operating over a 24-hour horizon, with hourly updates to demand forecasts and generator states. Training is done with 100 episodes per epoch.

Figure: (a) GTEPEnv
Refer to caption: x1.png

**Table 1: Evaluation results for 10 episodes**
|  | Optimal | CPO | DDPGLag |  |  |
| --- | --- | --- | --- | --- | --- |
| Environment | Reward | Reward | Cost | Reward | Cost |
| GTEPEnv | -267.7 | -313 | 0 | -19 | 689140 |
| InvMgmtEnv | 11265.97 | 7303.2 | 0 | -4858.26 | 0 |
| SchedMaintEnv | -1221.85 | -1283.96 | 29.59 | -1700.98 | 11675.99 |
| UCEnv | -197258 | -236553 | 5.56 | -337153 | 108 |
| GridStorageEnv | -54173 | -95198.2 | 0.02 | -118704 | 120440 |
| BlendingEnv | 1800 | 0 | 190 | 0 | 32763.44 |
| RTNEnv | 363.78 | -31.37 | 71 | -47.76 | 84 |
| STNEnv | 363.78 | -36.76 | 71 | -10.38 | 84 |

#### 4.1.2 Environments not trained to reasonable optimality

The following environments presented significant challenges during training, preventing the agents from learning reasonably optimal policies.

- •
GridStorageEnv: This case study includes a three-bus network with transmission limits of 80MW, 120MW (de-energized under wildfire risk), and 90MW; one generator per bus rated at 100MW, 90MW, and 80MW; and batteries sized 1.0, 1.2, and 0.8 p.u. respectively. The horizon spans 24 hours, with perfect charging, discharging, and carry-over efficiency. Experiments were run with 10 episodes per epoch. While some algorithms demonstrate progress toward the optimal reward and zero cost, a noticeable gap remains between the optimal reward and the reward achieved during training. This gap may stem from suboptimal tuning of the environment’s cost parameters, potentially limiting the agent’s ability to prioritize higher-reward actions during learning.
- •
BlendingEnv: The case study includes 2 input streams, 2 output streams, 2 quality properties, 4 blenders, and 6 time periods per episode with the prop strategy used to handle infeasible actions. No flow is allowed between 2 of the blenders. Experiments were run with 100 episodes per epoch. A significant gap is observed between training and evaluation for both rewards and costs in P3O, and for rewards in DDPGLag. As shown in Figure [1(f)](https://arxiv.org/html/2506.02255v1#S4.F1.sf6), some algorithms exhibit considerable oscillations in both reward and cost over training epochs. This instability may be attributed to the highly non-convex nature of the underlying optimization problem and the resulting non-smooth feasible action space, which makes consistent policy improvement more difficult.
- •
RTNEnv: This case study includes 3 raw materials, 2 intermediates, 2 products, 3 tasks, 3 pieces of equipment, and 2 utilities. The planning horizon spans 30 time periods with fixed product demands. Training used 128 episodes per epoch. As shown in Figure [1(g)](https://arxiv.org/html/2506.02255v1#S4.F1.sf7), both reward and cost exhibit slow learning across all algorithms. This sluggish progress may be attributed to the combination of non-convexities introduced by integer-based constraints such as task-equipment assignments and equipment availability and the indirect, time-coupled linear constraints that the action space must satisfy. The presence of temporal dependencies, material balances, and combinatorial task scheduling further compounds the difficulty of policy learning in these environments.
- •
STNEnv: This case study builds on the same network as RTNEnv but includes extended task-to-equipment mappings and product-specific processing times. To enable comparison with RTNEnv, mappings were kept unique. The planning horizon and demand profiles remain unchanged. Experiments were run with 128 episodes per epoch. TRPOLag performs the best, while OnCRPO performs the worst. Similar to RTNEnv, both reward and cost exhibit slow learning across all the algorithms in STNEnv, likely due to a similar combination of non-convexities introduced by integer-based constraints and the indirect linear constraints imposed on the action space.

#### 4.1.3 Discussion

Across most environments, OnCRPO and TRPOLag perform best, while DDPGLag consistently underperforms. Interestingly, the P3O algorithm showed a significant gap between training and evaluation performance in several settings. While some environments allowed agents to learn policies that achieved near-optimal rewards with minimal constraint violations, other environments posed significant challenges. These more difficult environments highlight the limitations of current methods and underscore the need for more sophisticated approaches to safe reinforcement learning.

## 5 Conclusions and Future Directions

We presented SafeOR-Gym, a suite of nine operations research environments tailored to benchmark safe RL algorithms in complex, realistic settings. These environments introduce structured constraints, mixed-integer decisions, and discrete-continuous actions, going beyond the scope of conventional safe RL benchmarks. While existing algorithms can solve some tasks, they perform poorly on problems involving mixed-integer variables or nonlinear, nonconvex constraints. These limitations point to broader challenges in applying safe RL to industrial domains.

To bridge this gap, future research can pursue several promising directions. First, improving the reliability and robustness of safe RL algorithms is essential for deployment in safety-critical applications. Second, developing automated parameter tuning methods, especially for constraint-aware algorithms like CPO, can reduce manual overhead and improve consistency across environments. Third, advancing action-constrained RL methods [12] that can handle hard constraints during action selection, rather than relying on soft penalties or post hoc projection, can better ensure safety. Finally, new approaches to directly encode safety constraints into neural network policies, possibly through architectural innovations or differentiable constraint satisfaction layers [5].

## References

- Achiam et al. [2017]
Joshua Achiam, David Held, Aviv Tamar, and Pieter Abbeel.
Constrained policy optimization.
In Doina Precup and Yee Whye Teh, editors, *Proceedings of the 34th International Conference on Machine Learning*, volume 70 of *Proceedings of Machine Learning Research*, pages 22–31, 2017.
- Altman [2021]
Eitan Altman.
*Constrained Markov decision processes*.
Routledge, 2021.
- Bloor et al. [2024]
Maximilian Bloor, José Torraca, Ilya Orson Sandoval, Akhil Ahmed, Martha White, Mehmet Mercangöz, Calvin Tsay, Ehecatl Antonio Del Rio Chanona, and Max Mowbray.
PC-Gym: Benchmark Environments for Process Control Problems.
*arXiv preprint arXiv:2410.22093*, 2024.
doi: 10.48550/arXiv.2410.22093.
- Brockman et al. [2016]
Greg Brockman, Vicki Cheung, Ludwig Pettersson, Jonas Schneider, John Schulman, Jie Tang, and Wojciech Zaremba.
OpenAI Gym.
*arXiv preprint arXiv:1606.01540*, 2016.
- Chen et al. [2024]
Hao Chen, Gonzalo E. Constante Flores, and Can Li.
Physics-informed neural networks with hard linear equality constraints.
*Computers & Chemical Engineering*, 189:108764, 2024.
ISSN 0098-1354.
doi: https://doi.org/10.1016/j.compchemeng.2024.108764.
URL [https://www.sciencedirect.com/science/article/pii/S0098135424001820](https://www.sciencedirect.com/science/article/pii/S0098135424001820).
- Chen and Maravelias [2020]
Yifu Chen and Christos T. Maravelias.
Preprocessing algorithm and tightening constraints for multiperiod blend scheduling: cost minimization.
*Journal of Global Optimization*, 77(3):603–625, Jul 2020.
ISSN 1573-2916.
doi: 10.1007/s10898-020-00882-3.
URL [https://doi.org/10.1007/s10898-020-00882-3](https://doi.org/10.1007/s10898-020-00882-3).
- Garcıa and Fernández [2015]
Javier Garcıa and Fernando Fernández.
A comprehensive survey on safe reinforcement learning.
*Journal of Machine Learning Research*, 16(1):1437–1480, 2015.
- Gu et al. [2022]
Shangding Gu, Long Yang, Yali Du, Guang Chen, Florian Walter, Jun Wang, and Alois Knoll.
A review of safe reinforcement learning: Methods, theory and applications.
*arXiv preprint arXiv:2205.10330*, 2022.
- Gurobi Optimization, LLC [2025]
Gurobi Optimization, LLC.
Gurobi Optimizer Reference Manual, 2025.
URL [https://www.gurobi.com](https://www.gurobi.com).
- Huang and Zheng [2020]
Zhouchun Huang and Qipeng Phil Zheng.
A multistage stochastic programming approach for preventive maintenance scheduling of GENCOs with natural gas contract.
*European Journal of Operational Research*, 287(3):1036–1051, 2020.
doi: 10.1016/j.ejor.2020.03.036.
- Hubbs et al. [2020]
Christian D. Hubbs, Hector D. Perez, Owais Sarwar, Nikolaos V. Sahinidis, Ignacio E. Grossmann, and John M. Wassick.
OR-Gym: A Reinforcement Learning Library for Operations Research Problems.
*arXiv preprint arXiv:2008.06319*, 2020.
doi: 10.48550/arXiv.2008.06319.
- Hung et al. [2025]
Wei Hung, Shao-Hua Sun, and Ping-Chun Hsieh.
Efficient action-constrained reinforcement learning via acceptance-rejection method and augmented mdps.
*arXiv preprint arXiv:2503.12932*, 2025.
URL [https://arxiv.org/abs/2503.12932](https://arxiv.org/abs/2503.12932).
- Ji et al. [2023]
Jiaming Ji, Borong Zhang, Jiayi Zhou, Xuehai Pan, Weidong Huang, Ruiyang Sun, Yiran Geng, Yifan Zhong, Josef Dai, and Yaodong Yang.
Safety gymnasium: A unified safe reinforcement learning benchmark.
*Advances in Neural Information Processing Systems*, 36:18964–18993, 2023.
- Ji et al. [2024]
Jiaming Ji, Jiayi Zhou, Borong Zhang, Juntao Dai, Xuehai Pan, Ruiyang Sun, Weidong Huang, Yiran Geng, Mickel Liu, and Yaodong Yang.
Omnisafe: An infrastructure for accelerating safe reinforcement learning research.
*Journal of Machine Learning Research*, 25(285):1–6, 2024.
- Knueven et al. [2020]
Bernard Knueven, James Ostrowski, and Jean-Paul Watson.
On mixed-integer programming formulations for the unit commitment problem.
*INFORMS Journal on Computing*, 32(4):857–876, 2020.
doi: 10.1287/ijoc.2019.0944.
- Li et al. [2022]
Can Li, Antonio J Conejo, Peng Liu, Benjamin P Omell, John D Siirola, and Ignacio E Grossmann.
Mixed-integer linear programming models and algorithms for generation and transmission expansion planning of power systems.
*European Journal of Operational Research*, 297(3):1071–1082, 2022.
- Lillicrap et al. [2019]
Timothy P. Lillicrap, Jonathan J. Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David Silver, and Daan Wierstra.
Continuous control with deep reinforcement learning.
2019.
URL [https://arxiv.org/abs/1509.02971](https://arxiv.org/abs/1509.02971).
- Pantelides [1994]
Constantinos C Pantelides.
Unified frameworks for optimal process planning and scheduling.
In *Proceedings on the second conference on foundations of computer aided operations*, pages 253–274, 1994.
- Park et al. [2025]
Joonsoo Park, Hyein Jung, Jong Woo Kim, and Jong Min Lee.
Reinforcement learning for process control: Review and benchmark problems.
*International Journal of Control, Automation and Systems*, 23(1):1–40, 2025.
- Perez et al. [2021]
Hector D Perez, Christian D Hubbs, Can Li, and Ignacio E Grossmann.
Algorithmic approaches to inventory management optimization.
*Processes*, 9(1):102, 2021.
- Pesántez et al. [2024]
Gabriel Pesántez, Wilian Guamán, José Córdova, Miguel Torres, and Pablo Benalcazar.
Reinforcement learning for efficient power systems planning: A review of operational and expansion strategies.
*Energies*, 17(9), 2024.
ISSN 1996-1073.
doi: 10.3390/en17092167.
URL [https://www.mdpi.com/1996-1073/17/9/2167](https://www.mdpi.com/1996-1073/17/9/2167).
- Piansky et al. [2024]
Ryan Piansky, Georgia Stinchfield, Alyssa Kody, Daniel K Molzahn, and Jean-Paul Watson.
Long duration battery sizing, siting, and operation under wildfire risk using progressive hedging.
*arXiv preprint arXiv:2404.12296*, 2024.
- Ramanujam and Li [2025]
Asha Ramanujam and Can Li.
A tutorial on multi-time scale optimization models and algorithms.
*arXiv preprint arXiv:2502.20568*, 2025.
- Rardin and Rardin [1998]
Ronald L Rardin and Ronald L Rardin.
*Optimization in operations research*, volume 166.
Prentice Hall Upper Saddle River, NJ, 1998.
- Ray et al. [2019]
Alex Ray, Joshua Achiam, and Dario Amodei.
Benchmarking Safe Exploration in Deep Reinforcement Learning.
2019.
- Schulman et al. [2015]
John Schulman, Sergey Levine, Pieter Abbeel, Michael Jordan, and Philipp Moritz.
Trust region policy optimization.
In Francis Bach and David Blei, editors, *Proceedings of the 32nd International Conference on Machine Learning*, volume 37 of *Proceedings of Machine Learning Research*, pages 1889–1897, 2015.
- Todorov et al. [2012]
Emanuel Todorov, Tom Erez, and Yuval Tassa.
MuJoCo: A physics engine for model-based control.
In *Proc. IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS)*, pages 5026–5033, 2012.
doi: 10.1109/IROS.2012.6386109.
- Xenos et al. [2016]
Dionysios P. Xenos, Georgios M. Kopanos, Matteo Cicciotti, and Nina F. Thornhill.
Operational optimization of networks of compressors considering condition-based maintenance.
*Computers & Chemical Engineering*, 84:117–131, 2016.
doi: 10.1016/j.compchemeng.2015.08.008.
- Xu et al. [2021]
Tengyu Xu, Yingbin Liang, and Guanghui Lan.
Crpo: A new approach for safe reinforcement learning with convergence guarantee.
In Marina Meila and Tong Zhang, editors, *Proceedings of the 38th International Conference on Machine Learning*, volume 139 of *Proceedings of Machine Learning Research*, pages 11480–11491, 2021.
- Yeh et al. [2023]
Christopher Yeh, Victor Li, Rajeev Datta, Julio Arroyo, Nicolas Christianson, Chi Zhang, Yize Chen, Mohammad Mehdi Hosseini, Azarang Golmohammadi, Yuanyuan Shi, et al.
Sustaingym: Reinforcement learning environments for sustainable energy systems.
*Advances in Neural Information Processing Systems*, 36:59464–59476, 2023.
- Zhang et al. [2022]
Linrui Zhang, Li Shen, Long Yang, Shixiang Chen, Xueqian Wang, Bo Yuan, and Dacheng Tao.
Penalized proximal policy optimization for safe reinforcement learning.
In Lud De Raedt, editor, *Proceedings of the Thirty-First International Joint Conference on Artificial Intelligence, IJCAI-22*, pages 3744–3750. International Joint Conferences on Artificial Intelligence Organization, 2022.
- Zhang et al. [2015]
Qi Zhang, Ignacio E. Grossmann, Clara F. Heuberger, Arul Sundaramoorthy, and Jose M. Pinto.
Air separation with cryogenic energy storage: Optimal scheduling considering electric energy and reserve markets.
*AIChE Journal*, 61(5):1547–1558, 2015.
doi: 10.1002/aic.14730.

## Supplementary Material

## Appendix A Problem Environment Description

### A.1 Resource Task Network Environment ( RTNEnv )

#### A.1.1 Overview

The Resource Task Network (RTN) [18] is a mathematical modeling framework used for plant scheduling problems. It optimally schedules a set of interdependent production tasks executed on equipment, which transform reactants into products via intermediates. The full set of reactants, intermediates, products, and equipment are collectively referred to as resources. Products are produced to fulfill time-varying demand while minimizing operational costs. The RTNEnv simulates this system in discrete time, where the agent chooses task batch sizes at each timestep and observes the resulting state transitions, constraint violations, and rewards.

#### A.1.2 Problem Setup

The RTN is defined over a finite time horizon $T$. Reactants, intermediates, products, equipment, tasks, and utilities are defined as follows:

- •
Reactants: Consumable raw materials that can be ordered (at a cost).
- •
Intermediates: Internally produced and consumed materials. Cannot be ordered or sold.
- •
Products: Final deliverables with external demand and associated revenue and penalty structures.
- •
Equipments: Units required for task execution. Each is consumed when a task starts and returned after the task completes.
- •
Tasks: Tasks produce a subset of resources from another distinct subset of resources using a subset of equipments after a specified time period.
- •
Utilities: Time-varying operational costs incurred per unit utility consumed by tasks.
- •
Demand: Defined only for products, specifying $d_{p,t}$ at each timestep $t$.

##### Sets

- •
$\mathcal{R}$: All resources (reactants, intermediates, products, equipment)
- •
$\mathcal{R}^{\text{react}}$: Reactants
- •
$\mathcal{R}^{\text{int}}$: Intermediates
- •
$\mathcal{R}^{\text{prod}}$: Products
- •
$\mathcal{R}^{\text{equip}}$: Equipments
- •
$\mathcal{R}^{\text{pend}}\subset\mathcal{R}^{\text{int}}\cup\mathcal{R}^{\text
{prod}}\cup\mathcal{R}^{\text{equip}}$: Resources which are produced/replenished.
- •
$\mathcal{I}$: Tasks
- •
$\mathcal{K}_{i}\subset\mathcal{R}^{\text{equip}}$: Equipment used by task $i$
- •
$\mathcal{U}$: Utilities
- •
$\mathcal{U}_{i}\subset\mathcal{U}$: Utilities consumed by task $i$

##### Parameters

- •
$T$: Time horizon
- •
$\tau_{i}$: Processing time of task $i$
- •
$\tau_{\text{max}}=\max\limits_{i}\tau_{i}$ : Maximum processing time.
- •
$V_{i}^{\min},V_{i}^{\max}$: Batch size bounds for task $i$
- •
$X_{r}^{0},X_{r}^{\min},X_{r}^{\max}$: Initial and bounded inventories for resource $r$
- •
$\nu_{i,r}$: Stoichiometric coefficient of resource $r$ in task $i$
- •
$\text{cost}_{r}$: Unit cost of ordering reactant $r$
- •
$\text{price}_{p}$: Unit price of product $p$
- •
$d_{p,t}$: Demand for product $p$ at time $t$
- •
$u_{u,t}$: Cost of utility $u$ at time $t$
- •
$\lambda_{\text{sanit}}$: Sanitization penalty coefficient
- •
$\mathbb{I}[\cdot]$: Indicator function
- •
$\oplus$ : vector concatenation

#### A.1.3 State Space

At timestep $t$, the agent observes:

- •
Inventory vector $X_{t}\in\mathbb{R}^{|\mathcal{R}|}$ : Inventory of all resources.
- •
Pending outputs $p_{t}\in\mathbb{R}^{\tau_{\max}\times|\mathcal{R}^{\text{pend}}|}$ : Intermediates and products which will be delivered in upcoming timesteps.
- •
Future demand $fd_{t}\in\mathbb{R}^{T\times|\mathcal{R}^{\text{prod}}|}$ : Demand of all products from timestep $t$ to $T$, post-padded with 0 0s to maintain consistent shapes.

#### A.1.4 Action Space

The action $a_{t}\in[-1,1]^{|\mathcal{I}|}$ is scaled to batch sizes via:

$$ $a^{\text{scaled}}_{i,t}=\frac{a_{i,t}+1}{2}\cdot(V_{i}^{\max}-V_{i}^{\min})+V_ {i}^{\min}$ $$

For numerical stability, any $|a_{i,t}|\leq 10^{-3}$ is set to 0 0.

#### A.1.5 Transition Dynamics

At each step:

- 1.
Sanitize Action: Prevent resource violations and enforce equipment availability by calculating the maximum inventory available for a resource, maximum batch size that can be processed based on inventory levels, and clipping between the batch size bounds accordingly.
$\begin{split}b_{i,r,t}\;&=\;\frac{\max(0,X_{r,t}-X_{r}^{\min})}{|\nu_{i,r}|}\\
b_{i,t}\;&=\;\min\limits_{r}b_{i,r,t}\\
a_{i}^{\text{clip}}\;&=\;0\;\;\text{if }b_{i,t}<V_{i}^{\min}\\
a_{i,t}^{\text{final}}\;&=\;\begin{cases}0,&\text{if }\exists e\in\mathcal{K}_
{i}\text{ with }X_{e,t}=0\\
a_{i}^{\text{clip}},&\text{otherwise}\end{cases}\end{split}$
- 2.
Inventory Update: Consumes the inputs to a task immediately.
$X_{r,t+1}=X_{r,t}+\sum_{i}\min(\nu_{i,r},0)\cdot a_{i,t}^{\text{final}}$
- 3.
Pending Outputs: Add outputs of a task to the pending output buffer and update inventory of resources that are being delivered in the next timestep.
$\begin{split}X_{r,t+1}\;&=\;X_{r,t}+p_{t,r,0}\\
p_{t}\;&=\;p_{t-1,r,1:\tau_{\text{max}}}\oplus\sum\limits_{i}\max\{\nu_{i,r},0
\}\cdot a_{i,t}^{\text{final}}\\
\end{split}$
(1)
- 4.
Inventory Enforcement: Ensures inventory bounds are not violated. A part of the cost is calculated based on this. Refer to [A.1.6](https://arxiv.org/html/2506.02255v1#A1.SS1.SSS6).
$X_{r,t+1}=\min(X_{r}^{\max},\max(X_{r}^{\min},X_{r,t+1}))$

#### A.1.6 Cost Function

The total cost at each timestep $t$ is given by:

$$ $C_{t}=C_{t}^{\text{lb}}+C_{t}^{\text{ub}}+C_{t}^{\text{eq}}+\lambda_{\text{ sanit}}C_{t}^{\text{sanit}}$ $$

- •
Bound Violation: Penalizes the resource inventory going out of bounds. (Reactants going below lower bounds are assumed to imply ordering of reactants).
$C_{t}^{\text{lb}}=\sum_{r\in\mathcal{R}^{\text{int}}\cup\mathcal{R}^{\text{
prod}}}\mathbb{I}[X_{r,t}<X_{r}^{\min}]$
$C_{t}^{\text{ub}}=\sum_{r\in\mathcal{R}}\mathbb{I}[X_{r,t}>X_{r}^{\max}]$
- •
Equipment Feasibility Cost: Penalizes execution of tasks when any required equipment is unavailable.
$C_{t}^{\text{eq}}=\sum_{i}\sum_{e\in\mathcal{K}_{i}}\mathbb{I}[a_{i,t}^{\text{
final}}>0]\cdot\mathbb{I}[X_{e,t}<1]$
- •
Sanitization Cost: Penalizes deviations between the raw and final actions due to constraint handling.
$C_{t}^{\text{sanit}}=\sum_{i}\left|a_{i,t}^{\text{final}}-a_{i,t}^{\text{
scaled}}\right|$

#### A.1.7 Reward Function

The total reward at each timestep $t$ is:

$$ $\Pi_{t}=\Pi_{t}^{\text{rev}}-\Pi_{t}^{\text{util}}-\Pi_{t}^{\text{unmet}}-\Pi_ {t}^{\text{order}}$ $$

- •
Revenue: Earned by fulfilling product demand, constrained by available inventory.
$\Pi_{t}^{\text{rev}}=\sum_{p\in\mathcal{R}^{\text{prod}}}\min(X_{p,t}-X_{p}^{
\min},d_{p,t})\cdot\text{price}_{p}$
- •
Unmet Demand Penalty: Penalizes unmet product demand at 1.5× product price.
$\Pi_{t}^{\text{unmet}}=1.5\cdot\sum_{p\in\mathcal{R}^{\text{prod}}}\max(d_{p,t
}-(X_{p,t}-X_{p}^{\min}),0)\cdot\text{price}_{p}$
- •
Reactant Ordering Cost: Charged when reactant inventory drops below zero (interpreted as external procurement)
$\Pi_{t}^{\text{order}}=\sum_{r\in\mathcal{R}^{\text{react}}}\max(-X_{r,t},0)
\cdot\text{cost}_{r}$
- •
Utility Cost: Incurred from executing tasks using utilities.
$\Pi_{t}^{\text{util}}=\sum_{i}\sum_{j\in\mathcal{U}_{i}}a_{i,t}^{\text{final}}
\cdot u_{j,t}$

#### A.1.8 Episode Termination

The episode ends when $t=T$. Truncation does not occur even under constraint violations.

### A.2 State Task Network ( STNEnv )

#### A.2.1 Overview

The State Task Network (STN) [18] is a mathematical modeling framework for short-term production scheduling. It focuses on scheduling a set of production tasks on processing units, where each task transforms material states over time. Unlike the RTN, which models resources more abstractly, the STN emphasizes the evolution of material states through task execution and transfer between units. The objective is to satisfy time-varying demand for final products while minimizing operational costs. The STNEnv simulates this system in discrete time, where an agent selects task batch sizes on specific units at each timestep and observes the resulting state transitions, constraint violations, and rewards.

#### A.2.2 Problem Setup

The STN is defined over a finite time horizon $T$. Material states, processing units, tasks, and utilities are defined as follows:

- •
Reactants: Consumable raw materials that can be externally procured at a cost. They serve as initial inputs to tasks.
- •
Intermediates: Internally produced and consumed materials. They are used to link tasks within the network. Intermediates cannot be purchased or sold externally.
- •
Products: Final deliverables for which external demand is specified. Products may generate revenue if delivered on time and incur penalties if demand is unmet.
- •
Units: Processing equipment on which tasks are scheduled. Each unit can process at most one task at a time and becomes available again after the task’s processing duration.
- •
Tasks: Operations that transform a subset of input states into a subset of output states on a designated unit. Each task has a fixed processing time, specific unit assignment, defined stoichiometry, and utility consumption profile.
- •
Utilities: Operational resources (e.g., electricity, steam) with time-varying costs. Each task consumes a fixed amount of utilities per unit batch size, incurring operational costs accordingly.
- •
Demand: Defined only for product states, specifying $d_{s,t}$ for state $s$ at time $t$. Demand fulfillment yields revenue, while shortages incur penalties.

##### Sets

- •
$\mathcal{S}$: All material states (reactants, intermediates, products)
- •
$\mathcal{S}^{\text{react}}\subset\mathcal{S}$: Reactants (raw materials)
- •
$\mathcal{S}^{\text{int}}\subset\mathcal{S}$: Intermediates (internal materials)
- •
$\mathcal{S}^{\text{prod}}\subset\mathcal{S}$: Products (deliverables)
- •
$\mathcal{S}^{\text{pend}}\subset\mathcal{S}^{\text{int}}\cup\mathcal{S}^{\text
{prod}}$: States that are produced (i.e., replenished by tasks)
- •
$\mathcal{I}$: Tasks
- •
$\mathcal{E}$: Equipment units
- •
$\mathcal{K}_{i}\subset\mathcal{E}$: Set of units on which task $i$ can be scheduled
- •
$\mathcal{U}$: Utilities
- •
$\mathcal{U}_{i}\subset\mathcal{U}$: Utilities consumed by task $i$

##### Parameters

- •
$T$: Time horizon
- •
$\tau_{i}$: Processing time of task $i$
- •
$\tau_{\text{max}}=\max\limits_{i}\tau_{i}$: Maximum processing time
- •
$V_{i,e}^{\min},V_{i,e}^{\max}$: Batch size bounds for task $i$ by using equipment $e$.
- •
$X_{s}^{0},X_{s}^{\min},X_{s}^{\max}$: Initial and bounded inventories for state $s$
- •
$\nu_{i,s}$: Stoichiometric coefficient of state $s$ in task $i$ (negative if consumed, positive if produced)
- •
$\text{cost}_{s}$: Unit cost of ordering reactant $s\in\mathcal{S}^{\text{react}}$
- •
$\text{price}_{p}$: Unit price of product $p\in\mathcal{S}^{\text{prod}}$
- •
$d_{p,t}$: Demand for product $p$ at time $t$
- •
$u_{u,t}$: Cost of utility $u$ at time $t$
- •
$\lambda_{\text{sanit}}$: Sanitization penalty coefficient (for equipment reuse)
- •
$\mathbb{I}[\cdot]$: Indicator function
- •
$\oplus$ : vector concatenation

#### A.2.3 State Space

At timestep $t$, the agent observes:

- •
Inventory vector $X_{t}\in\mathbb{R}^{|\mathcal{S}|}$ : Inventory of all material states.
- •
Pending outputs $p_{t}\in\mathbb{R}^{\tau_{\max}\times|\mathcal{S}^{\text{pend}}|}$ : Intermediates and products scheduled to be produced in future timesteps due to ongoing tasks.
- •
Future demand $fd_{t}\in\mathbb{R}^{T\times|\mathcal{S}^{\text{prod}}|}$ : Demand for all product states from timestep $t$ to $T$, post-padded with 0 0s to maintain consistent shapes.

#### A.2.4 Action Space

The action $a_{t}\in[-1,1]^{|\mathcal{I}\times\mathcal{E}|}$ represents a normalized matrix over task-equipment pairs and is scaled to batch sizes via:

$$ $a^{\text{scaled}}_{i,e,t}=\frac{a_{i,e,t}+1}{2}\cdot(V_{i,e}^{\max}-V_{i,e}^{ \min})+V_{i,e}^{\min}$ $$

For numerical stability, any $|a_{i,e,t}|\leq 10^{-3}$ is set to 0 0.

#### A.2.5 Transition Dynamics

At each step:

- 1.
Sanitize Action: Prevent state violations and enforce unit availability by calculating the maximum available inventory for each input state, the maximum feasible batch size given current inventories, and clipping between the allowed batch size bounds accordingly.
$\begin{split}b_{i,s,t}\;&=\;\frac{\max(0,X_{s,t}-X_{s}^{\min})}{|\nu_{i,s}|}\\
b_{i,t}\;&=\;\min\limits_{s\in\mathcal{S}:\nu_{i,s}<0}b_{i,s,t}\\
a_{i,e,t}^{\text{clip}}\;&=\;0\;\;\text{if }b_{i,t}<V_{i,e}^{\min}\\
a_{i,e,t}^{\text{final}}\;&=\;\begin{cases}0,&\text{if }e\notin\mathcal{K}_{i}
\text{ or }X_{e,t}=0\\
a_{i,e,t}^{\text{clip}},&\text{otherwise}\end{cases}\end{split}$
- 2.
Inventory Update: Immediately consumes the input states required by the activated tasks.
$X_{s,t+1}=X_{s,t}+\sum_{e}\sum_{i}\min(\nu_{i,s},0)\cdot a_{i,e,t}^{\text{
final}}$
- 3.
Pending Outputs: Add the output states of tasks to the pending output buffer and update inventories of materials delivered at the current timestep.
$\begin{split}X_{s,t+1}\;&=\;X_{s,t}+p_{t,s,0}\\
p_{t+1,s}\;&=\;p_{t,s,1:\tau_{\max}}\oplus\sum_{e}\sum_{i}\max(\nu_{i,s},0)
\cdot a_{i,e,t}^{\text{final}}\end{split}$
(2)
- 4.
Inventory Enforcement: Enforces inventory bounds to prevent overflow or underflow. Violations of these bounds contribute to the constraint cost.
$X_{s,t+1}=\min(X_{s}^{\max},\max(X_{s}^{\min},X_{s,t+1}))$

#### A.2.6 Cost Function

The total cost at each timestep $t$ is given by:

$$ $C_{t}=C_{t}^{\text{lb}}+C_{t}^{\text{ub}}+C_{t}^{\text{eq}}+\lambda_{\text{ sanit}}C_{t}^{\text{sanit}}$ $$

- •
Bound Violation: Penalizes material inventory going out of bounds. (Reactants going below their lower bounds are interpreted as triggering procurement costs.)
$C_{t}^{\text{lb}}=\sum_{s\in\mathcal{S}^{\text{int}}\cup\mathcal{S}^{\text{
prod}}}\mathbb{I}[X_{s,t}<X_{s}^{\min}]$
$C_{t}^{\text{ub}}=\sum_{s\in\mathcal{S}}\mathbb{I}[X_{s,t}>X_{s}^{\max}]$
- •
Equipment Feasibility Cost: Penalizes task executions on unavailable units.
$C_{t}^{\text{eq}}=\sum_{i}\sum_{e\in\mathcal{K}_{i}}\mathbb{I}[a_{i,e,t}^{
\text{final}}>0]\cdot\mathbb{I}[X_{e,t}<1]$
- •
Sanitization Cost: Penalizes deviation between scaled and final actions due to sanitization (inventory or equipment infeasibility).
$C_{t}^{\text{sanit}}=\sum_{i,e}\left|a_{i,e,t}^{\text{final}}-a_{i,e,t}^{\text
{scaled}}\right|$

#### A.2.7 Reward Function

The total reward at each timestep $t$ is:

$$ $\Pi_{t}=\Pi_{t}^{\text{rev}}-\Pi_{t}^{\text{util}}-\Pi_{t}^{\text{unmet}}-\Pi_ {t}^{\text{order}}$ $$

- •
Revenue: Earned by fulfilling product demand, constrained by available inventory.
$\Pi_{t}^{\text{rev}}=\sum_{p\in\mathcal{S}^{\text{prod}}}\min(X_{p,t}-X_{p}^{
\min},d_{p,t})\cdot\text{price}_{p}$
- •
Unmet Demand Penalty: Penalizes unmet product demand at $1.5\times$ the product price.
$\Pi_{t}^{\text{unmet}}=1.5\cdot\sum_{p\in\mathcal{S}^{\text{prod}}}\max(d_{p,t
}-(X_{p,t}-X_{p}^{\min}),0)\cdot\text{price}_{p}$
- •
Reactant Ordering Cost: Incurred when reactant inventory falls below zero (interpreted as external procurement).
$\Pi_{t}^{\text{order}}=\sum_{s\in\mathcal{S}^{\text{react}}}\max(-X_{s,t},0)
\cdot\text{cost}_{s}$
- •
Utility Cost: Accrued from task executions that consume utilities, priced per unit usage and per unit batch size.
$\Pi_{t}^{\text{util}}=\sum_{i,e}\sum_{j\in\mathcal{U}_{i}}a_{i,e,t}^{\text{
final}}\cdot u_{j,t}$

#### A.2.8 Episode Termination

The episode ends when $t=T$. Truncation does not occur even under constraint violations.

### A.3 Unit Commitment ( UCEnv )

#### A.3.1 Overview

The unit commitment problem is one of the most widely used optimization problems in power systems, aiming to minimize the operational costs of power generation over a specified planning horizon by determining optimal decisions for switching power units on or off and managing power dispatch [15]. These decisions must comply with safety requirements and fulfill various operational goals. In practice, the unit commitment problem is solved in advance on a rolling basis, as future electricity demand is uncertain and must be forecasted continually once new information becomes available. The growth of renewable energy sources and fluctuations in the electricity markets further increase the uncertainties in demand forecasts. Due to the size of power systems in the real world, solving the resulting MILP or MIQCP problem on time can be prohibitively difficult. Therefore, the development of efficient solution methods that can respond to frequent forecast updates is of significant interest. In this study, we formulate the unit commitment problem as a CMDP and implement it as the environment UCEnv. To support safe sequential decision making in power scheduling and dispatch, practical constraints, such as minimum up and down time, ramping constraints, and reserve requirements, are incorporated into the environment. Given the complexity of unit commitment problem, the environment is provided in two versions. The UCEnv-v0 version assumes a single-bus system, while UCEnv-v1 requires an agent to take into account distributed power demands and power flows within a transmission network.

#### A.3.2 Problem Setup

##### Sets

- •
$\mathcal{G}$: the set of generators.
- •
$\mathcal{N}$: the set of buses.
- •
$\mathcal{K}$: the set of transmission lines.
- •
$\mathcal{G}_{n}$: the set of generators that is connected to the $n$ bus.
- •
$k(n)$: the from-bus for the $k$th transmission line.
- •
$k(m)$: the to-bus for the $k$th transmission line.
- •
$\delta^{+}(n)$: the set of transmission line for the to-bus $n$.
- •
$\delta^{-}(n)$: the set of transmission line for the from-bus $n$.

##### Parameters

- •
$(a_{i},b_{i},c_{i})$: quadratic, linear, and constant cost coefficients of power generation.
- •
$C^{v}_{i}$: startup cost coefficients.
- •
$C^{w}_{i}$: shutdown cost coefficients.
- •
$UT_{i}$: minimum up time.
- •
$DT_{i}$: minimum down time.
- •
$RU_{i}$: ramp-up rate.
- •
$RD_{i}$: ramp-down rate.
- •
$SU_{i}$: start-up rate.
- •
$SD_{i}$: shut-down rate.
- •
$P_{\max i}$: maximum power output.
- •
$P_{\min i}$: minimum power output.
- •
$\Theta_{\max n}$: maximum voltage angle.
- •
$\Theta_{\min n}$: minimum voltage angle.
- •
$F_{\max k}$: maximum transmission capacity.
- •
$F_{\min k}$: minimum transmission capacity.
- •
$D_{n,t}$; time-varying power demand.
- •
$C^{LS}$: load shedding cost coefficient for failure to meet load.
- •
$C^{R}$: reserve shortfall cost coefficient for failure to meet the reserve requirement.
- •
$R$: system-wide reserve requirement

#### A.3.3 State Space

The state $s_{t}$ includes the following components:

- •
$u_{i,t}^{\text{seq}}=[u_{i,t},u^{\text{old}}_{i,t}]\in\{0,1\}^{\max(UT_{i},DT_
{i})+1}$: a sequence of binary indicators about the on-off status of the generator $i\in\mathcal{G}$, where $u^{\text{old}}_{i,t}$ records the history in the most recent time periods before $t$, used to track compliance with the up/down time. The dimension of this variable is $\sum_{i\in\mathcal{G}}(\max(UT_{i},DT_{i})+1)$.
- •
$p_{i,t}\in[P_{\min i},P_{\max i}]$: power output of the generator $i\in\mathcal{G}$. The dimension of this variable is $|\mathcal{G}|$.
- •
$\theta_{n,t}\in[\Theta_{\min n},\Theta_{\max n}]$: voltage angle of the bus $n\in\mathcal{N}$. The dimension of this variable is $|\mathcal{N}|$. In the simpler version, UCEnv-v0, the environment is assumed to be a single-bus system where the voltage angle is not considered.
- •
$D_{n,t+1:t+W}\in\mathbb{R}_{\geq 0}^{W}$: forecast demand of the bus $n\in\mathcal{N}$ with a window length of $W$. The dimension of this variable is $|\mathcal{N}|\times W$. When the window extends beyond the episode horizon, it uses the forecast demand from the following steps.

The full observation is flattened into a continuous vector space for reinforcement learning (RL) training.

#### A.3.4 Action Space

At each time step $t$, the agent takes the following actions $a_{t}$:

- •
$u_{i,t+1}\in\{0,1\}$: on/off status of the generator $i\in\mathcal{G}$. The dimension of this variable is $|\mathcal{G}|$.
- •
$p_{i,t+1}\in[P_{\min i},P_{\max i}]$: power output of the generator $i\in\mathcal{G}$. The dimension of this variable is $|\mathcal{G}|$.
- •
$\theta_{n,t+1}\in[\Theta_{\min n},\Theta_{\max n}]$: voltage angle of the bus $n\in\mathcal{N}$, where $\theta_{1,t+1}=0$ is always fixed as reference. The dimension of this variable is $|\mathcal{N}|-1$.

These decision variables are initially normalized to a continuous action space $a_{t}\in[-1,1]^{n}$ and then mapped to their actual values within their bounds.

#### A.3.5 Transition Dynamics

Given the action $a_{t}$, the next state $s_{t+1}$ is computed as follows.

Intermeidate state, turn-on and turn-off status and sequence:
First, we compute the intermediate states $v_{i,t+1}$, $w_{i,t+1}$ as well as the sequences $v_{i,t+1}^{\text{seq}}$ and $w_{i,t+1}^{\text{seq}}$. These intermediate states serve as a practical representation of whether a generator has recently been activated or deactivated, facilitating the subsequent computation of costs, violations, and rewards.

$$ $v_{i,t+1}=\max(0,u_{i,t+1}-u_{i,t})$ $$

$$ $w_{i,t+1}=-\min(0,u_{i,t+1}-u_{i,t})$ $$

$$ $v_{i,t+1}^{\text{seq}}=\left[v_{i,t+1},v^{\text{old}}_{i,t}\left[:-1\right]\right]$ $$

$$ $w_{i,t+1}^{\text{seq}}=\left[w_{i,t+1},w^{\text{old}}_{i,t}\left[:-1\right]\right]$ $$

##### Check and repair on-off status

Next, we check the feasibility of the on-off status. The first inequality evaluates the minimum up-time constraint, ensuring the $i$th generator remains on for a specified number of time periods, $UT_{i}$, before shutdown. The second inequality evaluates the minimum down-time constraint, which requires the $i$th generator to have a minimum off duration, $DT_{i}$, before restart. These constraints prevent excessive wear-and-tear resulting from frequent cycling. The violation indicates the power generator that must be kept on and off, respectively. The values of $u_{i,t+1}$ of the must-on generators (must-off generators) are then corrected to $1$ (0 0).

$$ $u_{i,t+1}^{\text{r}}=\begin{cases}1,&\text{if }\sum v_{i,t+1}^{\text{seq}}>u_{ i,t+1}\\ 0,&\text{elif }\sum w_{i,t+1}^{\text{seq}}>1-u_{i,t+1}\\ u_{i,t+1},&\text{otherwise }\end{cases}$ $$

##### Update sequence of on-off status

:
After checking and repairing the on-off status, their sequence is updated:

$$ $\mathbf{u}_{i,t+1}=\left[u_{i,t+1}^{\text{r}},u^{\text{old}}_{i,t}\left[:-1 \right]\right]$ $$

Check and repair power output
We proceed to check the violations of the ramping constraints. The first inequality evaluates the ramp-up constraint, and the second inequality evaluates the ramp-down constraint. These constraints impose limits on the rate at which a generator increases or decreases its output between consecutive time steps, reflecting the physical capabilities of generators. The violation indicates the power generation that must be kept within a tighter bound based on the repaired on-off status.

$$ $p_{i,t+1}^{\text{r}}=\begin{cases}p_{i,t}+RU_{i}\cdot u_{i,t}+SU_{i}\cdot v_{i ,t+1}^{\text{r}},&\text{if }p_{i,t+1}-p_{i,t}>RU_{i}\cdot u_{i,t}+SU_{i}\cdot v _{i,t+1}^{\text{r}}\\ p_{i,t}-RD_{i}\cdot u_{i,t+1}^{\text{r}}-SD_{i}\cdot w_{i,t+1}^{\text{r}},& \text{elif }p_{i,t}-p_{i,t+1}>RD_{i}\cdot u_{i,t+1}^{\text{r}}+SD_{i}\cdot w_{ i,t+1}^{\text{r}}\\ p_{i,t+1},&\text{otherwise }\end{cases}$ $$

##### Update power output

:
The power output is then updated by multiplying it with its on-off status.

$$ $p_{i,t+1}=u_{i,t+1}^{\text{r}}\cdot p_{i,t+1}^{\text{r}}$ $$

##### Update voltage angle

$$ $\theta_{n,t+1}=\theta_{n,t+1}$ $$

##### Intermeidate state, load unfulfillment and power reserve

We compute the following intermediate states to ease the computation of rewards.

$$ $f_{k,t+1}=B_{k}(\theta_{k(n),t+1}-\theta_{k(m),t+1})$ $$

$$ $f_{k,t+1}^{\text{r}}=\max\big{(}\min(F_{\max k},f_{k,t+1}),F_{\min k}\big{)}$ $$

$$ $s_{n,t+1}=\max\big{(}D_{n,t+1}-\sum_{i\in\mathcal{G}_{n}}p_{i,t+1}-\sum_{k\in \delta^{+}(n)}f_{k,t+1}^{\text{r}}+\sum_{k\in\delta^{-}(n)}f_{k,t+1}^{\text{r} },0\big{)}$ $$

$$ $r_{i,t+1}=\max\big{(}\min(P_{\max i}\cdot u_{i,t+1}-p_{i,t+1},RU_{i}\cdot u_{i ,t}+SU_{i}\cdot v_{i,t+1}),0\big{)}$ $$

Although the power flow $f_{k,t+1}$ is clipped for subsequent computation, the voltage angles $\theta_{n,t+1}$ are not repaired accordingly because future states are independent of $\theta_{n,t+1}$ and they will not accumulate further violations.

##### Demand forecast

:

$$ $D_{n,t+2:t+W+1}=\text{forecast}(D_{n,t+1:t+W})$ $$

#### A.3.6 Cost Function

##### Minimum up-time & down-time violations

:
The penalty for correcting invalid on-off status decisions is the number of minimum up-time and down-time violations multiplied by a penalty factor. The violations represent that the agent attempted to turn off a power unit that must be kept on or turn on a power unit that must be kept off at the current time step.

$$ $C^{\text{UTDT}}_{t}=\sum_{i}P\cdot\mathbb{I}\big{(}\sum v_{i,t+1}^{\text{seq}} >u_{i,t+1}\lor\sum w_{i,t+1}^{\text{seq}}>1-u_{i,t+1}\big{)}$ $$

##### Ramp-up & ramp-down violations

: The penalty for correcting invalid power output decisions is the magnitude of ramp-up and ramp-down violations multiplied by a penalty factor. The violations represent that the agent attempted to increase or decrease a power output too aggressively, which exceeds the generator’s allowable ramping limits between consecutive time steps.

$$ $C^{\text{Ramp}}_{t}=P\cdot\sum_{i}\max\big{(}p_{i,t+1}-p_{i,t}-RU_{i}\cdot u_{ i,t}-SU_{i}\cdot v_{i,t+1}^{\text{r}},p_{i,t}-p_{i,t+1}-RD_{i}\cdot u_{i,t+1}^ {\text{r}}-SD_{i}\cdot w_{i,t+1}^{\text{r}},0\big{)}$ $$

##### Transmission capacity violations

: The penalty for correcting invalid volatage angle decisions is the magnitude of transmission capacity violations multiplied by a penalty factor. The violations represent that the agent attempted to allocate an excessive or insufficient amount of power to other buses, exceeding or falling short of the transmission capacity.

$$ $C^{\text{Cap}}_{t}=P\cdot\sum_{k}\max\big{(}f_{k,t+1}-F_{\max k},F_{\min k}-f_ {k,t+1},0\big{)}\\$ $$

##### Total Cost

$$ $C_{t}=C^{\text{UTDT}}_{t}+C^{\text{Ramp}}_{t}+C^{\text{Cap}}_{t}$ $$

#### A.3.7 Reward Function

The agent receives a reward equal to the negative of the production generation cost, startup cost, shutdown cost, load shedding cost and reserve shortfall cost.

Production generation reward:

$$ $\Pi_{t}^{\text{pg}}=-\sum_{i}(a_{i}\cdot p_{i,t}^{2}+b_{i}\cdot p_{i,t}+c_{i})$ $$

Startup reward:

$$ $\Pi_{t}^{v}=-\sum_{i}(C^{v}_{i}\cdot v_{i,t})$ $$

Shutdown reward:

$$ $\Pi_{t}^{w}=-\sum_{i}(C^{w}_{i}\cdot w_{i,t})$ $$

Load shedding reward:

$$ $\Pi_{t}^{LS}=-C^{LS}\cdot\sum_{n}s_{n,t}$ $$

where $s_{n,t}$ represents the load unfulfillment at bus $n$.

Reserve shortfall reward:

$$ $\Pi_{t}^{R}=-C^{R}\cdot\max(R-\sum_{i}r_{i,t},0),$ $$

where $r_{i,t}$ represents the power that can be reserved at generator $i$.

Total reward:

$$ $\Pi_{t}=\Pi_{t}^{\text{pg}}+\Pi_{t}^{v}+\Pi_{t}^{LS}+\Pi_{t}^{R}$ $$

#### A.3.8 Episode Dynamics

The episode commences with the known sequence of the on-off status and power output from the preceding time step, and terminates after $T$ time steps.

### A.4 Generation and Transmission Expansion Planning( GTEPEnv )

#### A.4.1 Overview

The generation and transmission expansion problem is a critical planning task in power systems, aiming to determine when and where to install new generators and transmission lines to ensure adequate power supply amidst growing and spatially distributed demand. This problem is inherently combinatorial and must satisfy constraints such as the maximum number of generators in a region and overall demand satisfaction [16].

Because electricity demand varies over time and across regions, expansion decisions must be made periodically, turning the problem into a sequential decision-making process. Moreover, future demand is typically forecasted and therefore uncertain, necessitating a rolling planning framework in which decisions are continually updated as new information becomes available. This need is further heightened by the increasing integration of renewable energy sources and the growing volatility in energy consumption patterns, both of which introduce greater uncertainty into power system operations. As such, effective solutions must explicitly account for these uncertainties and remain flexible enough to adapt to frequent forecast revisions.
Keeping these considerations in mind, reinforcement learning (RL) offers a promising approach for addressing the generation and transmission expansion problem [21]. In particular, safe reinforcement learning techniques enable agents to learn actions that are more likely to be both feasible and near-optimal. To this end, we model the problem as a CMDP and implement it as the environment GTEPEnv, which supports decision-making regarding the installation of generators and transmission lines across different time periods and regions. We assume generators operate at full capacity and the cost for curtailment is negligible.

#### A.4.2 Problem Setup

We consider a multi-period generator and transmission expansion planning problem. The sets and known parameters used in the model are described below.

##### Sets

- •
$\mathcal{T}=\{1,\ldots,T\}$: Set of discrete time periods.
- •
$\mathcal{R}$: Set of regions.
- •
$\mathcal{G}$: Set of generator types.
- •
$\mathcal{L}\subseteq\mathcal{R}\times\mathcal{R}$: Set of candidate transmission lines, where each line is represented by a single directed pair $(r_{1},r_{2})$ with $r_{1}\neq r_{2}$. For any unordered pair $\{r_{1},r_{2}\}$, only one direction (e.g., $(r_{1},r_{2})$) is included in $\mathcal{L}$.

##### Parameters

- •
$\text{Dem}_{r,t}$: Electricity demand in region $r\in\mathcal{R}$ at time $t\in\mathcal{T}$.
- •
$\text{Cap}^{\text{gen}}_{i}$: Capacity of a single unit of generator type $i\in\mathcal{G}$.
- •
$C^{\text{inst,gen}}_{i}$: Installation cost of generator type $i$.
- •
$\text{Cap}^{\text{tl}}_{l}$: Transmission capacity of line $l\in\mathcal{L}$.
- •
$C^{\text{inst,tl}}_{l}$: Installation cost of transmission line $l$.
- •
$M_{i,r}$: Maximum number of generators of type $i$ that can be installed in region $r$.
- •
$\lambda_{0}$: Fixed penalty term (analogous to an $\ell_{0}$-style penalty to encourage sparsity).
- •
$\lambda_{2}$: Quadratic penalty coefficient (analogous to an $\ell_{2}$-style penalty to discourage overuse or smooth solutions).
- •
$k$: Window length for demand forecast
- •
$\epsilon$: A small threshold used to ignore negligible power flows

#### A.4.3 State Space

The state at each time step $t\in\mathcal{T}$, denoted $s_{t}$, includes the following components:

- •
$n_{i,r,t}\in\mathbb{Z}_{\geq 0}$, bounded by $[0,M_{i,r}]$: Number of generators of type $i\in\mathcal{G}$ installed in region $r\in\mathcal{R}$ at time $t\in\mathcal{T}$.
This component contributes a state dimension of $|\mathcal{G}|\times|\mathcal{R}|$.
- •
$nt_{l,t}\in\{0,1\}$: Binary indicator for whether transmission line $l\in\mathcal{L}$ is installed at time $t$. This contributes a dimension of $|\mathcal{L}|$.
- •
$Dem_{r,t+1:t+k}$: Forecasted demand in region $r\in\mathcal{R}$ from time $t+1$ to $t+k$, where $k$ is the forecasting window. This has a dimension of $|\mathcal{R}|\times k$. Entries are padded with zeros for time periods beyond the episode horizon.
- •
$t$: Current time index, optionally included to provide temporal context.

All components are concatenated and flattened into a continuous vector for use in reinforcement learning.

#### A.4.4 Action Space

At each time step $t\in\mathcal{T}$, the agent selects the following actions:

- •
$n^{\text{add}}_{i,r,t}\in[0,M_{i,r}]$: Number of generators of type $i\in\mathcal{G}$ to install in region $r\in\mathcal{R}$ at time $t$. This defines a decision space of dimension $|\mathcal{G}|\times|\mathcal{R}|$.
- •
$P_{l,t}\in[-\text{Cap}^{\text{tl}}_{l},\text{Cap}^{\text{tl}}_{l}]$: Power flow along transmission line $l=(r_{1},r_{2})\in\mathcal{L}$ at time $t$, where the direction of flow is from $r_{1}$ to $r_{2}$. This defines a space of dimension $|\mathcal{L}|$.

The bounds of the action space are given by the physical constraints on installation limits and transmission capacities.

For reinforcement learning, actions are normalized to $[-1,1]$ and then scaled back to their original ranges using:

$$ $a_{\text{actual}}=\frac{(a_{\text{normalized}}+1)}{2}\cdot(a_{\text{high}}-a_{ \text{low}})+a_{\text{low}}$ $$

#### A.4.5 Transition Dynamics

After scaling, we denote the set of actions by

$$ $\left\{n^{\text{add,action}}_{i,r,t},\quad P^{\text{action}}_{l,t}\right\}.$ $$

We first further process the actions by rounding the number of generators added to the nearest integer and setting negligible power flows to 0.

$$ $n^{\text{add,prebound}}_{i,r,t}=\text{round}(n^{\text{add,action}}_{i,r,t})$ $$

$$ $P_{l,t}=\begin{cases}0&\text{if }|P^{\text{action}}_{l,t}|\leq\epsilon\\ P^{\text{action}}_{l,t}&\text{otherwise}\end{cases}$ $$

We then increment $t$ to $t+1$.

##### Checking action for generator bounds:

Next, we proceed to check for violations of bounds in the state. The main focus is on checking for violations related to the number of generators in each region, as everything else has been accounted for in the scaling process. If the action results in a violation of the constraint, we adjust the action to ensure the state reaches the maximum possible configuration within the bounds.

$$ $n^{\text{add}}_{i,r,t}=\begin{cases}M_{i,r}-n_{i,r,t-1}&\text{if }n_{i,r,t-1}+ n^{\text{add,prebound}}_{i,r,t}>M_{i,r}\\ n^{\text{add,prebound}}_{i,r,t}&\text{otherwise}\end{cases}$ $$

After sanitizing the actions and ensuring the state satisfies its bounds, the state is updated as follows:

##### Generator Updates:

$$ $n_{i,r,t}=n_{i,r,t-1}+n^{\text{add}}_{i,r,t}$ $$

##### Transmission Line Installation:

$$ $nt_{l,t}=\begin{cases}1&\text{if }nt_{l,t-1}=0\text{ and }|P_{l,t}|>0\\ nt_{l,t-1}&\text{otherwise}\end{cases}$ $$

We then proceed to calculate the cost and reward. Finally, we shift the demand forecast by one step to $\text{Dem}_{r,t+1:t+k}$.

#### A.4.6 Cost Function

The total cost at each time step consists of penalties for constraint violations, including those for the bounds of the state, and demand satisfaction violations. The components of the cost are defined as follows:

##### Generator Bound Violations:

We apply a combination of $L_{0}$ and $L_{2}$ penalties for generating an action before sanitization that violates the maximum number of generators in a region:

$$ $C^{\text{bound,gen}}_{i,r}=\begin{cases}\lambda_{0}+\lambda_{2}\cdot\left(n^{ \text{add,prebound}}_{i,r,t}+n_{i,r,t-1}-M_{i,r}\right)^{2}&\text{if }n^{\text {add,prebound}}_{i,r,t}+n_{i,r,t-1}>M_{i,r}\\ 0&\text{otherwise}\end{cases}$ $$

##### Demand Violations:

The available power $\text{Pow}^{\text{avail}}_{r,t}$ in region $r$ at time $t$ is calculated as:

$$ $\text{Pow}^{\text{avail}}_{r,t}=\sum_{i}n_{i,r,t}\cdot\text{Cap}^{\text{gen}}_ {i}+\sum_{r^{\prime}|(r,r^{\prime})\in\mathcal{L}}P_{(r,r^{\prime}),t}-\sum_{r ^{\prime}|(r^{\prime},r)\in\mathcal{L}}P_{(r^{\prime},r),t}$ $$

Note: The power flow obtained from the agent is only in one direction. The power flow along the reverse direction can be interpreted simply the negative of the power flow in the original direction. Specifically, for any transmission line $(r_{1},r_{2})\in\mathcal{L}$, the power flow from region $r_{1}$ to region $r_{2}$ is denoted by $P_{(r_{1},r_{2}),t}$, and the reverse flow from region $r_{2}$ to region $r_{1}$ is $P_{(r_{2},r_{1}),t}=-P_{(r_{1},r_{2}),t}$.

We apply a combination of $L_{0}$ and $L_{2}$ penalties for unmet demand:

$$ $C^{\text{demand}}_{r}=\begin{cases}\lambda_{0}+\lambda_{2}\cdot\left(\text{Dem }_{r,t}-\text{Pow}^{\text{avail}}_{r,t}\right)^{2}&\text{if }\text{Dem}_{r,t}> \text{Pow}^{\text{avail}}_{r,t}\\ 0&\text{otherwise}\end{cases}$ $$

##### Total cost:

The total cost is the sum of the penalties for all violations, as follows:

$$ $C_{t}=\sum_{i,r}C^{\text{bound,gen}}_{i,r}+\sum_{r}C^{\text{demand}}_{r}$ $$

The total cost is used to guide the agent toward optimal decision-making.

#### A.4.7 Reward Function

The reward function consists of:

##### Contribution to reward from installation of generators

:

$$ $\pi^{gen}_{t}=-\sum_{i,r}n^{\text{add}}_{i,r,t}\cdot C^{\text{inst,gen}}_{i}$ $$

##### Contribution to reward from installation of transmission lines

:

$$ $\pi^{tl}_{t}=-\sum_{l\in\mathcal{L}}C^{\text{inst,tl}}_{l}\cdot\mathbbm{1}[nt_ {l,t-1}=0\wedge|P_{l,t}|>0]$ $$

##### Total reward

:

$$ $\pi_{t}=\pi^{gen}_{t}+\pi^{tl}_{t}$ $$

### A.5 Multiperiod Blending Problem( BlendingEnv )

#### A.5.1 Overview

The multiperiod blending problem, a core challenge in chemical engineering, involves optimally blending multiple input streams to produce outputs with desired quality attributes over a series of time periods. Input streams, characterized by specific properties, are procured and stored in inventory vessels. These streams are then transferred to blenders, where they are mixed according to specified blending rules. The resulting output streams must meet property constraints (e.g., quality specifications) and are subsequently stored in output inventory vessels before being sold, subject to upper bounds on product quantities.

The goal is typically to maximize profit while satisfying constraints on inventory levels, property ranges, and operational rules—such as prohibiting simultaneous inflow and outflow in the same blender. These requirements lead to a highly nonlinear and constrained formulation, commonly modeled as a non-convex mixed-integer quadratically constrained program (MIQCP) [6].

Due to the sequential decision-making structure of the problem and the uncertainty in demands or property variations over time, reinforcement learning (RL) emerges as a promising approach. In particular, safe RL techniques can guide agents to learn actions that are not only near-optimal but also likely to satisfy complex constraints. To that end, we model the problem as a Constrained Markov Decision Process (CMDP) and implement it as the environment BlendingEnv, which supports dynamic decisions on stream flows, purchasing, and selling over time.

#### A.5.2 Problem Setup

The sets and known parameters used to describe the environment are shown below:

##### Sets

- •
$\mathcal{T}=\{1,\ldots,T\}$: Set of discrete time periods.
- •
$\mathcal{S}$: Set of source streams.
- •
$\mathcal{J}$: Set of blenders.
- •
$\mathcal{P}$: Set of demand streams.
- •
$\mathcal{Q}$: Set of stream properties (e.g., chemical or physical characteristics).
- •
$\mathcal{F}^{s,j}$: Set of tuples representing possible directed flows from source streams to blenders.
- •
$\mathcal{F}^{j,j}$: Set of tuples representing possible directed flows between blenders. Flows are defined in such a way that only one way is possible.
- •
$\mathcal{F}^{j,p}$: Set of tuples representing possible directed flows from blenders to demand streams.

##### Parameters

- •
$F^{\max}$: Upper bound for any flow between nodes.
- •
$\sigma_{s,q}$: Value of property $q\in\mathcal{Q}$ for source stream $s\in\mathcal{S}$.
- •
$[s^{\text{lb}}_{s},s^{\text{ub}}_{s}]$: Lower and upper bounds on inventory of source $s\in\mathcal{S}$.
- •
$\tau^{0}_{s,t}$: Availability of source stream $s\in\mathcal{S}$ at time $t\in\mathcal{T}$.
- •
$[b^{\text{lb}}_{j},b^{\text{ub}}_{j}]$: Lower and upper inventory bounds for blender $j\in\mathcal{J}$.
- •
$[\sigma^{\text{lb}}_{p,q},\sigma^{\text{ub}}_{p,q}]$: Lower and upper bounds on property $q\in\mathcal{Q}$ for demand stream $p\in\mathcal{P}$.
- •
$[d^{\text{lb}}_{p},d^{\text{ub}}_{p}]$: Lower and upper bounds on inventory of demand stream $p\in\mathcal{P}$.
- •
$\delta^{0}_{p,t}$: Maximum amount of demand stream $p\in\mathcal{P}$ that can be fulfilled at time $t\in\mathcal{T}$.
- •
$\beta^{d}_{p}$: Unit selling price for demand stream $p\in\mathcal{P}$.
- •
$\beta^{s}_{s}$: Unit purchase cost of source stream $s\in\mathcal{S}$.
- •
$\beta$: Unit cost of intermediate flows (e.g., between nodes).
- •
$\alpha$: Fixed cost of activating an intermediate flow.
- •
$k$: Window length for source and demand forecast
- •
$strategy$: The strategy used in the environment to handle illegal actions caused by constraint violations. We support three options: $prop$, $disable$, and $none$. In the $prop$ strategy, we adjust a subset of actions when they violate the relevant constraints, with actions scaled or clipped depending on the specific constraint. In the $disable$ strategy, a subset of actions is set directly to zero . The $none$ strategy applies no correction, allowing actions to remain unchanged regardless of constraint violations.
- •
$\lambda_{0,B}$: a fixed cost for violating bound constraint (analogous to $\ell_{0}$ regularization).
- •
$\lambda_{B}$: prefactor to the sum of $\ell_{0}$ and $\ell_{1}$ violations for inventory bound constraint (analogous to $\ell_{0}$ regularization).
- •
$\lambda_{0,M}$: a fixed cost for violating in-out rule constraint (analogous to $\ell_{0}$ regularization).
- •
$\lambda_{0,Q}$: a fixed cost for violating property specifications (analogous to $\ell_{0}$ regularization).
- •
$\epsilon$: A small positive threshold used to disregard negligible violations of constraints.

#### A.5.3 State Space

The state $s_{t}$ at time $t\in\mathcal{T}$ includes the following components, with dimensionality expressed using the sets defined previously:

- •
Source inventories: $I^{s}_{s,t}\in[s^{\text{lb}}_{s},s^{\text{ub}}_{s}]$, for all $s\in\mathcal{S}$.
This has dimension $|\mathcal{S}|$.
- •
Blender inventories: $I^{b}_{j,t}\in[b^{\text{lb}}_{j},b^{\text{ub}}_{j}]$, for all $j\in\mathcal{J}$.
This has dimension $|\mathcal{J}|$.
- •
Demand inventories: $I^{d}_{p,t}\in[d^{\text{lb}}_{p},d^{\text{ub}}_{p}]$, for all $p\in\mathcal{P}$.
This has dimension $|\mathcal{P}|$.
- •
Blender properties: $C_{j,q,t}\in\mathbb{R}$, for all $j\in\mathcal{J},q\in\mathcal{Q}$.
This has dimension $|\mathcal{J}|\times|\mathcal{Q}|$.
- •
$\tau^{0}_{s,t+1:t+k}$: Forecasted source availability for all $s\in\mathcal{S}$ from time t+1 to t+k where $k$ is the forecasting window.
This component has a dimension of $|\mathcal{S}|\times k$. Entries are padded with zeros for time periods beyond the episode horizon.
- •
$\delta^{0}_{p,t+1:t+k}$ Forecasted demand availability, for all $p\in\mathcal{P}$ from time t+1 to t+k where $k$ is the forecasting window.
This component has a dimension of $|\mathcal{P}|\times k$. Entries are padded with zeros for time periods beyond the episode horizon.
- •
Time step: $t\in\mathcal{T}$.
This is a scalar.

#### A.5.4 Action Space

At each time step $t\in\mathcal{T}$, the agent selects the following actions:

- •
Source purchases: $\tau_{s,t}\in[0,\tau^{0}_{s,t}]$, for all $s\in\mathcal{S}$.
This has dimension $|\mathcal{S}|$.
- •
Demand sales: $\delta_{p,t}\in[0,\delta^{0}_{p,t}]$, for all $p\in\mathcal{P}$.
This has dimension $|\mathcal{P}|$.
- •
Source-to-blender flows: $F^{sj}_{s,j,t}\in[0,F^{\max}]$, for all $(s,j)\in\mathcal{F}^{s,j}$.
This has dimension $|\mathcal{F}^{s,j}|$.
- •
Blender-to-blender flows: $F^{jj}_{j,j^{\prime},t}\in[0,F^{\max}]$, for all $(j,j^{\prime})\in\mathcal{F}^{j,j}$.
This has dimension $|\mathcal{F}^{j,j}|$.
- •
Blender-to-demand flows: $F^{jp}_{j,p,t}\in[0,F^{\max}]$, for all $(j,p)\in\mathcal{F}^{j,p}$.
This has dimension $|\mathcal{F}^{j,p}|$.

Each action is initially normalized to the interval $[-1,1]$ and mapped to its actual value using affine transformation based on the lower and upper bounds of the corresponding action:

$$ $a^{\text{actual}}=\frac{(a^{\text{normalized}}+1)}{2}\cdot(a^{\text{high}}-a^{ \text{low}})+a^{\text{low}}$ $$

Here, $a^{\text{low}}$ and $a^{\text{high}}$ are the lower and upper bounds for each action dimension as specified above.

#### A.5.5 Transition Dynamics

After scaling the actions, we increment $t$ to $t+1$.
Let us denote the set of actions at this point as

$$ $\left\{\tau^{\text{prebound}}_{s,t},\quad\delta^{\text{prebound}}_{p,t},\quad F ^{\text{sj,prebound}}_{s,j,t},\quad F^{\text{jj,preinout}}_{j,j^{\prime},t}, \quad F^{\text{jp,preinout}}_{j,p,t}\right\}.$ $$

respectively.

##### Checking action for source inventory bounds:

We next proceed to check if the actions provide a source inventory that violates the bounds. If there is a violation, we adjust the actions based on the strategy chosen.

$$ $I_{\text{new},s}^{s}=I^{s}_{s,t-1}-\sum_{(s,j)\in\mathcal{F}^{s,j}}F^{sj, prebound}_{s,j,t}+\tau^{prebound}_{s,t}$ $$

$$ $F^{sj}_{s,j,t|(s,j)\in\mathcal{F}^{s,j}}=\begin{cases}F^{sj,prebound}_{s,j,t} \left(\frac{I^{s}_{s,t-1}+\tau^{prebound}_{s,t}-s^{lb}_{s}}{\sum_{(s,j)\in \mathcal{F}^{s,j}}F^{sj,prebound}_{s,j,t}}\right)&\text{if }I_{\text{new},s}^{ s}<s^{lb}_{s}-\epsilon,strategy=prop\\ 0&\text{if }I_{\text{new},s}^{s}<s^{lb}_{s}-\epsilon,strategy=disable\\ F^{sj,prebound}_{s,j,t}&\text{otherwise}\end{cases}$ $$

$$ $\tau_{s,t}=\begin{cases}\min(s^{ub}_{s}+\sum_{(s,j)\in\mathcal{F}^{s,j}}F^{sj, prebound}_{s,j,t}-I^{s}_{s,t-1},\tau^{0}_{s,t})&\text{if }I_{\text{new},s}^{s} >s^{ub}_{s}+\epsilon,strategy=prop\\ 0&\text{if }I_{\text{new},s}^{s}>s^{ub}_{s}+\epsilon,strategy=disable\\ \tau^{prebound}_{s,t}&\text{otherwise}\end{cases}$ $$

##### Source inventory updates

We then update the source inventory as follows:

$$ $I^{s}_{s,t}=\text{clip}(I^{s}_{s,t-1}-\sum_{(s,j)\in\mathcal{F}^{s,j}}F^{sj}_{ s,j,t}+\tau_{s,t},\;s^{lb}_{s},\;s^{ub}_{s})$ $$

##### Checking action for in-out rule violations:

We now check if the actions follow the in-out rule for blenders. That is, blenders should not have simultaneous inflow and outflow of streams. If there is such a case, we set all corresponding outflows to 0. The value of other flows are not changed.

$$ $\text{Inflow}_{j}=\sum_{(s,j)\in\mathcal{F}^{s,j}}F^{sj}_{s,j,t}+\sum_{(j^{ \prime},j)\in\mathcal{F}^{j,j}}F^{jj,preinout}_{j^{\prime},j,t}$ $$

$$ $\text{Outflow}_{j}=\sum_{(j,j^{\prime})\in\mathcal{F}^{j,j}}F^{jj,preinout}_{j ,j^{\prime},t}+\sum_{(j,p)\in\mathcal{F}^{j,p}}F^{jp,preinout}_{j,p,t}$ $$

$$ $F^{jp,prebound}_{j,p,t|(j,p)\in\mathcal{F}^{j,p}}=\begin{cases}0&\text{if } \text{Inflow}_{j}>\epsilon,\text{Outflow}_{j}>\epsilon,strategy\neq no\\ F^{jp,preinout}_{j,p,t}&\text{otherwise}\end{cases}$ $$

$$ $F^{jj,prebound}_{j,j^{\prime},t|(j,j^{\prime})\in\mathcal{F}^{j,j}}=\begin{ cases}0&\text{if }\text{Inflow}_{j}>\epsilon,\text{Outflow}_{j}>\epsilon, strategy\neq no\\ F^{jj,preinout}_{j,j^{\prime},t}&\text{otherwise}\end{cases}$ $$

##### Checking action for blender inventory lower bound:

We next proceed to check if the actions provide a blender inventory that violates the lower bounds.

$$ $I_{\text{new},j}^{b}=I^{b}_{j,t-1}+\sum_{(s,j)\in\mathcal{F}^{s,j}}F^{sj}_{s,j ,t}+\sum_{(j^{\prime},j)\in\mathcal{F}^{j,j}}F^{jj,prebound}_{j^{\prime},j,t}- \sum_{(j,j^{\prime})\in\mathcal{F}^{j,j}}F^{jj,prebound}_{j,j^{\prime},t}-\sum _{(j,p)\in\mathcal{F}^{j,p}}F^{jp,prebound}_{j,p,t}$ $$

If there is a violation, we adjust the actions based on the strategy chosen. We keep the same actions otherwise.

$$ $F^{jp}_{j,p,t|(j,p)\in\mathcal{F}^{j,p}}=\begin{cases}F^{jp,prebound}_{j,p,t} \left(\frac{I^{b}_{j,t-1}+\sum_{(s,j)\in\mathcal{F}^{s,j}}F^{sj}_{s,j,t}+\sum_ {(j^{\prime},j)\in\mathcal{F}^{j,j}}F^{jj,prebound}_{j^{\prime},j,t}-b^{lb}_{j }}{\sum_{(j,j^{\prime})\in\mathcal{F}^{j,j}}F^{jj,prebound}_{j,j^{\prime},t}+ \sum_{(j,p)\in\mathcal{F}^{j,p}}F^{jp,prebound}_{j,p,t}}\right)&\text{if }I_{ \text{new},j}^{b}<b^{lb}_{j}-\epsilon,\\ &strategy=prop\\ 0&\text{if }I_{\text{new},j}^{b}<b^{lb}_{j}-\epsilon,\\ &strategy=disable\\ F^{jp,prebound}_{j,p,t}&\text{otherwise}\end{cases}$ $$

$$ $F^{jj}_{j,j^{\prime},t|(j,j^{\prime})\in\mathcal{F}^{j,j}}=\begin{cases}F^{jj, prebound}_{j,j^{\prime},t}\left(\frac{I^{b}_{j,t-1}+\sum_{(s,j)\in\mathcal{F}^ {s,j}}F^{sj}_{s,j,t}+\sum_{(j^{\prime},j)\in\mathcal{F}^{j,j}}F^{jj,prebound}_ {j^{\prime},j,t}-b^{lb}_{j}}{\sum_{(j,j^{\prime})\in\mathcal{F}^{j,j}}F^{jj, prebound}_{j,j^{\prime},t}+\sum_{(j,p)\in\mathcal{F}^{j,p}}F^{jp,prebound}_{j, p,t}}\right)&\text{if }I_{\text{new},j}^{b}<b^{lb}_{j}-\epsilon,\\ &strategy=prop\\ 0&\text{if }I_{\text{new},j}^{b}<b^{lb}_{j}-\epsilon,\\ &strategy=disable\\ F^{jj,prebound}_{j,j^{\prime},t}&\text{otherwise}\end{cases}$ $$

##### Blender inventory updates:

After making the adjustments described above, we update the blender inventory.

$$ $I^{b}_{j,t}=\text{clip}(I^{b}_{j,t-1}+\sum_{(s,j)\in\mathcal{F}^{s,j}}F^{sj}_{ s,j,t}+\sum_{(j^{\prime},j)\in\mathcal{F}^{j,j}}F^{jj}_{j^{\prime},j,t}-\sum_{ (j,j^{\prime})\in\mathcal{F}^{j,j}}F^{jj}_{j,j^{\prime},t}-\sum_{(j,p)\in \mathcal{F}^{j,p}}F^{jp}_{j,p,t},\;b^{lb}_{j},\;b^{ub}_{j})$ $$

##### Checking action for demand inventory lower bound:

We now check if the actions provide a demand inventory that violates the lower bounds.

$$ $I_{\text{new},p}^{d}=I^{d}_{p,t-1}+\sum_{(j,p)\in\mathcal{F}^{j,p}}F^{jp}_{j,p ,t}-\delta^{prebound}_{p,t}$ $$

If there is a violation, we adjust the actions based on the strategy chosen.

$$ $\delta_{p,t}=\begin{cases}I^{d}_{p,t-1}+\sum_{(j,p)\in\mathcal{F}^{j,p}}F^{jp} _{j,p,t}-d^{lb}_{p}&\text{if }I_{\text{new},p}^{d}<d^{lb}_{p}-\epsilon, strategy=prop\\ 0&\text{if }I_{\text{new},p}^{d}<d^{lb}_{p}-\epsilon,strategy=disable\\ \delta^{prebound}_{p,t}&\text{otherwise}\end{cases}$ $$

##### Demand inventory updates:

After making the adjustments described above, we update the demand inventory.

$$ $I^{d}_{p,t}=\text{clip}(I^{d}_{p,t-1}+\sum_{(j,p)\in\mathcal{F}^{j,p}}F^{jp}_{ j,p,t}-\delta_{p,t},\;d^{lb}_{p},\;d^{ub}_{p})$ $$

##### Blender property updates

We then update the property of the materials in each blender as follows:

$$ $C_{j,q,t}=\begin{cases}=\frac{1}{I^{b}_{j,t}}\Big{(}C_{j,q,t-1}\cdot I^{b}_{j, t-1}+\sum_{(s,j)\in\mathcal{F}^{s,j}}F^{sj}_{s,j,t}\cdot\sigma_{s,q}&\\ +\sum_{(j^{\prime},j)\in\mathcal{F}^{j,j}}F^{jj}_{j^{\prime},j,t}\cdot C_{j^{ \prime},q,t-1}&\\ -\sum_{(j,j^{\prime})\in\mathcal{F}^{j,j}}F^{jj}_{j,j^{\prime},t}\cdot C_{j,q, t-1}&\\ -\sum_{(j,p)\in\mathcal{F}^{j,p}}F^{jp}_{j,p,t}\cdot C_{j,q,t-1}\Big{)}&\text{ if }I^{b}_{j,t+1}>\epsilon\\ 0&\text{otherwise}\end{cases}$ $$

We then proceed to calculate the cost and reward. Finally, we shift the future schedules forecast by one step to $\tau^{0}_{s,t+1:t+k}\text{ and }\delta^{0}_{p,t+1,t+k}$.

#### A.5.6 Costs

The total cost at each time step consists of penalties for constraint violations, including those for the violations of the bounds of the state and the in-out rule. The components of the cost are defined as follows:

##### Inventory Bound Violation Costs

:

Inventory levels at sources, blenders, and demands are required to remain within prescribed upper and lower bounds. Inventory levels computed with actions before the relevant upadates are used to assess constraint violations.

Sources:

$$ $C^{source}_{s,t}=\begin{cases}\lambda_{B}\cdot(\lambda_{0,B}+I^{s}_{new,s}-s^{ ub}_{s}),&\text{if }I^{s}_{new,s}>s^{ub}_{s}+\epsilon\\ \lambda_{B}\cdot(\lambda_{0,B}+s^{lb}_{s}-I^{s}_{new,s}),&\text{if }I^{s}_{new ,s}<s^{lb}_{s}-\epsilon\\ 0,&\text{otherwise}\end{cases}$ $$

Blenders:

$$ $C^{blender}_{j,t}=\begin{cases}\lambda_{B}\cdot(\lambda_{0,B}+I^{b}_{new,j}-b^ {ub}_{j}),&\text{if }I^{b}_{new,j}>b^{ub}_{j}+\epsilon\\ \lambda_{B}\cdot(\lambda_{0,B}+b^{lb}_{s}-I^{b}_{new,j}),&\text{if }I^{b}_{new ,j}<b^{lb}_{j}-\epsilon\\ 0,&\text{otherwise}\end{cases}$ $$

Demands:

$$ $C^{demand}_{p,t}=\begin{cases}\lambda_{B}\cdot(\lambda_{0,B}+I^{d}_{new,p}-d^{ ub}_{p}),&\text{if }I^{d}_{new,p}>d^{ub}_{p}+\epsilon\\ \lambda_{B}\cdot(\lambda_{0,B}+d^{lb}_{p}-I^{b}_{new,j}),&\text{if }I^{d}_{new ,p}<d^{lb}_{p}-\epsilon\\ 0,&\text{otherwise}\end{cases}$ $$

##### In-Out Rule Violation Costs

:

Blenders must not simultaneously receive and send flow within the same time step. If both incoming and outgoing flows are non-zero (beyond a tolerance $\epsilon$), a penalty is applied:

$$ $C^{in-out}_{j,t}=\begin{cases}\lambda_{0,M},&\text{if }\text{Inflow}_{j}> \epsilon,\text{Outflow}_{j}>\epsilon\\ 0,&\text{otherwise}\end{cases}$ $$

##### Property Violation Costs

:

Each demand $p$ requires product properties $q$ within bounds. If blender $j$’s content violates these bounds and is being delivered to $p$, a penalty is applied:

$$ $C^{Q}_{j,q,p,t}=\begin{cases}\lambda_{0,Q},&\text{if }(C_{j,q,t}<\sigma^{lb}_{ p,q}-\epsilon\lor C_{j,q,t}>\sigma^{ub}_{p,q}+\epsilon),(j,p)\in\mathcal{F}^{j ,p},F^{jp}_{j,p,t}>0\\ 0,&\text{otherwise}\end{cases}$ $$

##### Total Cost

The total penalty at time $t$ is:

$$ $C_{t}=\sum_{s\in S}C^{source}_{s,t}+\sum_{j\in J}C^{blender}_{j,t}+\sum_{p\in P }C^{demand}_{p,t}+\sum_{j\in J}C^{in-out}_{j,t}+\sum_{j\in J}\sum_{q\in Q}\sum _{p\in P}C^{Q}_{j,q,p,t}$ $$

#### A.5.7 Reward Function

The reward function consists of:

##### Revenue from selling streams

:

$$ $\pi^{sale}_{t}=\sum_{p\in P}\beta^{d}_{p}\cdot\delta_{p,t}$ $$

##### Contribution to reward from buying streams

:

$$ $\pi^{purchase}_{t}=-\sum_{s\in S}\beta^{s}_{s}\cdot\tau_{s,t}$ $$

##### Contribution to reward from flows

:

$$ $\pi^{flow}_{t}=-\alpha\cdot Q_{bin}-\beta\cdot Q_{float}$ $$

where

$$ $Q_{bin}=\sum_{(s,j)\in\mathcal{F}^{s,j}}\mathbbm{1}[F^{sj}_{s,j,t}>0]+\sum_{(j ,p)\in\mathcal{F}^{j,p}}\mathbbm{1}[F^{jp}_{j,p,t}>0]$ $$

$$ $Q_{float}=\sum_{(s,j)\in\mathcal{F}^{s,j}}F^{sj}_{s,j,t}+\sum_{(j,p)\in \mathcal{F}^{j,p}}F^{jp}_{j,p,t}$ $$

##### Total Reward

:

$$ $\pi_{t}=\pi^{sale}_{t}+\pi^{purchase}_{t}+\pi^{flow}_{t}$ $$

### A.6 Multi-Echelon Inventory Management Environment ( InvMgmtEnv )

#### A.6.1 Overview

The multi-echelon inventory management problem involves coordinating replenishment orders across a five-tier supply network—raw-material suppliers, producers, distributors, retailers, and end-markets—under time-varying demand. At each period, the decision maker chooses continuous order quantities along each transportation route, with orders subject to fixed lead times before arrival. On-hand and in-transit inventories incur holding costs, while unmet demand is backlogged and penalized. The objective is to maximize cumulative net profit—total sales revenue minus procurement, operating, holding, and shortage penalty costs—over a finite planning horizon.

We adopt a centralized, single-product framework [20] in which all replenishment decisions are made by a central planner, and customer demand at each retailer-to-market link is drawn from a known stationary distribution, such as a Gaussian with specified mean and variance. Transportation is lossless with deterministic lead times, and replenishment quantities are bounded by per-route capacity, with any excess actions penalized. Episodes terminate after a fixed number of periods.

#### A.6.2 Problem Setup

The sets and known parameters used to describe InvMgmtEnv are shown below.

##### Sets

- •
$\mathcal{T}=\{1,\dots,T\}$: set of discrete time periods.
- •
$\mathcal{M}$: set of market nodes.
- •
$\mathcal{R}$: set of retailer nodes.
- •
$\mathcal{D}$: set of distributor nodes.
- •
$\mathcal{P}$: set of producer nodes.
- •
$\mathcal{S}$: set of raw-material supplier nodes.
- •
$\mathcal{N}=\mathcal{M}\cup\mathcal{R}\cup\mathcal{D}\cup\mathcal{P}\cup
\mathcal{S}$: set of all nodes.
- •
$\mathcal{L}$: set of directed replenishment routes.
Each route is written
$\ell\;=\;\bigl{(}\mathrm{orig}(\ell),\,\mathrm{dest}(\ell)\bigr{)},$
an ordered pair of nodes with
$\mathrm{orig}(\ell)\in\mathcal{N}$ the origin (shipping) node
and $\mathrm{dest}(\ell)\in\mathcal{N}$ the destination
(receiving) node.
- •
$\mathcal{RM}$: set of retailer-to-market demand links.

##### Parameters

- •
$I^{\mathrm{init}}_{n}$, $n\in\mathcal{N}$: initial on-hand inventory at node $n$.
- •
$\mathrm{Cap}^{\mathrm{route}}_{\ell}$, $\ell\in\mathcal{L}$: capacity limit of route $\ell$.
- •
$C^{\mathrm{hold,mat}}_{\ell}$, $\ell\in\mathcal{L}$: per-unit holding cost for pipeline inventory on route $\ell$.
- •
$C_{\ell}$, $\ell\in\mathcal{L}$: procurement cost per unit ordered on route $\ell$.
- •
$LT_{\ell}$, $\ell\in\mathcal{L}$: fixed lead time (in periods) for route $\ell$.
- •
$C^{\mathrm{hold,inv}}_{n}$, $n\in\mathcal{N}$: per-unit holding cost for on-hand inventory at node $n$.
- •
$C^{\mathrm{oper}}_{p}$, $p\in\mathcal{P}$: operating cost per unit of production activity at producer $p$.
- •
$\eta_{p}$, $p\in\mathcal{P}$: production yield at producer $p$.
- •
$\mu_{r,m},\;\sigma_{r,m}$, $(r,m)\in\mathcal{RM}$: mean and standard deviation of demand on link $(r,m)$.
- •
$P_{r,m}$, $(r,m)\in\mathcal{RM}$: selling price per unit on link $(r,m)$.
- •
$C^{\mathrm{penalty}}_{r,m}$, $(r,m)\in\mathcal{RM}$: penalty cost per unit of unmet demand on link $(r,m)$.
- •
$k$: look-ahead window length for demand forecast.
- •
$\varepsilon$: small threshold below which reorder quantities are treated as zero.
- •
$\phi_{\mathrm{action}}$: penalty factor for action-bound violations.
- •
$\phi_{\mathrm{on_hand}}$: penalty factor for on-hand inventory violations.
- •
$\phi_{\mathrm{pipeline}}$: penalty factor for pipeline inventory violations.
- •
$\phi_{\mathrm{sales}}$: penalty factor for sales-state violations.
- •
$\phi_{\mathrm{backlog}}$: penalty factor for backlog-state violations.

#### A.6.3 State Space

The state $s_{t}$ at time $t\in\mathcal{T}$ is represented by the tuple

$$ $s_{t}=\bigl{(}I_{n,t},\,P^{\mathrm{inv}}_{\ell,t},\,S_{r,m,t},\,B_{r,m,t},\,D_ {r,m,t:t+k},\,t\bigr{)},$ $$

where:

- •
*On-hand inventory levels:*
$I_{n,t}\in\mathbb{R}_{\geq 0},\quad n\in\mathcal{N},$
contributing $|\mathcal{N}|$ dimensions.
- •
*Pipeline inventory:*
$P^{\mathrm{inv}}_{\ell,t}=\bigl{(}P_{\ell,1,t},\dots,P_{\ell,LT_{\ell},t}\bigr
{)},\quad\ell\in\mathcal{L},$
contributing $\sum_{\ell\in\mathcal{L}}LT_{\ell}$ dimensions.
- •
*Sales:*
$S_{r,m,t}\in\mathbb{R}_{\geq 0},\quad(r,m)\in\mathcal{RM},$
contributing $|\mathcal{RM}|$ dimensions.
- •
*Backlog:*
$B_{r,m,t}\in\mathbb{R}_{\geq 0},\quad(r,m)\in\mathcal{RM},$
contributing $|\mathcal{RM}|$ dimensions.
- •
*Demand window:*
$D_{r,m,t:t+k}=\bigl{(}D_{r,m,t},\dots,D_{r,m,t+k}\bigr{)},\quad(r,m)\in
\mathcal{RM},$
where, for offsets $h$ with $t+h>T$, the unavailable future demand
$D_{r,m,t+h}$ is padded with 0 0.
This contributes $|\mathcal{RM}|\times k$ dimensions.
- •
*Time step:* (optional) the scalar $t$, contributing $1$ dimension.

All components are concatenated and flattened into a continuous observation vector of total dimension

$$ $|\mathcal{N}|\;+\;\sum_{\ell\in\mathcal{L}}LT_{\ell}\;+\;2\,|\mathcal{RM}|\;+ \;|\mathcal{RM}|\times k\;+\;1.$ $$

#### A.6.4 Action Space

At each decision epoch $t\in\mathcal{T}$ the agent outputs a
$|\mathcal{L}|$–tuple of normalized actions

$$ $\mathbf{a}_{\mathrm{norm},t}\;=\;\bigl{(}a_{\mathrm{norm},\ell,t}\bigr{)}_{ \ell\in\mathcal{L}}\;\in\;[-1,1]^{|\mathcal{L}|},$ $$

whose components correspond one-to-one with the directed replenishment routes
$\ell\in\mathcal{L}$.

##### Scaling to Physical Reorder Quantities.

Each normalized component is linearly mapped to a true reorder quantity,
respecting the capacity of its route:

$$ $Q_{\ell,t}\;=\;\frac{a_{\mathrm{norm},\ell,t}+1}{2}\,\mathrm{Cap}^{\mathrm{ route}}_{\ell},\qquad\ell\in\mathcal{L}.$ $$

A small-order cutoff $\varepsilon$ is then applied:

$$ $Q_{\ell,t}\;=\;\begin{cases}0,&Q_{\ell,t}\leq\varepsilon,\[4.0pt] Q_{\ell,t},&\text{otherwise}.\end{cases}$ $$

Collecting all routes, the environment works with the physical reorder vector

$$ $\mathbf{Q}_{t}\;=\;\bigl{(}Q_{\ell,t}\bigr{)}_{\ell\in\mathcal{L}}\;\in\;\bigl {[}0,\>\mathrm{Cap}^{\mathrm{route}}_{\ell}\bigr{]}^{|\mathcal{L}|}.$ $$

##### Effective Action Space.

After scaling and cutoff, the admissible actions lie in the $|\mathcal{L}|$-dimensional box

$$ $\mathcal{A}\;=\;\Bigl{\{}\mathbf{Q}_{t}\;\bigm{|}\;Q_{\ell,t}\in\bigl{[}0, \mathrm{Cap}^{\mathrm{route}}_{\ell}\bigr{]},\;\ell\in\mathcal{L}\Bigr{\}}.$ $$

#### A.6.5 Transition Dynamics

At each time step $t\in\mathcal{T}$, after observing $s_{t}$ and selecting normalized actions $\mathbf{a}_{\mathrm{norm}}\in[-1,1]^{|\mathcal{L}|}$, the environment updates to $s_{t+1}$ as follows:

##### Action Processing, Clipping, and Penalty Recording.

Each component $a_{\mathrm{norm},\ell}$ is first mapped to a preliminary reorder quantity

$$ $Q^{\mathrm{pre}}_{\ell,t}=\frac{a_{\mathrm{norm},\ell}+1}{2}\,\mathrm{Cap}^{ \mathrm{route}}_{\ell}.$ $$

A small-order cutoff $\varepsilon$ is applied:

$$ $Q^{\mathrm{cut}}_{\ell,t}=\begin{cases}0,&Q^{\mathrm{pre}}_{\ell,t}\leq \varepsilon,\\ Q^{\mathrm{pre}}_{\ell,t},&\text{otherwise}.\end{cases}$ $$

Any remaining violation of the action bounds is then clipped and recorded:

$$ $Q_{\ell,t}=\begin{cases}0,&Q^{\mathrm{cut}}_{\ell,t}<0,\[3.0pt] Q^{\mathrm{cut}}_{\ell,t},&0\leq Q^{\mathrm{cut}}_{\ell,t}\leq\mathrm{Cap}^{ \mathrm{route}}_{\ell},\[3.0pt] \mathrm{Cap}^{\mathrm{route}}_{\ell},&Q^{\mathrm{cut}}_{\ell,t}>\mathrm{Cap}^{ \mathrm{route}}_{\ell},\end{cases}$ $$

and the action-bound violation penalty is computed as

$$ $C^{\mathrm{bound,action}}_{\ell,t}=\begin{cases}\phi_{\mathrm{action}}\;\bigl{ |}Q^{\mathrm{cut}}_{\ell,t}\bigr{|},&Q^{\mathrm{cut}}_{\ell,t}<0,\[6.0pt] \phi_{\mathrm{action}}\;\bigl{|}Q^{\mathrm{cut}}_{\ell,t}-\mathrm{Cap}^{ \mathrm{route}}_{\ell}\bigr{|},&Q^{\mathrm{cut}}_{\ell,t}>\mathrm{Cap}^{ \mathrm{route}}_{\ell},\[6.0pt] 0,&\text{otherwise},\end{cases}$ $$

with $\phi_{\mathrm{action}}$ the penalty factor for action violations. Finally, increment the period: $t\leftarrow t+1$.

##### Pipeline Update.

After incrementing the period $t\leftarrow t+1$ at the end of previous step, the in-transit slots are shifted and the newest order is injected:

$$ $P_{\ell,\tau,t}=\begin{cases}P_{\ell,\tau+1,\;t-1},&\tau=1,2,\dots,LT_{\ell}-1 ,\[6.0pt] Q_{\ell,\;t-1},&\tau=LT_{\ell},\[3.0pt] 0,&\text{otherwise.}\end{cases}$ $$

The total in-transit inventory on route $\ell$ is

$$ $P^{\mathrm{inv}}_{\ell,t}=\sum_{\tau=1}^{LT_{\ell}}P_{\ell,\tau,t},$ $$

and the arrivals at node $n$ are

$$ $\mathrm{Arrivals}_{n,t}=\sum_{\begin{subarray}{c}\ell\in\mathcal{L}\\ \mathrm{dest}(\ell)=n\end{subarray}}P_{\ell,1,t}.$ $$

##### Arrival and Inventory Update.

For each node $n\in\mathcal{N}$,

$$ $I_{n,t}=I_{n,t-1}+\mathrm{Arrivals}_{n,t}.$ $$

##### 4. Demand Realization.

For each $(r,m)\in\mathcal{RM}$,

$$ $D_{r,m,t}\sim\mathcal{N}(\mu_{r,m},\sigma_{r,m}).$ $$

##### Sales and Backlog Update.

Sales are

$$ $S_{r,m,t}=\min\bigl{\{}D_{r,m,t}+B_{r,m,t-1},\,I_{r,t}\bigr{\}},$ $$

then

$$ $I_{r,t}\,\leftarrow\,I_{r,t}-S_{r,m,t},\quad B_{r,m,t}=D_{r,m,t}+B_{r,m,t-1}-S _{r,m,t}.$ $$

##### Demand Forecast Shift.

$$ $D_{r,m,t+1:t+k}=\bigl{(}D_{r,m,t+1},\dots,D_{r,m,t+k}\bigr{)}\quad\forall\,(r, m)\in\mathcal{RM}.$ $$

##### Observation Clipping.

After constructing all next-state components, any $x_{i,t+1}$ outside its bounds $[L_{i},U_{i}]$ is clipped to $L_{i}$ or $U_{i}$ as appropriate. Each such clipping is recorded as an observation-bound violation and will incur the corresponding penalty in the Cost Function.

#### A.6.6 Cost Function

The total cost at time $t$ is the sum of the penalties incurred for any state-observation violations:

$$ $C_{t}\;=\;C^{\mathrm{on_hand}}_{t}\;+\;C^{\mathrm{pipeline}}_{t}\;+\;C^{ \mathrm{sales}}_{t}\;+\;C^{\mathrm{backlog}}_{t}$ $$

Each category cost $C^{c}_{t}$ (for $c\in\{\mathrm{on_hand},\mathrm{pipeline},\mathrm{sales},\mathrm{backlog}\}$) is computed by applying the same piecewise linear penalty to each pre-clipped component $x_{i,t}$ in that category. Let $\mathcal{I}_{c}$ be the set of component indices for category $c$, each with bounds $[L_{i},U_{i}]$ and penalty factor $\phi_{c}$. For each category
$c\in\{\mathrm{on_hand},\mathrm{pipeline},\mathrm{sales},\mathrm{backlog}\}$,
let $\phi_{c}$ denote its penalty factor (e.g. $\phi_{\mathrm{pipeline}}$
for pipeline-inventory violations). Then

$$ $C^{c}_{t}=\sum_{i\in\mathcal{I}_{c}}\begin{cases}\phi_{c}\,\bigl{(}L_{i}-x_{i, t}\bigr{)},&x_{i,t}<L_{i},\[6.0pt] \phi_{c}\,\bigl{(}x_{i,t}-U_{i}\bigr{)},&x_{i,t}>U_{i},\[6.0pt] 0,&\text{otherwise},\end{cases}$ $$

so that any observation below its lower bound or above its upper bound contributes linearly to the total cost.

##### Action - bound penalty.

If a preliminary order $Q^{\mathrm{cut}}_{\ell,t}$ violates the interval
$\bigl{[}0,\mathrm{Cap}^{\mathrm{route}}_{\ell}\bigr{]}$
(Step 1 of the transition dynamics),
it is clipped to the nearest bound and the deviation is recorded as an
*action-bound penalty* $C^{\mathrm{bound,action}}_{\ell,t}$,
weighted by the scalar factor $\phi_{\mathrm{action}}$.
The sum over all routes yields $C^{\mathrm{action}}_{t}$ is added to the total cost $C_{t}$ above.

#### A.6.7 Reward Function

We express the per-step reward as the sum of five components, each denoted by $\Pi$:

$$ $\Pi_{t}=\Pi^{\mathrm{rev}}_{t}\;-\;\Pi^{\mathrm{proc}}_{t}\;-\;\Pi^{\mathrm{ hold}}_{t}\;-\;\Pi^{\mathrm{oper}}_{t}\;-\;\Pi^{\mathrm{backlog}}_{t}.$ $$

- •
$\displaystyle\Pi^{\mathrm{rev}}_{t}=\sum_{(r,m)\in\mathcal{RM}}S_{r,m,t}\;P_{r
,m},$
revenue from sales.
- •
$\displaystyle\Pi^{\mathrm{proc}}_{t}=\;\sum_{\ell\in\mathcal{L}}Q_{\ell,t}\;C_
{\ell},$
procurement cost for orders.
- •
$\displaystyle\Pi^{\mathrm{hold}}_{t}=\;\sum_{n\in\mathcal{N}}I_{n,t}\;C^{
\mathrm{hold,inv}}_{n}\;+\;\sum_{\ell\in\mathcal{L}}P^{\mathrm{inv}}_{\ell,t}
\;C^{\mathrm{hold,mat}}_{\ell},$
holding cost for on-hand and pipeline inventories.
- •
$\displaystyle\Pi^{\mathrm{oper}}_{t}\;=\;\sum_{p\in\mathcal{P}}\frac{C^{
\mathrm{oper}}_{p}}{\eta_{p}}\sum_{\begin{subarray}{c}\ell\in\mathcal{L}\\
\mathrm{orig}(\ell)=p\end{subarray}}Q_{\ell,t},$
operating cost at each producer $p$, proportional to the total
quantity $Q_{\ell,t}$ dispatched along routes $\ell$ that
originate at $p$; the factor $1/\eta_{p}$ converts finished-good
output to required production input.
- •
$\displaystyle\Pi^{\mathrm{backlog}}_{t}=\;\sum_{(r,m)\in\mathcal{RM}}B_{r,m,t}
\;C^{\mathrm{penalty}}_{r,m},$
penalty for backlog.

#### A.6.8 Episode Termination

An episode ends when the final time step $t=T$ is reached. It is *not truncated*, even if the system encounters infeasible states.

### A.7 Grid-Integrated Energy Storage ( GridStorageEnv )

#### A.7.1 Overview

The grid-integrated energy-storage environment (GridStorageEnv) models the hourly operation of a transmission-connected battery fleet co-located with conventional generators on a network subject to time-varying loads and deterministic line de-energisation schedules [22]. At each period, the agent simultaneously chooses (i) real-power outputs for every thermal generator, (ii) battery charge rates, (iii) battery discharge rates, (iv) deliberate load shedding, and (v) bus voltage angles at all non-reference buses (Bus 1 is fixed at 0 rad). Given these angles, line flows are computed through DC power-flow equations, and flows on deterministically de-energised lines are forced to zero.

Batteries follow a “bucket” state-of-charge (SOC) dynamic that applies charging/discharging inefficiency and an inter-period carry-over factor.

The objective is to minimise total cost over a finite horizon of $T$ hours, comprising (a) generator fuel cost modelled as a polynomial in power output and (b) linear penalties on slack generation, unserved load, bus-angle limits, line-loading ratio, SOC and demand violations, as well as a nodal power-balance penalty that discourages infeasible angle choices. Physical limits on generators, transmission lines, buses, and batteries are enforced by clipping out-of-bounds actions or state variables and charging a proportional penalty.

We assume perfect foresight of hourly demand and line de-energisation schedules, a single central decision maker, lossless transmission on energised lines, and a fixed $k$-hour demand-forecast window embedded in the state. Episodes last exactly $T$ steps and are never truncated.

#### A.7.2 Problem Setup

The environment is defined by the following sets and parameters.

##### Sets

- •
$\mathcal{T}=\{1,\dots,T\}$: discrete time periods.
- •
$\mathcal{N}$: set of buses in the network, $|\mathcal{N}|=N$.
- •
$\mathcal{G}$: set of generators, $|\mathcal{G}|=G$.
- •
$\mathcal{L}\subseteq\mathcal{N}\times\mathcal{N}$: set of transmission lines.
- •
$\mathcal{D}_{t}\subseteq\mathcal{L}$: deterministic subset of lines de-energized at time $t$.

##### Parameters

- •
$\mathrm{BusGeneratorLink}$: a mapping $g\mapsto n$ for $g\in\mathcal{G}$, $n\in\mathcal{N}$, indicating which bus each generator sits on.
- •
$B_{ij}$, $(i,j)\in\mathcal{L}$: line susceptance.
- •
$\overline{f}_{\ell}$, $\ell\in\mathcal{L}$: maximum power-flow on line $\ell$.
- •
$\underline{\theta}_{\ell},\,\overline{\theta}_{\ell}$, $\ell\in\mathcal{L}$: bounds on voltage-angle difference.
- •
$d_{n,t}$, $(n,t)\in\mathcal{N}\times\{1,\dots,T\}$: demand at bus $n$ and time $t$.
- •
$p^{\min}_{g},\,p^{\max}_{g}$, $g\in\mathcal{G}$: generator output limits.
- •
$E^{\min}_{n},\,E^{\max}_{n}$, $n\in\mathcal{N}$: battery state-of-charge (SOC) bounds.
- •
$E_{n,0}$, $n\in\mathcal{N}$: initial SOC.
- •
$p^{c,\min}_{n},\,p^{c,\max}_{n}$, $n\in\mathcal{N}$: battery charge-rate bounds.
- •
$p^{d,\min}_{n},\,p^{d,\max}_{n}$, $n\in\mathcal{N}$: battery discharge-rate bounds.
- •
$\eta$: battery charge/discharge efficiency.
- •
$\gamma$: SOC carry-over rate between periods.
- •
$\mathrm{PolynomialDegree}$: number of generator-cost
coefficients (the highest exponent is
$\mathrm{PolynomialDegree}-1$).
- •
$C_{g,j}$, $g\in\mathcal{G}$, $j=0,\dots,\mathrm{PolynomialDegree}-1$: generator cost coefficients.
- •
$K_{\mathrm{slack}}$ (Kslack):
per-unit penalty for slack generation.
- •
$K_{\mathrm{ls}}$ (Kls):
per-unit penalty for load-shedding.
- •
$\Theta^{\max}$: absolute bound on controllable bus voltage angle (radians).
- •
$\phi_{\mathrm{bal}}$: penalty factor for nodal power-balance violations arising when injections do not match DC power flow.
- •
$\phi_{\theta,\text{act}}$: penalty factor for node-angle
*action* clipping.
- •
$\phi_{\mathrm{power}}$: penalty factor for generator output bounds violations.
- •
$\phi_{\mathrm{charge}}$: penalty factor for battery charge-rate bounds violations.
- •
$\phi_{\mathrm{discharge}}$: penalty factor for battery discharge-rate bounds violations.
- •
$\phi_{\mathrm{slack}}$: penalty factor for slack generation bounds violations.
- •
$\phi_{\mathrm{shed}}$: penalty factor for load-shedding bounds violations.
- •
$\phi_{\mathrm{soc}}$: penalty factor for state-of-charge observation bounds violations.
- •
$\phi_{\theta}$: penalty factor for voltage-angle observation-bound
violations.
- •
$s^{\max}$: maximum slack-generation allowed at each bus.
- •
$d^{\max}_{\text{global}}=\displaystyle\max_{n\in\mathcal{N},\,t\in\mathcal{T}}
d_{n,t}$:
system-wide peak demand, used as the upper bound for all
load-shedding actions.

#### A.7.3 State Space

The state $s_{t}$ at time $t\in\mathcal{T}$ is the tuple

$$ $s_{t}=\bigl{(}\mathrm{SOC}_{n,t},\;\Theta_{\ell,t},\;f_{\ell,t},\;s_{n,t},\;D_ {n,t:t+k-1},\;\tau_{t}\bigr{)},$ $$

with components defined and sized as follows:

- •
$\mathrm{SOC}_{n,t}=E_{n,t}/E^{\max}_{n}\in[0,1]$
(normalized battery state of charge at bus $n$;
dimension $N$).
- •
$\Theta_{\ell,t}=\frac{2(\theta_{i,t}-\theta_{j,t})-(\underline{\theta}_{\ell}+
\overline{\theta}_{\ell})}{\overline{\theta}_{\ell}-\underline{\theta}_{\ell}}$
(normalized voltage-angle difference for
$\ell=(i,j)$; dimension $L$).
- •
$f_{\ell,t}\in[-\overline{f}_{\ell},\overline{f}_{\ell}]$
(actual power flow on line $\ell$ in MW; dimension $L$).
- •
$s_{n,t}\in[0,s^{\max}]$
(slack generation at bus $n$; dimension $N$).
- •
$D_{n,t:t+k-1}=(d_{n,t},\,d_{n,t+1},\dots,d_{n,t+k-1})$
(length-$k$ demand-forecast window; dimension $N\times k$).
- •
$\tau_{t}=(t-1)/(T-1)\in[0,1]$
(normalized time index; dimension $1$).

All components combine into a flattened observation vector of length

$$ $2N\;+\;2L\;+\;N\,k\;+\;1.$ $$

#### A.7.4 Action Space

At the start of each period $t$ the agent chooses the vector

$$ $a_{t}=\bigl{(}p_{t},\;c_{t},\;p^{d}_{t},\;\ell_{t},\;\theta_{t}\bigr{)}^{\! \top},\qquad\theta_{1,t}\equiv 0.$ $$

Its components obey the compact interval constraints

$$ $\begin{array}[]{lll}p_{t}\in\bigl{[}p^{\min},p^{\max}\bigr{]},&&(\text{ generator outputs, dim. }G),\[4.0pt] c_{t}\in\bigl{[}p^{c,\min},p^{c,\max}\bigr{]},&&(\text{battery charge},N),\[4 .0pt] p^{d}_{t}\in\bigl{[}p^{d,\min},p^{d,\max}\bigr{]},&&(\text{battery discharge}, N),\[4.0pt] \ell_{t}\in[0,d^{\max}_{\text{global}}]^{N},&&(\text{load shedding},N),\[4.0 pt] \theta_{t}\in[-\Theta^{\max},\Theta^{\max}]^{N-1},&&(\text{bus angles},N{-}1). \end{array}$ $$

##### Normalized interface.

The policy operates in the cube $[-1,1]^{\,G+3N+(N-1)}$ and outputs
$a_{\mathrm{norm},t}$.
An affine map rescales it to a preliminary action

$$ $a_{\mathrm{pre},t}=\tfrac{1}{2}\bigl{(}a_{\mathrm{norm},t}+1\bigr{)}\odot(a_{ \max}-a_{\min})+a_{\min},$ $$

with block-wise bounds

$$ $a_{\min}=\bigl{(}p^{\min},p^{c,\min},p^{d,\min},0_{N},-\Theta^{\max}1_{N-1} \bigr{)}^{\!\top}$ $$

$$ $a_{\max}=\bigl{(}p^{\max},p^{c,\max},p^{d,\max},d^{\max}_{\text{global}}1_{N}, \Theta^{\max}1_{N-1}\bigr{)}^{\!\top}$ $$

Any element that exceeds its limits after mapping is clipped to the
nearest bound; the clipping distance is multiplied by the corresponding
penalty factor $\phi_{\!\cdot}$ and accumulated into the action-bound
penalty $C^{\mathrm{action}}_{t}$.

#### A.7.5 Transition Dynamics

At each time step $t\in\mathcal{T}$, the environment moves from state $s_{t}$ to $s_{t+1}$ after receiving a normalized action $\mathbf{a}_{\mathrm{norm},t}\in[-1,1]^{G+3N+(N-1)}$. The update proceeds through seven ordered steps:

##### 1. Action decoding, clipping, and penalty logging.

Each normalized component is mapped back into its physical range:

$$ $a^{\mathrm{pre}}_{i,t}=\frac{a_{\mathrm{norm},i,t}+1}{2}\,(a^{\max}_{i}-a^{ \min}_{i})+a^{\min}_{i},$ $$

and clipped to remain within bounds $[a^{\min}_{i},a^{\max}_{i}]$. Let the resulting action vector be

$$ $\mathbf{a}_{t}=\bigl{\{}p_{g,t}\bigr{\}}_{g\in\mathcal{G}}\;\|\;\bigl{\{}c_{n, t}\bigr{\}}_{n\in\mathcal{N}}\;\|\;\bigl{\{}p^{d}_{n,t}\bigr{\}}_{n\in\mathcal {N}}\;\|\;\bigl{\{}\ell_{n,t}\bigr{\}}_{n\in\mathcal{N}}\;\|\;\bigl{\{}\theta_ {n,t}\bigr{\}}_{n\in\mathcal{N}\setminus\{1\}},$ $$

with $\theta_{1,t}\equiv 0$. Each clipping violation incurs a penalty multiplied by the corresponding $\phi_{\cdot}$.

##### 2. Battery state-of-charge update.

The battery SOC at each bus $n$ evolves as:

$$ $E_{n,t+1}=\gamma E_{n,t}+\eta c_{n,t}-\frac{1}{\eta}p^{d}_{n,t},\quad n\in \mathcal{N}.$ $$

##### 3. Load-shedding enforcement.

Any load shedding exceeding the global maximum is clipped:

$$ $\ell_{n,t}\leftarrow\min(\ell_{n,t},d^{\max}_{\text{global}}),$ $$

penalising excess with factor $\phi_{\mathrm{shed}}$.

##### 4. Power-flow calculation.

Compute power flows from voltage angles, enforcing zero flow on de-energised lines:

$$ $f_{\ell,t}=\begin{cases}B_{ij}(\theta_{i,t}-\theta_{j,t}),&\ell\notin\mathcal{ D}_{t}\[6.0pt] 0,&\ell\in\mathcal{D}_{t}\end{cases},\quad\ell=(i,j).$ $$

##### 5. Slack generation calculation.

Slack generation $s_{n,t}$ is computed to enforce exact network balance:

$$ $\displaystyle s_{n,t}$ $\displaystyle=\max\Bigl{\{}0,\;d_{n,t}-\ell_{n,t}-\sum_{g:\mathrm{ BusGeneratorLink}[g]=n}p_{g,t}+c_{n,t}-p^{d}_{n,t}$ $\displaystyle\quad+\sum_{(i,n)\in\mathcal{L}}f_{(i,n),t}-\sum_{(n,j)\in \mathcal{L}}f_{(n,j),t}\Bigr{\}}\,.$ $$

##### 6. Net nodal-injection and power-balance penalty.

Compute net nodal injection at each bus $n$:

$$ $P_{n,t}=\sum_{g:\mathrm{BusGeneratorLink}[g]=n}p_{g,t}+s_{n,t}-d_{n,t}+\ell_{n ,t}-c_{n,t}+p^{d}_{n,t}.$ $$

The nodal power-balance residual is:

$$ $\Delta_{n,t}=P_{n,t}-\sum_{j\in\mathcal{N}}B_{nj}(\theta_{n,t}-\theta_{j,t}),$ $$

and the network-balance penalty is:

$$ $C^{\mathrm{bal}}_{t}=\phi_{\mathrm{bal}}\sum_{n\in\mathcal{N}}\lvert\Delta_{n, t}\rvert.$ $$

##### 7. Demand-forecast and observation reconstruction.

Update the forecast window at each bus $n$:

$$ $D_{n,t:t+k-1}=(d_{n,t},d_{n,t+1},\dots,d_{n,\min\{t+k-1,T\}}),$ $$

padded with zeros beyond horizon $T$. Form the next state $s_{t+1}$ from normalized SOC, voltage-angle differences, loading ratios, flows, slack generation $s_{n,t}$, demand window, and normalized time $\tau_{t+1}=t/(T-1)$. Components outside valid bounds are clipped, incurring penalties accordingly.

#### A.7.6 Cost Function

The total penalty cost at time $t$ is

$$ $C_{t}\;=\;C^{\mathrm{soc}}_{t}+C^{\theta}_{t}+C^{\mathrm{flow_ratio}}_{t}+C^{ \mathrm{slack}}_{t}+C^{\mathrm{bal}}_{t}+C^{\mathrm{action}}_{t}$ $$

##### Observation-bound terms.

For each category $c\in\{\text{soc},\theta,\text{flow_ratio},\text{slack}\}$, let $\mathcal{I}_{c}$ be the indices of the corresponding observation sub-vector and $[L_{i},U_{i}]$ its valid range. Then

$$ $C^{c}_{t}\;=\;\sum_{i\in\mathcal{I}_{c}}\begin{cases}\phi_{c}\,(L_{i}-x_{i,t}) ,&x_{i,t}<L_{i},\[4.0pt] \phi_{c}\,(x_{i,t}-U_{i}),&x_{i,t}>U_{i},\[4.0pt] 0,&\text{otherwise}.\end{cases}$ $$

##### Network-balance term.

$C^{\mathrm{bal}}_{t}$ is defined in Transition-Step 5 as
$\phi_{\mathrm{bal}}\sum_{n}|\Delta_{n,t}|$,
penalising any mismatch between injections and DC power flow.

##### Action-bound term.

$C^{\mathrm{action}}_{t}$ aggregates the clipping penalties accrued in Transition-Step 1 for generator power, charge/discharge rates, load shedding, and bus angles (the latter weighted by $\phi_{\theta,\text{act}}$). It ensures every action component exceeding its hard limit is penalised proportionally to its violation.

#### A.7.7 Reward Function

We decompose the per-step reward $\Pi_{t}$ into three components, each denoted by $\Pi$:

$$ $\Pi_{t}=\Pi^{\mathrm{gen}}_{t}\;+\;\Pi^{\mathrm{slack}}_{t}\;+\;\Pi^{\mathrm{ shed}}_{t}.$ $$

where

$$ $\Pi^{\mathrm{gen}}_{t}=-\sum_{g\in\mathcal{G}}\sum_{j=0}^{\mathrm{ PolynomialDegree}-1}C_{g,j}\,p_{g,t}^{\,j},$ $$

negative generator fuel cost (polynomial in output $p_{g,t}$),

$$ $\Pi^{\mathrm{slack}}_{t}=-K_{\mathrm{slack}}\sum_{n\in\mathcal{N}}s_{n,t},$ $$

negative cost of slack generation at each bus,

$$ $\Pi^{\mathrm{shed}}_{t}=-K_{\mathrm{ls}}\sum_{n\in\mathcal{N}}\ell_{n,t}.$ $$

negative cost of load-shedding.

#### A.7.8 Episode Termination

An episode ends when the final time step $t=T$ is reached. It is *not truncated*, even if the system encounters infeasible states.

### A.8 Integrated scheduling and maintenance ( SchedMaintEnv )

#### A.8.1 Overview

Energy-intensive chemical processes leverage Demand Response (DR) to adjust electricity usage in response to price fluctuations, typically optimizing production on a rolling basis using forecasted demand and electricity prices. However, optimizing production scheduling alone can be detrimental, as it neglects the operational condition of essential equipment. Recent studies have addressed this by integrating condition-based maintenance into production optimization, notably for Air Separation Units (ASUs) [28], and natural gas plants [10].

In this study, we model an Air Separation Unit (ASU) comprising three compressors tasked with meeting aggregated gaseous nitrogen (GAN) and oxygen (GOX) demand over a 31-day episode, leveraging a deterministic 30-day rolling forecast of electricity prices and demands. Each day, the agent decides for each compressor whether to operate—producing at a chosen output level—or to undergo maintenance, incurring downtime and resetting its operational state. If total production falls short of demand, the deficit is met through external purchases at a fixed (though inflated) price. The objective is to minimize total operating expense—comprising electricity costs, downtime losses, and external purchase costs—by optimally trading off short-term production gains against long-term equipment health.

#### A.8.2 Problem Setup

The sets and known parameters used to describe the environment are
shown below:

##### Sets

- •
$\mathcal{T}=\{0,\ldots,T\}$: Set of discrete time periods.
- •
$\mathcal{C}$: Set of compressors.

##### Parameters

- •
$n$: Number of compressors.
- •
$S$: Forecast horizon.
- •
$Cap_{c}$: Maximum daily production capacity of the compressor $c$.
- •
$\mathrm{SPEN}_{c}$: Specific energy of compressor $c$ in KWh/t.
- •
$\mathrm{MTTF}_{c}$: Mean time to failure represents the maximum number of consecutive operating days before maintenance is required for compressor $c$.
- •
$\mathrm{MTTR}_{c}$: Mean time to repair represents fixed duration (in days) of any maintenance outage compressor $c$.
- •
$\mathrm{MNRD}_{c}$: Minimum no-repair duration, i.e., the time that must elapse after maintenance before the next service can begin for compressor $c$.
- •
$tlcm_{c,0}$: Initial time left to complete maintenance for compressor $c$ at start of the episode.
- •
$tslm_{c,0}$: Initial time since last maintenance for compressor $c$ at start of the episode.
- •
$cdm_{c,0}$: Initial indicator of whether compressor $c$ is eligible for maintenance at the start of the episode.
- •
$\alpha_{ext}$: External purchase price of per unit of product.
- •
$Q_{ext}$: Maximum possible purchase quantity for any given day.
- •
D: Array of daily forecasted demand over the simulation horizon $T+S$ in ton.
- •
E: Array of daily forecasted electricity prices over the simulation horizon $T+S$ in $/KWh.
- •
$\rho_{\text{MD}},\rho_{\text{MF}},\rho_{\text{EM}},\rho_{\text{RP}},\rho_{
\text{D}}$: Various penalty parameters related to constraint violation.

#### A.8.3 State Space

The observation state at time $t\in\mathcal{T}$ is represented as a vector,

$$ $s(t)=\left({d}_{t},{e}_{t},{tslm}_{t},{tlcm}_{t},{cdm}_{t}\right),\quad t\in[0 ,T]$ $$

The state vector $s(t)$ captures the essential operational and maintenance-related information for the Air Separation Unit (ASU) on day $t$. It includes forecasts of production demands and electricity prices over a fixed horizon (S days), along with detailed maintenance indicators for each compressor. These components are defined as follows:

- •
Demand Forecast ($d_{t}\in\mathbb{R}_{+}^{S\times 1})$: a vector of predicted demands from day $(t+1)$ to $(t+S)$, expressed in tons.
- •
Electricity Price Forecast ($e_{t}\in\mathbb{R}_{+}^{S\times 1}$): a vector of corresponding day-ahead electricity prices from day $t$ to $t+S-1$, measured in $\$/kWh$
- •
Time Since Last Maintenance ($\text{tslm}_{t}\in\mathbb{Z}_{+}^{n\times 1}$): the number of days since each compressor $c$ last underwent maintenance
- •
Time Left to Complete Maintenance ($\text{tlcm}_{t}\in\mathbb{Z}_{+}^{n\times 1}$): the remaining time (in days) required to complete maintenance for each compressor $c$; it is strictly positive only when maintenance is in progress.
- •
Can Do Maintenance Indicator ($\text{cdm}_{t}\in\{0,1\}^{n}$): a binary vector where $\text{cdm}_{ct}=1$ indicates that compressor $c$ is eligible for maintenance on day $t$

#### A.8.4 Action Space

Given the received observation at the start of each day $t\in\mathcal{T}$, the action space at time $t$ consists of operational decisions related to maintenance scheduling, compressor utilization, and external product procurement. The physical description is as follows:

- •
Compressor maintenance ($a_{\text{maintenance}}(t)\in\{0,1\}^{n}$): a binary vector indicating whether each compressor is scheduled for maintenance at time $t$, with $a_{\text{maintenance},c}(t)=1$ if compressor $c$ is under maintenance. We occasionally abbreviate this action as $a_{\text{maint.},c}(t)$.
- •
Compressor production rate ($a_{\text{production}}(t)\in[0,1]^{n}$): a continuous vector representing the fraction of the maximum capacity $Cap_{c}$ utilized by each compressor $c$. We occasionally abbreviate this action as $a_{\text{prod.},c}(t)$.
- •
External purchase $a_{\text{purchase}}(t)\in[0,1]$: the fraction of the maximum external product $Q_{\mathrm{ext}}$ purchased to meet demand when internal production is insufficient.

The agent’s raw actions are clipped to remain within their specified bounds. In particular, each component of $a_{\text{maintenance}}(t)$ is first generated as a scalar in $[0,1]$ and then rounded to $\{0,1\}$, while all other actions are clipped directly to their respective intervals.

#### A.8.5 Transition Dynamics

Here we define how the environment state evolves in response to the agent’s actions at each discrete time step $t\in\mathcal{T}$. Let $s(t)=\bigl{(}d_{t},\,e_{t},\,\mathrm{tslm}_{t},\,\mathrm{tlcm}_{t},\,\mathrm{
cdm}_{t}\bigr{)}$ be the observation vector at time $t$, with $s(0)$ denoting the initial observation. The transition to $s(t+1)$ is governed by the following procedures:

##### Information State Update:

This update incorporates changes in demand and electricity price signals. The updated states are retrieved from the simulated perfect-forecast arrays of demand (D) and electricity prices (E) for the next $S$ days as follows:

$$ $\textbf{d}_{t+1}\leftarrow\texttt{D}[t+1,t+S],\quad e_{t+1}\leftarrow\texttt{E }[t+1,t+S]\quad\quad\forall t\in T$ $$

It is worth noting that the simulated data is appropriately longer than the episode length to account for the state horizon; therefore, no padding is used at any point.

##### Compressor Physical Condition Transition:

The following updates track the evolution of maintenance status and compressor readiness for each compressor $c\in C$, based on operational decisions. The initial physical state at the start of the simulation is given by $(tlcm_{c,0},tslm_{c,0},cdm_{c,0})$, and future states are derived accordingly.

$$ $\text{tslm}_{c,t+1}=\begin{cases}0,&\text{if }a_{\text{maintenance},c}(t)=1\\ \text{tslm}_{ct}+1,&\text{otherwise}\end{cases}$ $$

$$ $\text{tlcm}_{c,t+1}=\begin{cases}\text{MTTR}_{c}-1,&\text{if }a_{\text{ maintenance},c}(t)=1\land\text{cdm}_{ct}=1\\ \text{tlcm}_{ct}-1,&\text{if }a_{\text{maintenance},c}(t)=1\land\text{cdm}_{ct }=0\\ \text{tlcm}_{ct},&\text{otherwise}\end{cases}$ $$

$$ $\text{cdm}_{c,t+1}=\begin{cases}1,&\text{if }\text{tslm}_{c,t+1}\geq\text{MNRD }_{c}\\ 0,&\text{otherwise}\end{cases}$ $$

To ensure feasibility and consistency with compressor state constraints, a sanitization step is applied to the raw agent actions before the state update, but after the associated violation costs are realized. For each compressor $c\in C$, the action is adjusted as follows:

- •
If $\text{tslm}_{ct}\geq\text{MTTF}_{c}$ and $a_{\text{maintenance},c}(t)\neq 1$, then:
$\displaystyle\Rightarrow\quad a_{\text{maintenance},c}(t)$
$\displaystyle\leftarrow 1\quad\text{and}\quad a_{\text{production},c}(t)$
$\displaystyle\leftarrow 0$
This rule enforces maintenance when it is overdue (i.e., $\text{tslm}_{ct}\geq\text{MTTF}_{c}$) but the agent has not scheduled it. Maintenance is forced, and production is halted to ensure feasibility and update the environment state accordingly.
- •
If $a_{\text{maintenance},c}(t)=1$ and $a_{\text{production},c}(t)>0$, then:
$\displaystyle\Rightarrow\quad a_{\text{production},c}(t)$
$\displaystyle\leftarrow 0$
This rule ensures that production is not allowed during maintenance.
- •
If $\text{cdm}_{ct}=0$ and $\text{tlcm}_{ct}=0$ and $a_{\text{maintenance},c}(t)=1$, then:
$\displaystyle\Rightarrow\quad a_{\text{maintenance},c}(t)$
$\displaystyle\leftarrow 0$
To ensure maintenance is not performed after the required duration or prematurely before it is permitted.
- •
If $\text{tlcm}_{ct}>0$ and $a_{\text{maintenance},c}(t)\neq 1$, then:
$\displaystyle\Rightarrow\quad a_{\text{maintenance},c}(t)$
$\displaystyle\leftarrow 1\quad\text{and}\quad a_{\text{production},c}(t)$
$\displaystyle\leftarrow 0$
To make sure maintenance remains active for the required maintenance duration.

#### A.8.6 Cost Function

The agent may incur various costs at each time step if system constraints are violated, encouraging it to learn an optimal policy. We reiterate that these costs are realized before the action is sanitized. The potential costs are as follows:

Maintenance Duration Cost:

This cost is incurred if maintenance is interrupted before it is completed or prolonged, in which case $\text{tlcm}_{ct}$ becomes negative. The cost is denoted by $\text{C}^{\text{MI}}_{ct}$, where MI stands for maintenance interruption, defined as:

$$ $\text{C}^{\text{MI}}_{ct}=\begin{cases}&\text{if }\left(a_{\text{maint.},c}(t) \neq 1\text{ and }\text{tlcm}_{ct}>0\right)\\ \rho_{\text{MD}}\cdot\exp\left(|\text{tlcm}_{ct}|\right)&or\left(a_{\text{ maint.},c}(t)=1\text{ and }\text{tlcm}_{ct}=0\text{ and }\text{tslm}_{ct}=0 \right)\\ &or\left(a_{\text{maint.},c}(t)=1\text{ and }\text{tlcm}_{ct}<0\right),\\ 0&\text{otherwise}.\end{cases}$ $$

Maintenance Failure Cost:

This cost occurs if the Time Since Last Maintenance ($\text{tslm}_{ct}$) exceeds the Mean Time to Failure ($\text{MTTF}_{c}$) of the compressor. The cost is denoted by $\text{C}^{\text{MF}}_{ct}$, where MF stands for maintenance failure, defined as:

$$ $\text{C}^{\text{MF}}_{ct}=\begin{cases}\rho_{\text{MF}}\cdot(\text{tslm}_{ct}- \text{MTTF}_{c})&\text{if }\left(a_{\text{maint.},c}(t)=0\text{ and }\text{ tslm}_{ct}>\text{MTTF}_{c}\right),\\ \rho_{\text{MF}}&\text{if }\left(a_{\text{maint.},c}(t)=0\text{ and }\text{ tslm}_{ct}=\text{MTTF}_{c}\right),\\ 0&\text{otherwise}.\end{cases}$ $$

Early Maintenance Cost:

This cost is incurred if maintenance is performed on a compressor when it is not yet eligible for maintenance (i.e., when $\text{cdm}_{ct}=0$, indicating that the compressor has recently undergone maintenance, and $\text{tlcm}_{ct}=0$). The cost is proportional to the Time Since Last Maintenance ($\text{tslm}_{ct}$) of the compressor. The cost is denoted by $\text{C}^{\text{EM}}_{ct}$, where EM stands for early maintenance, defined as:

$$ $\text{C}^{\text{EM}}_{ct}=\begin{cases}-\rho_{\text{EM}}\cdot\text{tslm}_{ct}& \text{if }\left(a_{\text{maint.},c}(t)=1\text{ and }\text{cdm}_{ct}=0\text{ and }\text{tlcm}_{ct}=0\right),\\ 0&\text{otherwise}.\end{cases}$ $$

Ramp Cost:

This cost is incurred when a compressor is ramped up while under maintenance.

$$ $\text{C}^{\text{Ramp}}_{ct}=\begin{cases}\rho_{\text{RP}}\cdot a_{\text{prod.} ,c}(t)\cdot\text{Cap}_{c}&\text{if }\left(a_{\text{maint.},c}(t)=1\text{ and } a_{\text{prod.},c}(t)\neq 0\right),\\ 0&\text{otherwise}.\end{cases}$ $$

Demand Cost:

This penalty is incurred if the total supply from production and external purchases does not meet the demand on the current day. The total supply is the sum of the production and external purchase, and if this is less than or greater than the demand, a penalty is imposed proportional to the absolute difference between demand and supply.

$$ $\text{C}^{\text{Demand}}_{t}=\rho_{\text{D}}\cdot|d_{t}-\sum_{c}(a_{\text{ production},c}\cdot Cap_{c})|$ $$

Total Cost:

$$ $C^{\text{total}}_{t}=\sum_{c\in\mathcal{C}}(C^{\text{MI}}_{ct}+C^{\text{MF}}_{ ct}+C^{\text{EM}}_{ct}+C^{\text{Ramp}}_{ct})+C^{\text{Demand}}_{t}$ $$

#### A.8.7 Reward Function

The reward function represents the cost incurred by the agent for making decisions related to production and external purchases. At each time step $t$, the reward is defined as:

$$ $\displaystyle\Pi^{action}_{t}$ $\displaystyle=-\bigl{(}\text{production cost}_{t}+\text{external purchase cost }_{t}\bigr{)}$ $$

where,

$$ $\displaystyle\text{production cost}_{t}$ $\displaystyle=\sum_{c\in\mathcal{C}}(\mathrm{SPEN}_{c}\;\,a_{\text{production} ,c}(t)\;\,\mathrm{Cap}_{c}\;\,\texttt{E}[t])$ $\displaystyle\text{external purchase cost}_{t}$ $\displaystyle=a_{\text{purchase}}(t)\cdot Q_{ext}\cdot\alpha_{ext}$ $$

The production cost at time $t$ is calculated using the production rate, compressor capacity, specific energy consumption, and electricity price. The external purchase cost is incurred when demand exceeds production capacity, calculated by multiplying the purchase amount by the external price.

#### A.8.8 Episode Termination

The episode terminates when $t+1=T$, indicating the start of the day immediately after the final one.

### A.9 Production Scheduling in Air Separation Unit ( ASUEnv )

#### A.9.1 Overview

The ASUEnv simulates a liquid air separation unit (ASU) producing liquid nitrogen, oxygen, and argon in a Gym-compatible reinforcement learning framework. We consider the ASU to have hourly production capacity while demand occurs only at 24-hour intervals. To that end, at each hour the agent selects production rates based on inventory levels to minimize electricity and storage costs while ensuring daily demand satisfaction. Production actions are restricted to the convex hull of historically observed operating points, guaranteeing industrial feasibility. We follow the simplified dynamics of Zhang et al. [32], which capture core ASU behavior without the complexity of detailed mode-switching or maintenance constraints.

We make several key assumptions to keep the environment tractable. Only two production modes—“Work” (active production) and “Off” (zero output)—are available each hour, and switching between them is instantaneous and cost-free. Electricity prices and product demands over a short rolling horizon are treated as perfectly known and error-free. Storage capacity for each product is finite and nonnegative, with penalties applied if inventory limits are exceeded or daily demand is unmet. Finally, we do not model any external purchasing option, assuming all demand falls within the ASU’s inherent production capability. The simulation runs for a total of seven days with a four-day lookahead, resulting in $24\times 7$ steps per episode.

#### A.9.2 Problem Setup

The sets and known parameters used to describe the environment are shown below:

##### Sets

- •
$\mathcal{T}=\{0,\ldots,T\}$: Set of hours in the episode.
- •
$\mathcal{D}=\{1,\ldots,D\}$: Set of days in the episode.
- •
$\mathcal{J}$: Set of liquid products: liquid nitrogen (LIN), liquid oxygen (LOX) and liquid argon (LAR).
- •
$\mathcal{X}$: Set of vertices of the convex hull derived from historical operational data.

##### Parameters

- •
$T$: Episode length in hours.
- •
$D$: Episode length in days.
- •
$S$: Lookahead days used in the forecast.
- •
$m$: Number of products in $\mathcal{J}$.
- •
$[IV^{j,\mathrm{lb}},\,IV^{j,\mathrm{ub}}]$: Lower and upper bounds on the inventory level of each product $j$.
- •
$N$: Number of historical production data points.
- •
$v_{x}$: Extreme points of the convex hull.
- •
$\mathrm{HPQ}$: Historical hourly production quantities.
- •
$k$: Number of extreme points of the convex hull.
- •
$\bar{\texttt{D}}_{t}$: Matrix of hourly product demands used in the simulation, of dimension $\mathbb{R}_{+}^{m\times 4(S+T+1)}$.
- •
$\bar{\texttt{E}}_{t}$: Array of hourly electricity prices used in the simulation, of dimension $\mathbb{R}_{+}^{24(S+T+1)}$.
- •
$PQ_{t}$: Array of products produced based on the actions.
- •
$DQ_{d}$: Array of dispatched product quantities at the end of each day in the simulation.
- •
$\rho_{\mathrm{IV}}$: Penalty parameter for inventory overflow.
- •
$\rho_{\mathrm{D}}$: Penalty parameter for unmet demand.
- •
$C_{\text{fixed}}$: Fixed cost per hour to keep the plant operational.
- •
$C_{\text{unit}}$: Hourly unit production cost.

#### A.9.3 State Space

At any hour $t$, the observation state is represented by the vector

$$ $s(t)=\left(e_{t},D_{t},IV_{t}\right),\quad\forall t\in\mathcal{T}$ $$

The state vector $s(t)$ captures all relevant information needed for the agent to make production planning decisions at hour $t$ in the Air Separation Unit (ASU). It includes deterministic forecasts of electricity prices and product demands over a lookahead horizon of $S$ future days; therefore, including the current day, the total forecasting horizon becomes $S+1$ days. It also includes the current inventory levels of liquid products. The components are defined as follows:

- •
Electricity Price Forecast ($e_{t}\in\mathbb{R}_{+}^{24(S+1)\times 1}$): a vector of day-ahead electricity prices for the next $S+1$ days, given at an hourly resolution (totaling $24(S+1)$ elements), measured in KWh.
- •
Demand Forecast ($D_{t}\in\mathbb{R}_{+}^{24(S+1)\times m}$): a matrix of demands for each product $j$ over the next $S+1$ days, where $j\in\mathcal{J}$. Each row represents the hourly demand forecast for one product; however, the demand is non-zero only at 24-hour intervals.
- •
Inventory Levels ($IV_{t}\in\mathbb{R}_{+}^{m\times 1}$): the current inventory levels of all $m$ liquid products at hour $t$. These are bounded between predefined lower and upper capacity limits.

#### A.9.4 Action Space

The action space at each time step $t$ is defined as:

$$ $a(t)=\lambda(t),$ $$

where $\lambda(t)\in[0,1]^{k}$ represents the weights of the extreme points in the convex hull of the possible production quantities. We assume historical hourly production quantities are given by

$$ $\mathrm{HPQ}=\bigl{\{}Q_{j}^{1},\,Q_{j}^{2},\,\ldots,\,Q_{j}^{N}\mid j\in \mathcal{J}\bigr{\}},$ $$

where $N$ is the number of samples available. The feasible region $\mathrm{FR}$ is then approximated as $\texttt{convhull}(\mathrm{HPQ})$, with vertices $v_{jx}$ for $j\in\mathcal{J}$, $x\in\mathcal{X}$, and $|\mathcal{X}|=k$. The quantity of each product produced at time $t$ is

$$ $PQ_{jt}=\sum_{x\in\mathcal{X}}\lambda_{x}(t)\,v_{jx}.$ $$

The received actions are clipped to their bounds $[0,1]$ and then normalized to enforce the convex-sum property $\sum_{x=1}^{k}\lambda_{x}(t)=1$ as described in the next section.

#### A.9.5 Transition Dynamics

Here we describe how the system state evolves in response to the agent’s production decisions at each discrete hourly time step $t\in T$. Let the observation vector at time $t$ be $s(t)=\left(e_{t},D_{t},IV_{t}\right)$, with $s(0)$ denoting the initial observation. The transition to $s(t+1)$ is governed by two primary updates: the shifting of forecast windows and the physical evolution of product inventories.

##### Forecast Update:

The forecast arrays for electricity prices and product demand are deterministic and span a rolling horizon of $S+1$ days at hourly resolution. The environment updates the forecast component of the state differently depending on whether a new hour or a new day has begun.

##### Hourly Shifting:

At each non-zero hour $(t+1)\bmod 24\neq 0$, the environment updates the observation by shifting the forecast vectors leftward by one hour to discard outdated information. This is achieved via the shift_observation() routine:

$$ ${D}_{t+1}\leftarrow\texttt{ShiftLeft}({D}_{t}),\quad{e}_{t+1}\leftarrow\texttt {ShiftLeft}({e}_{t})$ $$

where ShiftLeft removes the earliest hour from the forecast vector and appends a placeholder value—such as the average of the remaining values (for electricity) or zeros (for demand)—to preserve the total horizon length $24(S+1)$.

##### Daily Refresh:

At the start of each new day (i.e., when $(t+1)\bmod 24=0$), the environment invokes update_demand_and_electricty_state() to refresh the entire forecast arrays for electricity prices and product demands. This function populates only the end-of-day demand values (i.e., the 24th hour of each day) while keeping the rest of the hourly entries zero, as demand is modeled to be daily:

$$ $D_{t+1}\;\leftarrow\;\bigl{(}\bar{\texttt{D}}[t+1],\,\bar{\texttt{D}}[t+2],\, \ldots,\,\bar{\texttt{D}}[\,t+24\,(S+1)\,]\bigr{)}$ $$

$$ $E_{t+1}\;\leftarrow\;\bigl{(}\bar{\texttt{E}}[t+1],\,\bar{\texttt{E}}[t+2],\, \ldots,\,\bar{\texttt{E}}[\,t+24\,(S+1)\,]\bigr{)}$ $$

This rolling update mechanism enables the agent to make production decisions with awareness of upcoming price and demand trends while ensuring that outdated data does not persist in the observation state. The simulated data exceeds the episode length to cover the lookahead horizon, eliminating the need for padding during daily refresh.

##### Inventory State Transition:

Before updating the inventory, action sanitization rescales the raw weights $\{\lambda_{x}(t)\}$ to enforce the convex-sum constraint:

$$ $\lambda_{x}(t)\;\leftarrow\;\frac{\lambda_{x}(t)}{\sum_{y=1}^{k}\lambda_{y}(t) }\quad\forall x\in\mathcal{X},\quad\text{s.t.}\quad\sum_{x=1}^{k}\lambda_{x}(t )=1$ $$

The inventory vector is then updated based on the production action $PQ_{t}$ at time $t$, itself computed as a convex combination of feasible production profiles. If $t\mod 24=23$ (the last hour of the day), a portion of inventory is shipped to meet daily demand; otherwise, production is simply added:

$$ $IV_{j,t+1}=\begin{cases}IV_{j,t}+PQ_{j,t}-DQ_{j,d},&\text{if }t\bmod 24=23,d= \left\lfloor\frac{t+1}{24}\right\rfloor\\ IV_{j,t}+PQ_{j,t}&\text{otherwise,}\end{cases}$ $$

where $DQ_{j,d}=\min(IV_{j,t}+PQ_{j,t},\ D[j,23])$ ensures that the shipment quantity does not exceed the sum of available inventory and production.

Finally, state sanitization corrects any inventory overflow by checking whether the inventory penalty $\text{C}^{\text{IV}}_{t}>0$. If so, the inventory vector is clipped element-wise to its upper bounds:

$$ $IV_{t+1}\leftarrow\min\bigl{(}IV_{t+1},\,IV^{\text{ub}}\bigr{)},$ $$

thereby preserving feasibility by preventing storage violations.

#### A.9.6 Cost Function

The agent may incur several types of costs at each time step $t$ from production decisions or constraint violations. These costs guide the agent toward learning an efficient and feasible production policy. The individual cost components are as follows:

Inventory Overflow Cost:
This cost is incurred if the inventory of any product exceeds its maximum storage capacity:

$$ $\text{C}^{\text{IV}}_{t}=\rho_{\text{IV}}\cdot\sum_{j\in\mathcal{J}}\max(IV_{j ,t}-IV_{j}^{\text{max}},0)$ $$

Demand Shortfall Cost:
At the end of each day (i.e., every 24 hours), the environment evaluates whether the shipped quantity meets the daily demand. A cost is imposed for any shortfall:

$$ $\text{C}^{D}_{t}=\begin{cases}\rho_{\text{D}}\cdot\sum_{j\in J}\max\left(D[j,t ]-\text{DQ}_{j,d},0\right)&\text{if }t\bmod 24=23,d=\left\lfloor\frac{t+1}{24} \right\rfloor\\ 0&\text{otherwise},\end{cases}$ $$

where $D[j,23]$ is the daily non-zero demand for product $j$, and $DQ_{j,d}$ is the quantity shipped.

##### Total Cost

$$ $\text{C}^{\text{total}}_{t}=\text{C}^{\text{IV}}_{t}+\text{C}^{D}_{t}$ $$

#### A.9.7 Reward Function

The reward at time $t$ is defined as the negative of the production cost:

$$ $\Pi^{production}_{t}=-\left(\text{production cost}_{t}\right)$ $$

The production cost is formally given by:

$$ $\text{production cost}_{t}=\begin{cases}0&\text{if }\sum_{x}\lambda_{x}(t)=0, \\ C_{\text{fixed}}+\left(\sum_{j\in J}PQ_{jt}\right)\cdot C_{\text{unit}}\cdot e [t]&\text{otherwise}\end{cases}$ $$

where $PQ_{jt}$ is the production quantity of product $j$, and $e[t]$ is the electricity price at time $t$. These costs arise from the fixed cost $C_{\text{fixed}}$, incurred if any production occurs and a variable cost, proportional to the total production and electricity price at hour $t$.

#### A.9.8 Episode Termination

The episode terminates when $(t+1)=H$ or $(t+1)=24D$, i.e., when the next starting hour is the first hour following the final day.

## Appendix B Other Results

### B.1 Additonal Environments and Variants

We consider results for three additional environments—ASUEnv, UNEnv-v1, and GTEP without transmission lines—and two variants of the previously solved BlendingEnv, based on the illegal action correction strategy used, namely, disable and none. Figure [2](https://arxiv.org/html/2506.02255v1#A2.F2) presents the average reward and cost per training epoch, with shaded regions indicating one standard deviation around the mean. Table [2](https://arxiv.org/html/2506.02255v1#A2.T2) summarizes the evaluation results, averaged over 10 episodes, for the additional environments. For the set of environments considered, the values in green correspond to the evaluation reward and cost of the best-performing algorithms, while values in red indicate those of the worst-performing algorithms. The optimal reward is calculated by solving an optimization counterpart of the environment at each step. Finally, we divide the environments based on the performance of algorithms by evaluating whether the reward is reasonably close to that of the optimal solution or not. The strategy used to determine the algorithm with the best and worst performance, as well as the criteria to segregate the environments based on performance, remain the same as described in the main paper.

Figure: (a) UCEnv-v1
Refer to caption: x18.png

#### B.1.1 Environments with reasonable performance

The following environments illustrate scenarios in which at least one algorithm successfully trains a policy that yields a reasonably high rewards with low associated cost:

- •
UCEnv-v1: This unit commitment version models a multi-bus system with explicit power flows, enabling realistic evaluation of policies where generation and demand locations are critical. This example considers a multi-bus unit commitment power system with five generators distributed across four buses, connected by five transmission lines. It operates over a 24-hour horizon with hourly updates to demand forecasts, generator states, and network power flows. Training is done with 100 episodes per epoch. OnCRPO turns out to be the best, while CPO lags slightly in performance. However, both demonstrate consistent performance during training and evaluation.
- •
GTEPEnv- without transmission: This environment can be considered a variant of the original one, in the sense that we modify the original GTEPEnv by removing transmission lines. This simplified GTEP environment models regional generation expansion without power transfers between regions. Each region must install sufficient generation capacity to meet its own forecasted demand, and transmission lines are not part of the decision space. This case study involves a five-region power system with two generators over a 10-period planning horizon. We observe that CPO and TRPOLag perform on par with each other. Furthermore, DDPG fails to learn to take any meaningful actions, as reflected by a reward close to zero and a very high cost.
- •
ASUEnv: This example considers production scheduling in an air separation unit over a one-week horizon, where the agent takes hourly steps to meet daily product demands. We consider a planning horizon of 5 days, with each episode consisting of 168 steps, reflecting the operation of the ASU over a week. We train using 60 episodes per epoch. A significant gap is observed between the training and testing costs for CPO and TRPOLag.

#### B.1.2 Environments not trained to reasonable optimality

The following environments presented significant challenges during training, preventing the agents from learning reasonably optimal policies.

- •
BlendingEnv-disable: The description of the environment remains the same as in the main paper; however, the disable strategy represents setting a subset of actions directly to zero. A significant gap is observed between training and evaluation costs for all algorithms except DDPGLag, while a significant gap in reward is observed only for CPO.
- •
BlendingEnv-none: The description of the environment remains the same as described in the main paper; however, the none strategy represents no action correction, allowing actions to persist despite constraint violations. A significant gap is observed between training and evaluation for both cost and reward in P3O, and for cost only in TRPOLag. As shown in Figure [2(d)](https://arxiv.org/html/2506.02255v1#A2.F2.sf4), DDPGLag and P3O exhibit considerable oscillations in both reward and cost over training epochs. As also noted in the main paper, this instability may be attributed to the highly non-convex nature of the underlying optimization problem.

#### B.1.3 Discussion

The superior performance of ONCRPO and TRPOLag remains consistent, as reported in the main paper. However, for the ASUEnv, we observe that CPO marginally outperforms ONCRPO, positioning it as the best algorithm in this setting. DDPGLag sustains its poor performance for the additional environments as well. Regarding the BlendingEnv-prop environment evaluated in the main paper, the reward outcomes for the other two action correction strategies, namely prop and none, remain unchanged. Specifically, all algorithms fail to learn policies that yield meaningful rewards, as evidenced by the evaluation results in Table [2](https://arxiv.org/html/2506.02255v1#A2.T2). Furthermore, when relaxing the environment complexity—as exemplified by the GTEPEnv variant without transmission lines—the best gap from the optimal reward is approximately 11%, closely matching the 10.16% gap observed in the more complex environment discussed in the main paper. This indicates that even substantial reductions in environmental complexity do not significantly narrow the performance gap achieved by the learned policies. These findings underscore the persistent challenges inherent in such constrained settings and highlight the urgent need for more refined and robust approaches to safe reinforcement learning in these domains.

**Table 2: Evaluation results for 10 episodes**
|  | Optimal | CPO | DDPGLag |  |  |
| --- | --- | --- | --- | --- | --- |
| Environment | Reward | Reward | Cost | Reward | Cost |
| UCEnv-v1 | -264104 | -319469 | 0 | -575239 | 216.0 |
| GTEP- without transmission lines | -330 | -333.0 | 0 | -6.0 | 706040.0 |
| Blending- disable | -1800 | 0 | 443.96 | 0 | 54207.6 |
| Blending- none | -1800 | 0.24 | 100.11 | 1800.0 | 67750.0 |
| ASUEnv | -6597.50 | -7295.45 | 25563.34 | -7743.56 | 13130.41 |

### B.2 Constraint-wise violation analysis across Safe-RL algorithms

In the following subsection we interpret the plots that report the *mean episode-level constraint breaches per epoch* observed during training with five safe-rl algorithms.
To help the reader connect each trend to its control philosophy, we first give a concise description of every algorithm and its reward–cost balancing mechanism.

- •
Constrained Policy Optimization (CPO): At each update, CPO solves a small trust-region *quadratic program* (QP) that maximizes expected return while ensuring the new policy remains within a cumulative-cost constraint set. This guarantees monotonic improvement in reward without violating the safety constraints.
- •
Trust-Region Policy Optimization with a Lagrange Multiplier (TRPOLag): TRPOLag enhances standard *Trust-Region Policy Optimization* (TRPO) by introducing an on-policy Lagrange multiplier, updated after each batch. This multiplier penalizes excessive costs within the Kullback–Leibler trust region, balancing reward optimization and safety.
- •
On-Policy Constrained Reinforcement Policy Optimization (OnCRPO): OnCRPO alternates between maximizing reward using a standard *Proximal Policy Optimization* (PPO) objective when constraints are satisfied, and minimizing costs through a dedicated surrogate objective when constraints are breached, thus explicitly balancing reward and safety.
- •
Penalty-based Proximal Policy Optimization (P3O): P3O integrates an *adaptive exterior penalty* into PPO’s clipped-surrogate objective, dynamically adjusting penalty strength based on constraint violations. The penalty increases when cumulative cost exceeds its budget and decreases otherwise, gradually guiding the policy towards feasibility while prioritizing reward.
- •
Deep Deterministic Policy Gradient with a Lagrange Multiplier (DDPGLag): DDPGLag employs an off-policy deterministic actor–critic architecture, augmented with stability enhancements from *Twin Delayed Deep Deterministic Policy Gradients* (TD3). It concurrently learns a Lagrange multiplier, policy, and critic from replay-buffer data, effectively balancing reward and constraint satisfaction through deterministic policy gradients.

#### B.2.1 RTNEnv

Figure [3](https://arxiv.org/html/2506.02255v1#A2.F3) illustrates mean episode-level constraint violations per epoch for the RTNEnv. For *inventory-level* constraints, projection-based algorithms—CPO, OnCRPO, and TRPOLag—consistently reduce violations, converging swiftly to minimal violation levels. P3O achieves comparable compliance more gradually, while DDPGLag consistently exhibits the highest residual violations. *Equipment-usage* violations are inherently less frequent owing to the simpler nature of the constraints compared to inventory management; all methods maintain near-baseline levels throughout training, with CPO, OnCRPO, and TRPOLag achieving compliance earliest, followed slightly later by P3O, and DDPGLag showing a modestly higher yet infrequent violation rate.

Figure: Figure 3: Average number of episode violations for different epochs for RTNEnv
Refer to caption: x29.png

#### B.2.2 STNEnv

Figure [4](https://arxiv.org/html/2506.02255v1#A2.F4) presents mean episode-level constraint breaches per epoch for the STNEnv. Regarding *inventory-level* safety, the projection-driven algorithms—CPO, OnCRPO, and TRPOLag—steadily minimize violations, stabilizing at the lowest counts observed. P3O demonstrates a slower convergence, while DDPGLag retains a significantly higher residual violation count. *Equipment-usage* breaches are consistently low for all algorithms due to reasons similar to the RTN environment, with immediate practical compliance from CPO, OnCRPO, and TRPOLag, followed shortly thereafter by P3O. DDPGLag again presents a slightly elevated but infrequent violation occurrence, reflecting the general pattern of constraint management effectiveness among these approaches.

Figure: Figure 4: Average number of episode violations for different epochs for STNEnv
Refer to caption: x31.png

#### B.2.3 UCEnv

##### Single-bus system without network constraints (UCEnv-v0):

Figure [5](https://arxiv.org/html/2506.02255v1#A2.F5) reports mean episode-level constraint violations per epoch for the single-bus UCEnv problem, covering *minimum up-time*, *minimum down-time*, and *ramping-rate* constraints. Projection-based algorithms—CPO, OnCRPO, and TRPOLag—rapidly reduce violations (in about 100 epochs), converging to the lowest residual counts. P3O achieves compliance more gradually as its adaptive penalty strengthens, while DDPGLag is the quickest to reduce violations (in less than 10 epochs) early on due to aggressive Lagrangian penalty updates and off-policy learning but plateaus with ramp-up residual violations due to higher variance and instability.

Figure: Figure 5: Average number of episode violations for different epochs for UCEnv-v0
Refer to caption: x33.png

##### Multiple-bus system with network constraints (UCEnv-v1):

Figure [6](https://arxiv.org/html/2506.02255v1#A2.F6) illustrates mean episode-level breaches per epoch for the multi-bus UCEnv problem, incorporating *minimum up-time*, *minimum down-time*, *ramping-rate*, and network feasibility constraints. The qualitative performance of the algorithms remains the same as described for UCEnv-v0.

Figure: Figure 6: Average number of episode violations for different epochs for UCEnv-v1
Refer to caption: x37.png

#### B.2.4 GTEPEnv

##### GTEPEnv without transmission lines:

Figure [7](https://arxiv.org/html/2506.02255v1#A2.F7) illustrates mean episode-level constraint violations per epoch for the single-bus generator-expansion task without active transmission line constraints. The projection-based algorithms—CPO, OnCRPO, and TRPOLag—swiftly minimize generator-bound violations and stabilize demand balance, demonstrating effective per-update safety management. P3O achieves similar compliance more gradually due to adaptive penalty adjustments, while DDPGLag retains higher residual violations and exhibits a persistent imbalance in demand, reflecting its off-policy variance. With the network simplified to a single bus, line-capacity violations are naturally negligible.

Figure: Figure 7: Average number of episode violations for different epochs for GTEPEnv without transmission lines
Refer to caption: x41.png

##### GTEPEnv with transmission lines.

The trends are similar to the variant without transmission lines.

#### B.2.5 BlendingEnv

##### Example with prop strategy:

Figure [8](https://arxiv.org/html/2506.02255v1#A2.F8) shows the mean episode-level constraint violations per epoch during training for the Blending environment using the *prop* strategy. For inventory bound violations, CPO, TRPOLag, and OnCRPO rapidly converge to zero violations. P3O exhibits a gradual decline with minor oscillations before stabilizing at a small but non-zero level. DDPGLag consistently oscillates without clear convergence. In contrast, for the in-out rule violations, CPO, TRPOLag, and OnCRPO show significant increases, stabilizing at substantial violation levels. P3O displays oscillatory increases, while DDPGLag maintains persistent oscillations around a steady level. Property violations slightly increase over time for P3O, CPO, TRPOLag, and OnCRPO with minor fluctuations, whereas DDPGLag demonstrates clear oscillations with an upward trend.

This pattern qualitatively indicates that agents tend to learn to take no action, as reflected by training rewards near zero reported in the main paper, rather than learning actions that actively prevent violations. The combination of higher rewards and higher costs for DDPGLag suggests the agent’s inability to effectively learn to avoid constraint violations.

Figure: Figure 8: Average number of episode violations for different epochs for BlendingEnv with prop strategy
Refer to caption: x43.png

Figure: Figure 9: Average number of episode violations for different epochs with BlendingEnv with disable strategy
Refer to caption: x46.png

##### Example with disable strategy:

Figure [9](https://arxiv.org/html/2506.02255v1#A2.F9) shows mean episode-level constraint violations per epoch for the Blending environment employing the *disable* strategy. For inventory bound violations, TRPOLag and OnCRPO steadily decrease to near-zero levels. CPO initially reduces violations significantly, then slightly rebounds to settle at a small residual value. P3O exhibits visible oscillations before stabilizing, whereas DDPGLag decreases slowly but consistently. Regarding in-out rule violations, TRPOLag and OnCRPO increase significantly and stabilize at substantial levels, while CPO demonstrates slight initial reduction followed by an increase. DDPGLag converges to near-zero violations despite fluctuations, and P3O exhibits an oscillatory increasing trend. For property violations, DDPGLag converges to zero despite oscillations, P3O stabilizes at a small positive level after oscillatory movements, and CPO, TRPOLag, and OnCRPO gradually increase with minor fluctuations.

##### Example with none strategy:

Figure [10](https://arxiv.org/html/2506.02255v1#A2.F10) presents mean episode-level constraint violations per epoch for the Blending environment using the *none* strategy. Inventory bound violations initially decrease significantly for OnCRPO and CPO, converging to near-zero. P3O gradually decreases and stabilizes at a non-zero level, while DDPGLag only slightly reduces its violation count. TRPOLag exhibits a non-monotonic decrease-increase-decrease pattern. In-out rule violations slightly decrease for DDPGLag, and display a complex decrease-increase-decrease trend for TRPOLag. CPO, P3O, and OnCRPO steadily decrease, converging similarly to moderate residual levels. Property violations show a pronounced initial decline followed by stabilization for DDPGLag, a steady downward trend for CPO and OnCRPO, and an intermediate stabilization level for P3O. TRPOLag again demonstrates a non-monotonic trend with an initial drop, mid-training increase, and final decline. Overall, property violations are more pronounced in the *none* strategy compared to the *prop* and *disable* strategies, with notable oscillations particularly in TRPOLag (none strategy) and P3O (disable strategy). This is due to the higher average reward obtained in the *none* strategy compared to the others.

Figure: Figure 10: Average number of episode violations for different epochs for BlendingEnv with none strategy
Refer to caption: x49.png

#### B.2.6 InvMgmtEnv

Figure [11](https://arxiv.org/html/2506.02255v1#A2.F11) presents the mean episode-level constraint violations per epoch for the InvMgmtEnv, which includes bounds constraints on *reordering quantities*, *on-hand inventory*, *pipeline inventory*, *backlog*, and *sales*. Projection-based methods—CPO, OnCRPO, and TRPOLag—rapidly minimize violations of the reordering quantity bounds, establishing robust and sustained compliance throughout training. P3O follows a similar trend but requires additional epochs to recover from early spikes. All algorithms achieve near-zero violations for the on-hand inventory, pipeline inventory, sales, and backlog bounds constraints.

Figure: Figure 11: Average number of episode violations for different epochs for InvMgmtEnv
Refer to caption: x52.png

#### B.2.7 GridStorageEnv

Figure [12](https://arxiv.org/html/2506.02255v1#A2.F12) illustrates the mean episode-level violations per epoch for the GridStorageEnv, covering bounds constraints on *generator power limits*, *battery charge rates*, *battery discharge rates*, *load shedding*, *bus-angle bounds*, *battery state of charge (SOC)*, and the *slack-bus angle*. The projection-driven algorithms—CPO, OnCRPO, and TRPOLag—rapidly mitigate violations, quickly stabilizing compliance. P3O demonstrates slower convergence, with temporary mid-training peaks in generator power and battery rates before aligning with the leading methods. Violations for battery SOC and slack-bus voltage angles remain consistently at zero across all algorithms, indicating complete compliance from the outset.

Figure: Figure 12: Average number of episode violations for different epochs for GridStorageEnv
Refer to caption: x53.png

#### B.2.8 SchedMaintEnv

Figure [13](https://arxiv.org/html/2506.02255v1#A2.F13) illustrates mean episode-level violations per epoch for the Integrated Scheduling & Maintenance benchmark, covering constraints on *maintenance-duration*, *maintenance-failure*, *early-maintenance*, *ramping-in-maintenance*, and *demand-unsatisfaction*. Projection-based methods—CPO, OnCRPO, and TRPOLag—swiftly reduce violations across all constraints, establishing stable and minimal breach levels. P3O follows a similar trend but exhibits transient spikes in violations for almost all constraints during mid-training, except for demand-unsatisfaction, where it consistently fails to learn full compliance. For the other constraints, it eventually achieves violation levels comparable to the projection-based algorithms. DDPGLag consistently displays higher residual violations, notably in duration and demand-unsatisfaction categories, highlighting variability from its replay-buffer updates. Maintenance-failure violations remain consistently low for all methods.

Figure: Figure 13: Average number of episode violations for different epochs for SchedMaintEnv
Refer to caption: x58.png

#### B.2.9 ASUEnv

Figure [14](https://arxiv.org/html/2506.02255v1#A2.F14) shows the mean episode-level constraint violations per epoch in the Air Separation Unit environment, focusing on *inventory limits* and *demand satisfaction*. Projection-based methods—CPO, OnCRPO, and TRPOLag—quickly reduce inventory violations, reaching stable minimal levels. P3O exhibits a general downward trend in inventory violations but retains substantial residual violations by the end of training. DDPGLag maintains the highest violation counts, particularly for inventory constraints, consistent with the higher variance typical of off-policy algorithms.

Notably, demand violations emerge later in training—after approximately half the epochs—because the agent begins to encounter underproduction violations only once it has learned to avoid overproduction. Consequently, P3O and DDPGLag, which fail to sufficiently reduce inventory violations, rarely experience demand violations. In contrast, CPO, TRPOLag, and OnCRPO exhibit fewer than one demand violation episode on average per epoch. This underscores the importance of cost shaping to encourage the agent to explore all relevant cost signals early in training, enabling it to balance constraints effectively and converge to optimal policies.

Figure: Figure 14: Average number of episode violations for different epochs for ASUEnv
Refer to caption: x63.png

### B.3 Computational Time for Training Different Environments with Various Algorithms

Table [3](https://arxiv.org/html/2506.02255v1#A2.T3) lists the wall-clock training time (hours) required by each algorithm on every environment.
All experiments were run on an AWS g4dn.xlarge instance—4 vCPUs, 16 GB RAM, and a single NVIDIA T4 GPU.

**Table 3: Wall-clock training time (hours) across environments and algorithms**
| Environment | P3O | DDPGLag | TRPOLag | OnCRPO | CPO |
| --- | --- | --- | --- | --- | --- |
| RTNEnv | 0.13 | 0.26 | 0.12 | 0.12 | 0.12 |
| STNEnv | 0.13 | 0.26 | 0.13 | 0.13 | 0.13 |
| UCEnv-v0 | 4.66 | 9.18 | 4.43 | 4.43 | 4.46 |
| UCEnv-v1 | 4.58 | 3.71 | 4.44 | 4.44 | 4.43 |
| GTEPEnv | 0.33 | 1.00 | 0.31 | 0.31 | 0.32 |
| GTEPEnv-without transmission lines | 0.33 | 0.97 | 0.32 | 0.31 | 0.32 |
| BlendingEnv-prop | 1.20 | 3.62 | 1.16 | 1.18 | 1.23 |
| BlendingEnv-disable | 1.23 | 3.79 | 1.17 | 1.24 | 1.22 |
| BlendingEnv-none | 1.24 | 3.72 | 1.18 | 1.12 | 1.21 |
| InvMgmtEnv | 0.93 | 2.60 | 0.82 | 0.83 | 0.88 |
| GridStorageEnv | 0.94 | 2.70 | 0.86 | 0.84 | 0.95 |
| SchedMaintEnv | 0.57 | 1.70 | 0.56 | 0.56 | 0.58 |
| ASUEnv | 2.38 | 8.80 | 2.42 | 2.39 | 2.42 |

##### Runtime trends across algorithms

The projection–trust-region trio—TRPO-Lag, On-CRPO, and CPO—shows virtually identical runtimes, reflecting their shared on-policy update pattern with lightweight trust-region sub-problems.
P3O matches this group closely, incurring only a modest overhead for its adaptive penalty update.
By contrast, the off-policy DDPG-Lag is consistently the slowest: replay-buffer sampling, twin-critic evaluation, and deterministic actor updates roughly double the wall-clock time relative to the on-policy methods.
The results thus indicate that enforcing safety through on-policy projections or dual updates delivers both strong constraint compliance and favourable computational efficiency, whereas off-policy dual learning trades longer runtimes for greater sample reuse.

## Peer Reviews

confidence: 3
contribution: 3
initial_rating: 6
presentation: 3
questions: - I suggest to add a compact taxonomy table in the main text summarizing the 9 environments along axes: domain, obs/action sizes, discrete vs continuous decisions, presence of integer constraints, stochasticity, horizon length, and canonical safety constraints. This will immediately clarify diversity claims.
- Provide hyperparameter search ranges, seeds, evaluation episode counts, and computational budgets. Moreover, the appendix is really dense: a tighter edit would help.
- Include diagnostic analyses (e.g., constraint-violation breakdowns or action-feasibility rates) to better explain algorithmic failures.
- I would suggest selecting Benchmark and Datasets as the primary submission area.
soundness: 3
strengths: - **Well-motivated contribution:** The authors target an important mismatch: popular safe-RL benchmarks are control/robotics focused, while many real safety problems are OR problems with mixed-integer structure and long horizons. SafeOR-Gym is clearly targeted to that gap.
- **Implementation quality:** Environments expose explicit cost channels (CMDP wrapper) rather than only reward penalties, making them directly useful for constraint-aware algorithms in OmniSafe and similar toolkits.
- **Empirical insight:** The results clearly show that most safe RL algorithms fail to handle mixed-integer or nonconvex constraints effectively, a useful diagnostic for future algorithmic design.
- **Comparative positioning:** The paper situates itself well relative to OR-Gym and SustainGym, emphasizing constraint modeling and CMDP compliance
- **Potential impact:** If released and maintained, SafeOR-Gym could become a standard benchmark for the intersection of operations research and RL.
summary: SafeOR-Gym presents a suite of nine operations-research (OR) inspired environments (e.g., RTN, STN, UC, GridStorage, Blending, InvMgmt, SchedMaint, ASU, GTEP) implemented as Gym/CMDP environments with native OmniSafe compatibility and explicit cost signals for constraint handling. The paper benchmarks a range of safe-RL algorithms (CPO, TRPOLag, P3O, OnCRPO, DDPGLag, SAC variants, FOCOPS, etc.), compares to optimization baselines (Gurobi) where applicable, and reports that many current safe-RL methods struggle on these structured OR problems.
weaknesses: - **Envirnonment diversity, but overlapping algorithmic challenges:** The nine environments span a good range of OR-inspired domains, from power systems to scheduling and process control. However, several share similar underlying learning characteristics — such as long-horizon decision-making, hybrid discrete–continuous actions, and feasibility-based safety constraints. For instance, RTN and STN represent closely related scheduling formulations. As a result, while the suite is cohesive and well-scoped for evaluating this particular class of problems, it may capture a narrower slice of safe-RL challenges (e.g., limited stochasticity, partial observability, or risk-based safety criteria). Expanding future versions to include such variations could further broaden its applicability.
- **Lack of real-world data and realism:** The environments rely on JSON instance files with synthetic parameters, but no real-world datasets or data provenance are provided. Moreover, most environments are deterministic, with stochasticity introduced only in one variant. This limits the practical realism claimed in the paper.
- **Reproducibility:** The main text does not provide a public code link, which hinders verification and community adoption (assuming it exists online).

---

confidence: 4
contribution: 2
initial_rating: 4
presentation: 3
questions: Could you provide a concise comparative summary of all nine environments (e.g., action/observation dimensions, horizon, constraint types, stochasticity) to help readers better understand their diversity and complexity?

Since most environments are currently deterministic, do you plan to introduce stochastic variants (e.g., uncertain demand or resource availability) to better reflect real-world operational uncertainty?

You note that most algorithms struggle to learn effective policies—could you elaborate on the underlying causes (e.g., infeasibility, gradient instability, constraint scaling issues) and whether any diagnostics were performed?

Could you clarify what specific structural or operational features (e.g., mixed-integer decisions, coupling over time, nonconvex safety constraints) make these environments representative of practical OR systems rather than abstract RL benchmarks?
soundness: 3
strengths: The main strength of this work lies in its attempt to model complex and structured OR problems within a safe RL framework. The environments are well-motivated, grounded in realistic operational settings, and go beyond traditional control benchmarks like Safety Gym. Integrating these tasks with OmniSafe provides immediate usability and reproducibility, which makes SafeOR-Gym a valuable contribution to the community.

The paper also highlights an important empirical finding: most current safe RL algorithms struggle to learn effective policies when faced with hybrid discrete–continuous decisions and nonconvex constraints. This observation underlines the benchmark’s relevance as a stress test for future algorithmic advances.
summary: This paper introduces SafeOR-Gym, a benchmark suite of nine operations research (OR)–inspired environments designed to evaluate safe reinforcement learning (RL) algorithms. The environments model structured decision problems such as unit commitment, scheduling, blending, and inventory management, each formulated as a Constrained MDP and fully compatible with the OmniSafe framework. The authors benchmark several state-of-the-art safe RL algorithms (CPO, TRPOLag, P3O, OnCRPO, DDPGLag) and compare their performance against optimal solutions obtained with mathematical programming solvers such as Gurobi.
weaknesses: The structure of the paper is not fully clear. While nine environments are introduced, only a few (two or three) are described in sufficient detail in the main text, with the rest delegated to the supplementary material. A concise comparative summary (e.g., a table of environment sizes, horizon lengths, constraint types, and stochasticity) would help readers understand their diversity and modeling differences.

Moreover, although the authors refer to these tasks as real-world, most environments are fully deterministic, with only the blending task including a stochastic component. This weakens the “realistic” claim, since real operational systems usually involve uncertainty in demand, resource availability, or failures. Including stochastic variants would strengthen the benchmark’s practical realism.

The results section shows that most algorithms struggle to reach satisfactory policies. While this is an important observation, the paper could provide a deeper analysis of why this occur

Finally, I would have appreciated a clearer discussion on what makes each environment “real-world” beyond the fact that it represents a classical OR problem. Highlighting the specific characteristics that differentiate these environments from standard RL benchmarks would make the contribution stronger.

Missing code link in paper (find it on google)

---

confidence: 3
contribution: 2
initial_rating: 2
presentation: 1
questions: 1. You state that state-of-the-art optimization solvers (e.g., Gurobi) can solve the deterministic nonconvex problems globally while strictly enforcing constraints. Under what conditions is RL actually necessary?

2. In RTNEnv and STNEnv, all safe RL algorithms fail to converge to good solutions. Should we interpret this as evidence that these tasks are fundamentally out of reach for current policy-gradient methods? Or do you believe the tasks are learnable with RL but require different training schemes. Why is PPO not explicitly included as a baseline for “can vanilla RL solve this at all,” independent of safety?

3. How many random seeds were used for Figure 1 and the other reported learning curves? Some curves (e.g., Figure 1(a)) appear to have essentially zero visible variance. Please report the number of seeds and whether shaded regions represent standard deviation or standard error.

4. The benchmark spans very different domains. How did you validate that the state transitions, action constraints, and reward/cost definitions are implemented correctly in each environment? From an RL researcher’s perspective, it is difficult to audit the correctness of these environments without deep domain expertise.

5. In several plots in Figure 1, some algorithms’ reward curves become almost perfectly flat very early in training. Please explain what causes these early plateaus.

6. In Figure 1(f) (BlendingEnv), most algorithms show reward collapse and large fluctuations.  Any insight here would help clarify what specifically makes this environment challenging.

7. How you define the cost threshold for each task?
soundness: 2
strengths: 1.The paper systematically evaluates CMDP-based safe RL algorithms in environments with structured constraints, mixed-integer decision structure, and hybrid discrete–continuous actions, spanning planning, power systems, chemical process control, and maintenance scheduling. The results clearly show that many widely used algorithms fail on these tasks.

2.The benchmark suite is implemented to be directly usable: it exposes a CMDP interface through OmniSafe while staying compatible with standard Gymnasium-style RL interfaces. This lowers the barrier for the community to reproduce the experiments and extend them.
summary: The paper proposes SafeOR-Gym, a benchmark suite for safe reinforcement learning in realistic operations and planning settings. Unlike prior safe RL benchmarks that focus on robotics-style continuous control with safety penalties, these environments model industrial decision problems. The environments feature hybrid discrete–continuous actions, long-horizon coupling through forecasts, and hard operational constraints; constraint violations are exposed as explicit cost signals via a CMDP interface compatible with OmniSafe/Gymnasium. The results show that current safe RL methods are still far from being reliable for industrial decision-making.
weaknesses: 1. The paper devotes a large amount of space to domain-specific operational details of each environment (e.g., industrial process assumptions, power system structure, scheduling rules), but provides relatively little insight into why current CMDP-style algorithms fail. The work reports outcomes (“algorithm X fails here, succeeds there”) but does not analyze which aspects of the tasks (e.g., mixed integers, nonconvex feasible sets, long-horizon credit assignment under feasibility penalties) are responsible for failure, nor how existing safe RL algorithms might need to be modified to handle them.

2. The experimental section mostly presents success/failure across algorithms and tasks, but does not attempt to explain the observed behaviors. For example, why do certain algorithms collapse in BlendingEnv. Without this analysis, it is difficult to extract algorithmic lessons for the safe RL community.

3. It is difficult for a typical RL researcher (without deep OR / energy / process-control background) to judge whether a learned policy is actually making reasonable decisions. All environments are highly domain-specific, and the paper does not provide qualitative rollouts, interpretable visualizations, or sanity checks of agent behavior over time. This limits the accessibility and impact of the benchmark.
4. The paper argues that these environments are realistic and safety-critical, but also states that strong optimization solvers (e.g., Gurobi) can compute globally optimal solutions while strictly satisfying all constraints in the deterministic settings. This weakens the motivation for using RL in these tasks.

5. Many plots appear effectively single-run (visually almost no variance band), and it is unclear how many random seeds were used.

---

confidence: 3
contribution: 2
initial_rating: 2
presentation: 2
questions: **Q1.** The paper emphasizes the importance of handling mixed discrete–continuous action spaces, yet the benchmark evaluation relies primarily on algorithms developed for continuous domains. Could the authors clarify how these algorithms interact with the discrete components of the tasks, and whether any relaxation or encoding strategy was applied?

**Q2.** The paper distinguishes between modelling safety through reward penalties and using explicit cost signals within a CMDP framework. Could the authors elaborate on the conceptual and practical differences between these two formulations, and explain how explicit cost modelling leads to improved learning stability or constraint satisfaction in practice?

**Q3.** Table 1, the authors refer to “classical OR” tasks. Could the authors clarify what qualifies as a “classical” OR task in this context, and how the proposed SafeOR-Gym environments differ from or extend these traditional formulations?
soundness: 2
strengths: The key point is the provision of a set of different tasks with solid and well-documented representations, and strong baselines for comparison. The goal is to provide the community with a testbed beyond robotics and control tasks, which often treat constraint violations as merely negative rewards. The paper is mostly well written and covers similar works available in the literature.
summary: The work proposes a new reinforcement learning (RL) benchmark based on operations research (OR) tasks. The main motivation is to provide tools for evaluating RL approaches beyond standard control and robotics domains. In my review, I focused primarily on the relevance of these tasks for RL, as well as on the paper’s presentation quality and reproducibility. I used large language models (LLMs) to polish the writing after crafting the first draft by hand; none of the opinions expressed were artificially generated.
weaknesses: Although the work is undoubtedly well motivated, several aspects could be improved to enhance clarity and strengthen the contribution.

**Introduction:**
In the second paragraph, the discussion around OmniSafe occupies considerable space and may appear premature. At this early stage, readers who are not already familiar with the framework might find this section confusing, since its relevance to the benchmark’s motivation is not yet established. This content would be better placed later in the paper, perhaps in the methodology or implementation section.

**Results and Motivation:**
The results shown in Figure 1 are a primary concern. In several environments, particularly (f), some RL algorithms fail to outperform what would likely be a randomly initialized policy. In other cases, the convergence is extremely fast, which could reflect limited task complexity, insufficient exploration, or inadequate network architecture.
Moreover, the authors’ explanation that poor performance stems from the nonconvexity of the underlying problems is not entirely convincing. RL is generally robust to nonconvex optimization landscapes; the key issue may instead lie in problem formulation or algorithmic design. This raises a broader question: **if RL methods perform poorly on these tasks, does the benchmark truly represent a suitable or fair testbed for RL research?** The authors should clarify whether the environments are intentionally designed to expose current limitations or whether they are inherently ill-suited for RL-based approaches.

**Technical Content:**
Some detailed technical descriptions currently in the main text could be moved to the appendix. This would help streamline the narrative and maintain focus on the conceptual and empirical contributions.

**Figure 1:**
The figure is difficult to interpret. The overlapping curves, and dense information make it challenging to extract meaningful insights.

**Minor remarks:**
Although code release is not mandatory, providing a supplementary file with the benchmark implementation and trained models would substantially improve transparency and allow reviewers to verify reproducibility.