RLC 2026 · Reinforcement Learning Conference

DR-Gym

Towards Affordable Energy: A Gymnasium Environment for Electric Utility Demand-Response Programs

Jose E. Aguilar Escamilla  ·  Lingdong Zhou  ·  Xiangqi Zhu  ·  Huazheng Wang

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.

$9,000/MWh
ERCOT's system-wide price cap, sustained for 72+ consecutive hours during Winter Storm Uri (Feb. 2021)
FERC/NERC, 2021
$10,000+
Bills faced by some residential customers exposed directly to wholesale price volatility
FERC/NERC, 2021
20–72%
Acceptance-rate range reported across 15 large-scale residential demand-response pilots
Faruqui & Sergici, 2010
Why DR-Gym

A market-level testbed, not another device controller.

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.

1

First market-level DR Gym environment

The first standardized Gymnasium environment for electric-utility-level demand response via credit issuance, complete with baselines, validation experiments, and reproducible data snapshots.

2

Calibrated, closed-loop realism

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.

3

Configurable, risk-aware reward

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.

Architecture

Six components, one hourly decision.

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.

🎛️ActionCredit rate $/kWh
🏠BuildingSimulatorPer-building demand
📈MarketModelWholesale price + forecast
👥CustomerResponseAcceptance & reduction
🗼GridStressNormalized indicators
🎯RewardComputerMulti-objective + CVaR
DR-Gym architecture: external data sources (CityLearn, weather, market data) feed six internal components inside DemandResponseEnv, exchanging observation, action, and reward with the RL agent.

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.

Show detailed component data-flow (variables & signals)
Detailed DR-Gym data flow: building demand d_i,t and temperature T_t feed GridStressCalculator and RewardComputer; MarketModel produces price p_t; OpSavingsGenerator tracks budget B_t; the agent receives 32-dim observation s_t and reward r_t, and returns action a_t = c_t.

Every component exposes reset() and is reconstructed fresh on env.reset(). Configuration is a plain Python dict passed to every component at construction time.

MDP formulation

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.

IndicesFeature
0–1Hour of day, day of week
2–3Aggregate demand, wholesale price
4–74-hour price forecast
8Temperature
9–12Stress indicators (demand, price, thermal, overall)
13–14Available budget, last credit issued
15–24Per-building individual loads
25–295-hour demand history
30–31Cumulative credits issued, episode day
Simulator Validation

Calibrated against real market and building data.

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.

Wholesale price dynamics: 7-day trajectory with spike storms and heavy-tailed log-scale price distribution
Wholesale price dynamics. Regime-switching storms cluster over multiple hours (mean ≈7h) rather than isolated spikes; AR(1) autocorrelation ρ̂₁ ≈ 0.85, within the 0.78–0.93 range reported for CAISO/PJM/Nord Pool.
Aggregate building demand profile across 50 buildings and 40 episodes, showing morning ramp and evening peak
Building demand. EnergyPlus/ResStock profiles reproduce the expected bimodal residential pattern — morning ramp (6–9h) and evening peak (17–21h) — with realistic inter-building variability.
Customer acceptance curves by archetype and fatigue decay over consecutive activations
Customer response. Weighted-average acceptance at c=$0.05/kWh is ≈0.65, matching the 20–72% empirical DR-pilot range; the fatigue mechanic captures declining participation under repeated activation.
Scalability ablation comparing baseline policies at N=50 and N=500 buildings
Scalability. Re-evaluating all baselines at N=500 buildings (commercial-portfolio scale) preserves rank ordering, confirming the signal structure is stable across population sizes.
Show full ERCOT day-ahead calibration (4-panel validation)
Four-panel ERCOT calibration: TOU base profile vs literature range, AR(1) residual distribution, hourly spike rate, and a 7-day Winter-Storm-Uri-analog trajectory
(a) TOU base falls within ERCOT literature ranges. (b) AR(1) noise σ=0.020 $/kWh, within the [0.015, 0.025] literature range. (c) Storm-driven level-crossings exceed discrete-event counts because one storm causes multiple crossings — expected given spike_exit_prob=0.15 (≈7h mean storm duration). (d) A 7-day Uri-analog stress test with elevated spike entry and temperature boost.
Reward Design

Multi-objective, and risk-aware by default.

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.

Per-step reward
rt  =  λs (  wR·Rt/N  −  wC·Ct/N  −  wσ·σtoverall  −  wrisk·Δriskt )
R_t, C_t — utility revenue and consumer cost this step
σ_t^overall — weighted grid-stress indicator ∈ [0,1]
Δrisk_t — change in a running risk measure over consumer bills (e.g. CVaR); any risk-aware measure can be swapped in
(w_R, w_C, w_σ, w_risk) — configurable weights; default (0.3, 0.5, 0.2, 0.3)
CVaR-revenue trade-off frontier: sweeping uniform credit level from 0 to 0.10 dollars per kWh traces a Pareto frontier between mean reward and CVaR of consumer bills
The risk–revenue trade-off is real and tunable. Sweeping a uniform credit policy from $0 to $0.10/kWh traces a clean Pareto frontier: higher credit levels monotonically reduce CVaR0.95 of consumer bills at a modest revenue cost — exactly the trade-off the reward is designed to expose to risk-aware algorithms (CVaR-PPO, WCSAC, distributional RL).
Learning Experiments

The environment is learnable, and risk-reducing.

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.

PPO learning curve over training and final policy comparison against four baselines
Training & final comparison. PPO converges within ~5×10⁵ steps and achieves the highest mean evaluation reward among all tested policies.
Mean episode reward and CVaR of consumer bills across No-Credit, Uniform, Rule-Based, Budget-Aware, and PPO policies
Consumer protection. PPO achieves the lowest CVaR0.95 on consumer bills of any policy tested, while No-Credit — despite the highest raw revenue — leaves consumers most exposed to tail risk.

✓Revenue preservation

Despite issuing more credits than No-Credit, PPO maintains positive utility revenue across all pricing scenarios.

✓Budget efficiency

PPO uses 72–85% of the daily budget (vs. 100% for Uniform, <40% for No-Credit) — selective rather than exhaustive.

✓CVaR reduction

PPO reduces CVaR0.95 of per-building episode bills by 18–24% relative to No-Credit across pricing seeds.

Related Environments

How DR-Gym differs.

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.

FeatureDR-Gym (ours)CityLearnSinergymGrid2Op
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
Get Started

Install and run in a minute.

DR-Gym is a standard Gymnasium environment — it drops into any RL library that speaks the Gym interface (Stable-Baselines3, CleanRL, Ray RLlib).

# create the environment
mamba env create -f environment.yml
mamba activate dr-gym
pip install -e .
from risk_aware_grid.env import DemandResponseEnv

env = DemandResponseEnv(config={'num_buildings': 50})
obs, info = env.reset(seed=42)
for _ in range(24):
  action = env.action_space.sample()
  obs, reward, terminated, truncated, info = env.step(action)
  if terminated:
    print(f"Episode CVaR: {info['episode_cvar']:.4f}")
Honest Accounting

Limitations & future work.

Feedback parameters are literature-informed defaults

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.

PPO is a proof of concept, not a benchmark ceiling

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.

Customer archetypes come from survey ranges

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.

Takeaways

Market-level, not device-level

DR-Gym is the first standardized testbed for the electric-utility credit-issuance decision itself.

Risk-aware by design

A native, configurable CVaR term exposes the revenue–tail-risk trade-off directly in the reward.

Calibrated and learnable

Validated against CAISO/ERCOT and ResStock data; PPO reliably beats hand-designed baselines.

Resources

Paper, code, and citation.

BibTeX
@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}
}