IEEE Transactions on Smart Grid Early Access · 2026

End-to-End Battery Dispatch with Exact Rainflow Degradation via Mixed-Integer Differentiable Predictive Control

Eshagh Safarzadeh Ravajiri1 Ján Drgoňa2 Mahdi Mehrtash3 Benjamin F. Hobbs1

1 Environmental Health and Engineering, Johns Hopkins University
2 Civil and Systems Engineering, Johns Hopkins University
3 Electrical and Biomedical Engineering, University of Nevada, Reno

Learning to accelerate battery dispatch while accounting for the cost of its cycles. A neural policy selects operating modes and power levels from demand, solar, and price forecasts. Training evaluates rainflow degradation directly and combines sparse cycle-extrema gradients with a dense proxy signal.

Johns Hopkins Whiting School of Engineering University of Nevada, Reno
Battery policy, SOC dynamics, rainflow cycle pairing, and hybrid gradient feedback.
View full size
Forecasts flow through the policy to a state-of-charge trajectory. Moving markers follow that illustrative trajectory; cycle highlights appear as rainflow pairs its extrema. The two gradient paths return the degradation signal to policy training.

The dispatch problem

Buying electricity at lower prices and discharging at higher prices can reduce a household’s energy bill. But cycling also wears the battery. Two schedules with similar energy throughput can incur different degradation because cycle depth matters.

Rainflow counting identifies full and half cycles in an irregular state-of-charge (SOC) trajectory. Its discrete cycle-pairing operations complicate gradient-based learning. Mixed-integer differentiable predictive control (MI-DPC) keeps that forward cost calculation while supplying a custom backward signal.

The study considers independent, grid-connected residential batteries with rooftop solar: a 24-hour schedule at 15-minute resolution, or 96 dispatch intervals. SOC is expressed as stored energy in kWh.

Energy cost + cycle degradation

$$\min_{\mathbf{x}}\;\sum_t\left(p_t^{\mathrm{import}}\pi_t^{\mathrm{buy}}-p_t^{\mathrm{export}}\pi_t^{\mathrm{sell}}\right)\Delta t+C_{\mathrm{cyc}}$$
$$C_{\mathrm{cyc}}=\frac{R}{\eta_{\mathrm{dis}}}\sum_i n_i\Phi(\delta_i),\qquad\Phi(\delta)=a\delta^b$$

Cycle depths \(\delta_i\) and counts \(n_i\) come from rainflow; \(R\) is replacement cost and \(\eta_{\mathrm{dis}}\) is discharge efficiency. The paper uses a Li-NMC stress law. Charge/discharge limits, mode exclusivity, battery dynamics, grid balance, SOC bounds, and a terminal SOC target define the scheduling problem.

Formulation: paper Sections II-A–B, Equations (1)–(4). The forward implementation’s half-cycle convention is described in Section III-C7.

From forecasts to a trainable dispatch policy

The graphical abstract follows the computational path below. Offline training uses the scheduling objective itself, without requiring optimal dispatch labels. At deployment, the trained network predicts a schedule and an optional quadratic-program (QP) filter adjusts its continuous powers.

  1. Encode the forecasts

    Normalize solar generation, demand, purchase price, and the buy–sell price spread. A shared multilayer encoder feeds separate mode and power heads over the full horizon.

  2. Select modes and bound power

    A straight-through Gumbel–Softmax estimator supplies one-hot charge, discharge, or idle decisions during training. Sigmoid power outputs are scaled by the power limit and gated by the chosen mode. Inference uses discrete mode selection.

  3. Unroll the physical calculation

    Compute SOC from the battery dynamics and derive import/export from net grid power. Evaluate energy cost and rainflow cycle cost on the resulting trajectory. Dynamics and power balance are explicit computations.

  4. Backpropagate and update

    Combine gradients at identified cycle extrema with a proxy gradient based on adjacent SOC changes. Backpropagate through the dynamics and policy, together with SOC-bound and terminal penalties. Repeat over training batches.

The hybrid backward signal

$$\widetilde{\nabla}_{\mathrm{SOC}}=\lambda\nabla_{\mathrm{exact}}+(1-\lambda)\nabla_{\mathrm{proxy}}$$

The sparse term differentiates the cost associated with identified cycle extrema; the proxy distributes a signal across incremental SOC changes. The paper uses \(\lambda=0.5\). The mixture is a training estimator, not the exact derivative of the entire rainflow mapping.

The self-supervised loss

$$\mathcal L=\mathcal L_{\mathrm{econ}}+w_{\mathrm{deg}}(e)\mathcal L_{\mathrm{cyc}}+\lambda_{\mathrm{SOC}}\mathcal L_{\mathrm{SOC}}+\lambda_{\mathrm{term}}\mathcal L_{\mathrm{term}}$$

A curriculum decreases the degradation weight while the categorical temperature is annealed. SOC-bound and terminal penalties guide learning; they do not by themselves guarantee feasibility for every forecast.

Algorithm 1 and Sections III-C–F; hybrid gradient Equation (25), loss Equation (19). The tilde marks the hybrid estimator here; the paper writes it as a backward derivative.

Paper Figure 2: SOC signal, sparse extrema gradient, dense proxy gradient, their hybrid, and rainflow-cost optimization.
Figure 2 from the paper illustrates the sparse, proxy, and hybrid signals and their behavior in a trajectory-optimization example. It explains the training mechanism; fleet dispatch results are reported separately below.

Fast dispatch with a feasibility filter

An optional feasibility filter adjusts predicted power schedules to respect state-of-charge and power limits while keeping the selected operating modes.

Results across residential battery profiles

Optimize thousands of battery dispatch days in seconds, with feasible schedules and near-optimal performance.

