There is considerable interest in using time-varying electricity prices to shape consumer demand response, and better align energy demand with renewable production. However, optimal prices generally vary over time in response to complex signals such as weather forecasts, sunrise/sunset times, and day-of-week patterns; and existing methods are not able to make efficient use of such rich contextual information. Here, we propose a neural-network-based algorithm for contextual energy pricing, modeling pricing as a Stackelberg game and leveraging a mean-field solution representation from Mehrabi et al.~(2024). The approach learns constrained mappings from contextual features to feasible price signals. We validate our approach by simulating the energy grid in several US cities, and show that incorporating contextual information can considerably increase the value of the demand response programs.
Figures & tables
Figure 1 : Illustration of the value of context-aware pricing. Left: Optimal price profiles for sunny and cloudy weather conditions obtained by minimizing a grid-risk objective based on net demand. The objective combines the l2 norm and the sum of squared differences between consecutive periods, capturing overall demand magnitude and temporal fluctuations. Right: Net demand on a single (sunny) day when both price profiles from the left panel are applied. The sunny-day optimal price produces a more stable demand profile, while the cloudy-day price, applied to the same sunny day, yields poor performance with a pronounced duck curve.
Figure 2 : Sequential contextual price learning. The operator announces the day-ahead price using the forecasted context and the current pricing rule. After operation, HEMS responses, realized consumption, and renewable supply reveal the actual net-demand signal, which is used to update the network weights and price prototypes. Better context forecasts lead to prices that are better aligned with realized system conditions and improve demand management.
Figure 3 : Role of weather forecasts in contextual price learning. Forecasted weather variables are used to generate context-dependent price signals prior to real-time operation. Households respond by optimizing device schedules (e.g., HVAC, BESS) based on the announced prices and anticipated conditions, yielding an operation plan. Forecast errors may lead to discrepancies between planned and realized consumption, as devices operate under realized conditions rather than the planned consumption trajectory. This introduces forecast-induced variability into demand feedback and subsequent price updates.
Figure 4 : Comparison of price signals generated by the feedback-only and contextual learning algorithms under an alternating weather regime. The cluster-based soft classifier algorithm (with the number of clusters K=2 ) learns distinct price profiles corresponding to the two day types. In contrast, the feedback-only algorithm converges to a single price signal that is approximately the average of the two contextual prices.
Figure 5 : Comparison of peak demand shaving (PDS) achieved by the feedback-only and contextual pricing algorithms under an alternating weather regime. The shaded area represents the PDS gain achieved by contextual pricing over the feedback-only benchmark. The contextual pricing algorithm consistently attains greater peak demand reduction.
Figure 6 : Comparison of peak demand shaving (PDS) across different contextual learning algorithms trained over 90 days of weather data in Denver, CO. Both the projection layer and interior point methods show high volatility, with occasional negative PDS values. The proximal gradient method performs moderately well, while the cluster-based soft classifier is the only algorithm that consistently achieves positive PDS.
Figure 7 : Violin plot comparing peak demand shaving (PDS) across the four contextual learning algorithms. The cluster-based soft classifier exhibits the highest average PDS with the smallest spread.
Figure 8 : Weather profiles of San Francisco, Atlanta, and Phoenix in July 2022. Panel (a) shows the daily temperature profiles; panel (b) shows the daily solar irradiance profiles. Solid lines represent the mean daily profiles across the month, while the shaded regions indicate the corresponding day-to-day variability ( ±1 standard deviation).
Figure 9 : Daily peak demand shaving achieved by the cluster-based soft classifier pricing algorithm for San Francisco, Atlanta, and Phoenix in summer 2022.
Figure 10 : Average hourly price signals generated by the cluster-based soft classifier algorithm for San Francisco, Atlanta, and Phoenix in July 2022. Solid lines represent the mean hourly price profiles, and shaded regions represent ±1 standard deviation across days.
Appendix figures & tables4 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 11 : Constrained output learning architecture with cluster-based soft classifier. Network maps input features to a probability assignment over clusters, with each cluster representing a archetypal system condition. Constraints are applied directly to the cluster-level outputs, ensuring that the final price signal—computed as a convex combination of the cluster-level outputs—remains feasible.
Figure 12 : Constrained output learning architecture with a projection layer. Unlike projected gradient descent, which adjusts training variables iteratively, the projection layer approach enforces constraints directly on the network outputs by projecting them onto the feasible set.
Method
Convergence
Adaptiveness
Efficiency
Projection layer
x Leads to over-parametrization
x Requires differentiable projection operator
✓Utilizes various first-order methods
Interior point
✓Imposes constraints actively
x Requires differentiable norm as constraints
x Causes numerical instability near boundary
Proximal gradient
x Provides only lower bound via weak dual
✓Allows for constraints to be non-differentiable
✓Combines gradient descent ascent (GDA) with proximal operators
Soft classifier
✓Imposes constraints via projected gradient descent; Admits universal approximation
✓Allows for constraints to be non-differentiable
✓Utilizes various first-order methods
Appendix
Table 1 : Advantages and Limitations to Different Methods
Figure 13 : Comparison of net peak demand under flat-rate and context-aware demand response pricing across cities in 2022. The 45-degree line indicates identical net peak demand under the two pricing schemes. Points below the line correspond to days on which the proposed learning framework achieves lower net peak demand than the flat-rate scheme.
We study contextual dynamic pricing with linear valuations and bounded-support agnostic noise, whose induced demand curve may be non-Lipschitz with arbitrary jumps and atoms. Such discontinuities break the cross-context interpolation arguments used by smooth-demand pricing algorithms, while the best previous method achieved only O~(T3/4) regret. We propose Conservative-Markdown Redirect-UCB Pricing, a polynomial-time algorithm that combines randomized parameter estimation, conservative residual-grid probing, and confidence-based one-step redirection. Our algorithm achieves O~(T2/3) optimal regret, matching the known lower bounds of Kleinberg and Leighton (2003) up to logarithmic factors and improving over the previous upper bound of Xu and Wang (2022). Under stochastic well-conditioned contexts, this closes the long-existing open regret gap in linear-valuation contextual pricing under agnostic non-Lipschitz noise distribution.
Extreme weather and volatile wholesale electricity markets expose residential consumers to catastrophic financial risks, yet demand response at the distribution level remains an underutilized tool for grid flexibility and energy affordability. While a demand-response program can shield consumers by issuing financial credits during high-price periods, optimizing this sequential decision-making process presents a unique challenge for reinforcement learning despite the plentiful offline historical smart meter and wholesale pricing data available publicly. Offline historical data fails to capture the dynamic, interactive feedback loop between an electric utility's pricing signals and customer acceptance and adaptation to a demand-response program. To address this, we introduce DR-Gym, an open-source, online Gymnasium-compatible environment designed to train and evaluate demand-response from the electric utility's perspective. Unlike existing device-level energy simulators, our environment focuses on the market-level electric utility setting and provides a rich observational space relevant to the electric utility. The simulator additionally features a regime-switching wholesale price model calibrated to real-world extreme events, alongside physics-based building demand profiles. For our learning signal, we use a configurable, multi-objective reward function for specifying diverse learning objectives. We demonstrate through baseline strategies and data snapshots the capability of our simulator to create realistic and learnable environments.
Jose E. Aguilar Escamilla, Lingdong Zhou, Xiangqi Zhu +1
Department of Electrical Engineering and Computer Science, Oregon State University, USA
We study contextual dynamic pricing with arbitrary covariate sequences and bounded, possibly nonbinary purchase quantities. Demand follows a semiparametric surplus-index model with an unknown linear valuation parameter and an unknown Hölder-smooth response. We impose neither concavity nor strong unimodality on revenue and allow nonunique optimal prices. We develop a pilot-corrected layered decision-partitioning policy that combines directional pilot estimation, local polynomial learning, predictable data assignment, and global action elimination. Pilot correction removes the first-order effect of valuation-parameter error, while permanent labels enable concentration under adaptive sampling. The policy attains the minimax smoothness-dependent horizon rate up to logarithmic factors; a matching lower bound already holds for a constant-context binary-demand subclass.
Xueping Gong, Zhuoluo Zhang, Zhaowei Miao +1
School of Management, Xiamen University · Department of Industrial Engineering and Decision Analytics, The Hong Kong University of Science and Technology