Market-level, not device-level
DR-Gym is the first standardized testbed for the electric-utility credit-issuance decision itself.
Towards Affordable Energy: A Gymnasium Environment for Electric Utility Demand-Response Programs
Department of Electrical Engineering and Computer Science, Oregon State University
TL;DR. Wholesale electricity prices can spike to catastrophic levels during extreme weather, and demand-response credits are a promising way to shield consumers — but there was no standardized RL environment for training the utility's credit-issuance policy. DR-Gym fills that gap: a Gymnasium-compatible environment with a regime-switching wholesale market model calibrated to CAISO/ERCOT, physics-based building demand from CityLearn/ResStock, a heterogeneous customer response model, and a configurable multi-objective reward with a native, plug-and-play risk-aware (CVaR) term.
Existing open-source environments (e.g., CityLearn) put the agent in charge of a single building's HVAC or battery. DR-Gym puts the agent in the role of the electric utility itself — issuing an hourly bill credit to a whole population of buildings under wholesale price uncertainty and a hard operating budget.
The first standardized Gymnasium environment for electric-utility-level demand response via credit issuance, complete with baselines, validation experiments, and reproducible data snapshots.
A regime-switching price-spike process with temperature coupling, validated against CAISO/ERCOT statistics, and a heterogeneous logistic customer-acceptance model calibrated to empirical DR trial data.
A multi-objective reward with a plug-and-play risk term. PPO outperforms four literature baselines on the composite objective while achieving lower CVaR on consumer bills and staying revenue-positive.
Every env.step(action) call runs the same pipeline: the agent's credit rate flows through building demand, market pricing, customer response, grid stress, and budget accounting to produce the next observation and reward.
DR-Gym is built from six loosely-coupled components that can be individually reconfigured or replaced — e.g. swap in a live price feed, a different customer behavior model, or a physics-based grid-stress calculator, without touching the agent-facing interface.
Every component exposes reset() and is reconstructed fresh on env.reset(). Configuration is a plain Python dict passed to every component at construction time.
DR-Gym is an episodic MDP 𝓜 = ⟨𝒮, 𝒜, P, R, γ⟩. At each hour, the agent observes state st ∈ ℝ³² (hourly mode) and selects a credit rate at = ct ∈ [0, cmax].
Action space: continuous Box(0, c_max, shape=(1,)), default c_max = $0.10/kWh.
Revenue: Rt = (pretail − ct − pt) · Dt
Consumer cost: Ct = (pretail − ct) · Dt
Budget: a daily budget B caps total credits paid; unspent budget rolls over at rate 0.95.
| Indices | Feature |
|---|---|
| 0–1 | Hour of day, day of week |
| 2–3 | Aggregate demand, wholesale price |
| 4–7 | 4-hour price forecast |
| 8 | Temperature |
| 9–12 | Stress indicators (demand, price, thermal, overall) |
| 13–14 | Available budget, last credit issued |
| 15–24 | Per-building individual loads |
| 25–29 | 5-hour demand history |
| 30–31 | Cumulative credits issued, episode day |
Wholesale prices are benchmarked against CAISO/ERCOT day-ahead statistics via the gridstatus library; building demand is benchmarked against the underlying CityLearn/ResStock source data.
spike_exit_prob=0.15 (≈7h mean storm duration). (d) A 7-day Uri-analog stress test with elevated spike entry and temperature boost.The reward balances utility revenue, consumer welfare, and grid stress — with an optional, plug-and-play risk-aware penalty on the tail of the consumer bill distribution.
PPO (Stable-Baselines3) trained for 2M steps against four hand-designed baselines from the literature. The goal is not state-of-the-art performance — it's demonstrating that DR-Gym's design produces a challenging, tractable, and meaningfully risk-sensitive learning signal.
Despite issuing more credits than No-Credit, PPO maintains positive utility revenue across all pricing scenarios.
PPO uses 72–85% of the daily budget (vs. 100% for Uniform, <40% for No-Credit) — selective rather than exhaustive.
PPO reduces CVaR0.95 of per-building episode bills by 18–24% relative to No-Credit across pricing seeds.
Existing open-source energy RL environments target device-level control or transmission-level topology. DR-Gym is the retail-market layer in between: a price-taking utility choosing how much to pay consumers to curtail.
| Feature | DR-Gym (ours) | CityLearn | Sinergym | Grid2Op |
|---|---|---|---|---|
| Target agent role | Market-level utility (DR credit pricing) | Building controller (HVAC/battery) | Building controller (thermostat) | System operator (topology) |
| Risk objective | Risk-aware & neutral (CVaR built in) | Risk-neutral (expected cost) | Risk-neutral (energy vs. comfort) | Risk-neutral (margin) |
| Extreme events | Markov regime-switching spikes | Historical static weather/pricing | Historical/simulated TMY weather | Static historical scenarios |
| Human behavior | Stochastic fatigue, 4 archetypes | N/A (compliant devices) | N/A (compliant devices) | N/A (inelastic loads) |
| Demand coupling | Temperature-coupled synthetic & ResStock | Physics-based thermal dynamics | EnergyPlus co-simulation | PandaPower / AC-DC power flows |
DR-Gym is a standard Gymnasium environment — it drops into any RL library that speaks the Gym interface (Stable-Baselines3, CleanRL, Ray RLlib).
Demand-persistence decay (γ=0.9) and price-elasticity (λ=0.001) are set from the literature rather than fit to a specific DR program; empirical calibration is future work.
We use standard PPO to validate learnability. Benchmarking risk-aware algorithms (CVaR-PPO, WCSAC, distributional RL) against risk-neutral baselines is a natural next step.
The four archetype parameters are drawn from published survey ranges rather than fit to one dataset. Calibration to Pecan Street or LBNL DR pilot data is a planned direction.
DR-Gym is the first standardized testbed for the electric-utility credit-issuance decision itself.
A native, configurable CVaR term exposes the revenue–tail-risk trade-off directly in the reward.
Validated against CAISO/ERCOT and ResStock data; PPO reliably beats hand-designed baselines.
Paper, code, and citation.
@inproceedings{aguilar2026drgym,
title = {Towards Affordable Energy: A Gymnasium Environment for
Electric Utility Demand-Response Program},
author = {Aguilar Escamilla, Jose E. and Zhou, Lingdong and
Zhu, Xiangqi and Wang, Huazheng},
booktitle = {Reinforcement Learning Conference (RLC)},
year = {2026}
}