3,650 daily battery schedules in 62 seconds—with 100% reported feasibility and total cost 3.33% above the optimization benchmark.

The paper evaluates simulated dispatch using metered rooftop-solar and demand profiles from 10 residential batteries over 365 days, under real-world electricity tariffs. The main reference is a piecewise-linear (PWL) degradation mixed-integer linear program solved with Gurobi; its schedules are evaluated using rainflow cost.

+3.33%

Total-cost gap versus PWLFleet-wide training, with projection, over 3,650 battery-days.

62.0 s

Total inference timeVersus 35,011 s for PWL; the paper reports a 564× speedup.

100%

Reported feasibilityAcross 3,650 daily schedules for the fleet-trained policy, with or without projection.

Table III. Fleet-wide training uses all 3,650 scenarios and reports performance on that fleet; this is not an established held-out fleet test. The PWL reference is a benchmark, so these are performance gaps, not certified gaps to the global optimum.

What broader training changes

Annual fleet totals — Table III, 3,650 battery-days
Method / trainingTotal cost ($)Gap vs. PWLFeasibility (%)Time (s)
PWL / Gurobi16,0000.00%100%35,011
Single battery, no projection17,810+11.31%87.48%52.7
Single battery + projection17,804+11.27%100%485
Fleet-wide, no projection16,533+3.33%100%21.9
Fleet-wide + projection16,533+3.33%100%62.0

A policy trained on a single household incurs a larger gap when evaluated across the full fleet. Exposing training to the broader set of profiles lowers the reported gap. Projection repairs the reported SOC violations from the single-customer policy while making only small changes to its total cost.

Battery and horizon
10 kWh; 4.8 kW power limit; 92% efficiency; SOC bounds 10–90%; 96 intervals per day.
Timing conditions
Intel Core Ultra 7 155H CPU, 16 GB RAM; batch size 1; Gurobi 13.0 on the same machine. Fleet times sum the per-instance solves.
Offline training
Approximately 8.5 hours on one NVIDIA Tesla T4 GPU (16 GB), separate from inference timing.
Statistical scope
Reported aggregate costs and timings for this dataset. The tables do not provide confidence intervals or repeated-run uncertainty.
Paper Figure 4: a summer-day SOC trajectory before and after projection, distribution of violations, and temporal pattern of violations.
Figure 4: projection behavior for the single-battery-trained policy evaluated across the fleet. Table III reports 87.48% feasibility before projection and 100% afterward, across 3,650 daily schedules. Original axes and legends are retained.

Why the rainflow training objective matters

On 10 held-out synthetic test days, changing the training objective while retaining the MI-DPC architecture changes the cost–wear trade-off. The exact-rainflow-trained policy has a smaller reported gap than its PWL-trained counterpart. The comparison below keeps projection enabled for both.

Selected rows from Table I — 10 synthetic test days
MethodEnergy cost ($)Degradation ($)Gap vs. PWLTime / day (s)Feasibility (%)
PWL / Gurobi28.550.580.00%9.42100%
MI-DPC-PWL + projection31.350.15+8.14%0.019100%
MI-DPC + projection29.010.62+1.74%0.041100%

Costs and per-instance timings as reported in Table I; same CPU and batch-size-1 setup as above. Table I also includes throughput, differential evolution, and reinforcement-learning baselines. Rounded source values are retained without recomputing the reported gaps.

Paper Figure 3: rainflow-cost convergence and final cost versus the hybrid mixing weight lambda over 50 trajectories.
Figure 3: mixing-weight sensitivity over 50 trajectories. Interior values perform similarly in this study, motivating the default \(\lambda=0.5\); the paper does not establish a universally optimal mixing weight.

Scope and interpretation

  • Model-based dispatch on real traces. These results use measured customer profiles in scheduling experiments. They do not establish a physical closed-loop battery deployment.
  • Exact forward cost, approximate training signal. “Exact rainflow” identifies the cycle-counting objective. The hybrid backward estimator and learned policy do not imply globally optimal dispatch.
  • Feasibility has a defined scope. Architectural constraints, soft training penalties, and the projection QP play different roles. The QP result applies to its stated constraints and initial-SOC assumption; it does not establish the original terminal equality.
  • Distribution and chemistry matter. The reported fleet results use common battery specifications and a Li-NMC cycle-stress law. New customer profiles or chemistries require separate assessment. Calendar aging and electrochemical aging dynamics are outside this model.
  • Day-ahead scheduling. Receding-horizon re-optimization and online adaptation are future directions in the paper. Independent per-battery schedules do not enforce coupled network constraints.

Resources and citation

Explore the released Jupyter notebook, train on its synthetic profiles, or examine its comparison and projection routines. The repository README explains the dependencies and the additional checkpoint required by the fleet-evaluation cells.

Paper version

The publication record is IEEE Transactions on Smart Grid, Early Access, 2026, DOI 10.1109/TSG.2026.3737375. The scientific descriptions, equations, figures, and results on this page follow arXiv:2609.12968v1. The IEEE full text was inaccessible during preparation, so differences from the version of record could not be checked.

BibTeX

IEEE Transactions on Smart Grid · Early Access
@article{ravajiri2026battery,
  author = {Ravajiri, Eshagh Safarzadeh and Drgona, Jan
            and Mehrtash, Mahdi and Hobbs, Benjamin F.},
  title = {End-to-End Battery Dispatch with Exact Rainflow
           Degradation via Mixed-Integer Differentiable
           Predictive Control},
  journal = {IEEE Transactions on Smart Grid},
  year = {2026},
  note = {Early Access},
  doi = {10.1109/TSG.2026.3737375},
  url = {https://ieeexplore.ieee.org/document/11707737/}
}