Battery Storage Optimization
LP · Arbitrage · Peak-shaving
Short-term · State-of-charge dynamics · Round-trip efficiency
When should a grid-scale battery charge, and when should it discharge? The answer is simple in the abstract — charge when electricity is cheap, discharge when it is expensive — and precise in practice: the operator solves a linear program over 24 hours subject to energy capacity, power rating, and round-trip efficiency. This is the central OR problem behind every battery dispatch system in the world, from the PJM Interconnection's frequency-regulation fleet to Australian household Tesla Powerwalls. Sioshansi, Denholm, Jenkin & Weiss (2009) showed that LP-based schedules capture 85–95% of theoretical arbitrage value even with imperfect price forecasts.
The problem
Temporal arbitrage under capacity and efficiency constraints
A 20-MW / 80-MWh lithium-ion battery (a typical utility-scale system as of 2024) looks like a pipe in two dimensions: it has a power rating ($P^{\max}$, how much charge or discharge per hour) and an energy capacity ($E^{\max}$, how much stored energy total). The ratio $E^{\max} / P^{\max}$ is the duration: 4 hours for the example above. A 30-minute duration battery is a power battery (frequency regulation); a 8-hour battery is an energy battery (peak shaving, diurnal arbitrage).
The state-of-charge (SOC) dynamics impose temporal coupling that is the core mathematical feature. Hourly charging $c_t$ adds $\eta^c c_t$ to stored energy (where $\eta^c$ is charging efficiency, typically 0.95); discharging $d_t$ removes $d_t / \eta^d$ from stored energy (discharge efficiency also $\sim 0.95$). Combined round-trip efficiency is about 0.85–0.92 for lithium-ion, 0.70–0.80 for flow batteries, and 0.75–0.85 for pumped hydro. This efficiency gap is the fundamental economic constraint: arbitrage is profitable only when the buy/sell price spread exceeds the efficiency loss plus marginal degradation cost.
Revenue streams are diverse. Energy arbitrage (charge off-peak, discharge on-peak) is the simplest; typical daily spread in California CAISO is $20–40/MWh. Ancillary services — frequency regulation, spinning reserve, reactive power — can pay two to five times more per MWh of capacity offered but require the battery to stay available for fast response. Behind-the-meter applications (peak-shaving of demand charges, solar self-consumption, time-of-use rate optimization) yield additional stacked revenues. Full value stacking optimization runs a co-optimized LP across all revenue streams.
Beyond pure arbitrage, batteries increasingly sit alongside solar and wind to firm variable renewable output. Combined with renewable-integration stochastic dispatch, storage becomes one of the main degrees of freedom for handling forecast uncertainty — see renewable integration.
Mathematical formulation
Linear program with SOC dynamics
Notation
| Symbol | Meaning | Units |
|---|---|---|
| $T$ | Number of time periods (e.g., 24 hours) | — |
| $\pi_t$ | Electricity price in period $t$ | $/MWh |
| $L_t$ | Load in period $t$ (for peak-shaving) | MW |
| $E^{\min}, E^{\max}$ | SOC bounds | MWh |
| $P^{\max}$ | Power rating | MW |
| $\eta^c, \eta^d$ | Charging and discharging efficiencies | pu |
| $e_t$ | State of charge at end of period $t$ | MWh |
| $c_t$ | Charging power | MW |
| $d_t$ | Discharging power | MW |
Objective · arbitrage revenue
Maximize net revenue over the horizon (discharge minus charge, at market price):
The dual formulation minimizes net procurement cost. Peak-shaving variants replace the objective with a demand-charge minimization (highest observed net load over the billing month).
Constraints
SOC evolution: the heart of the problem, linking $e_t$ to $e_{t-1}$:
Energy capacity:
Power rating:
Initial / terminal conditions: fix $e_0$ and optionally $e_T = e_0$ for cyclic operation:
The simultaneous charge-discharge exclusion — preventing $c_t > 0$ and $d_t > 0$ in the same period — is technically redundant when efficiencies are strictly less than 1: any simultaneous pair incurs loss for zero gain, so the LP optimum naturally sets the smaller to zero. If $\eta^c \eta^d = 1$ exactly, a binary variable is needed. Most literature ignores this and solves the pure LP.
Value stackingarbitrage + ancillary services
Modern commercial operation co-optimizes multiple revenue streams: arbitrage $r_t^{\mathrm{arb}}$, regulation $r_t^{\mathrm{reg}}$, spinning reserve $r_t^{\mathrm{res}}$. The constraint total power allocated across services does not exceed capacity becomes:
and a related SOC-availability constraint for each reserve product. The full LP has ~5–10 variables per period and remains fast to solve.
Degradation as cost
Cycling degrades lithium-ion battery capacity; an extra $/MWh term $c_{\mathrm{deg}}$ can be added to objective (1) to penalize throughput: $-c_{\mathrm{deg}} (c_t + d_t)$. Mobile asset management considers the marginal cycle life lost. Typical $c_{\mathrm{deg}}$ is $10–$30/MWh throughput for 2024 lithium-ion systems.
Complexity & practical solve times
Deterministic battery LP is polynomial-time. A 24-hour horizon has 72 variables (charge + discharge + SOC per hour) and ~100 constraints. Commercial LP solvers (Gurobi, CPLEX, HiGHS) solve in $<$10 ms. Rolling-horizon deployment re-solves every few minutes with updated price forecasts.
Stochastic extensions (uncertain prices, uncertain ancillary activation) become scenario-based LPs with thousands of variables and still solve in seconds. Multi-year degradation-aware optimization becomes a large LP or convex QP over 365 × 24 = 8760 periods but remains tractable.
Real-world data
CAISO day-ahead / real-time prices
CAISO OASIS publishes 5-minute real-time and hourly day-ahead LMPs that drive most California battery arbitrage studies. The "duck curve" and frequent negative-price hours make California one of the most battery-friendly markets.
NREL Annual Technology Baseline · Battery
NREL ATB provides projected lithium-ion battery capital cost, O&M, lifetime, and efficiency trajectories through 2050. Standard source for investment analysis.
PJM ancillary services prices
PJM ancillary services publishes hourly regulation and reserve market prices. Frequency regulation pays highest for fast-responding assets; batteries dominate this product category in PJM.
Illustrative 24-hour case (this page)
The interactive solver below uses a synthetic but realistic day-ahead price profile (low overnight, peak evening) with user-configurable battery parameters (capacity, power, efficiency). Prices scale roughly like US-northeast summer days: $20–$150/MWh range.
Interactive solver
24-hour LP arbitrage · SOC trajectory
Battery parameters
Price signal & battery operation
Solution interpretation
The SOC trajectory reveals the optimal policy: the battery typically fills (charges) during overnight hours when prices are low, discharges during evening peaks when prices are high, and reaches its minimum storage during the highest-price window. A full cycle uses the entire energy capacity exactly once per day if the morning-to-evening price spread justifies it; two partial cycles appear when there are two distinct price peaks (morning + evening).
The efficiency gap is the key economic margin. A 20% round-trip loss means the operator needs at least a 20% price spread to break even. In CAISO peak summer days, the spread routinely exceeds 300%; even 70%-efficient legacy batteries make money. In flat markets (typical winter Sundays), a 90%-efficient battery may still lose money to degradation cost and will sit idle.
Degradation cost is the most-commonly-ignored but commercially critical parameter. At $30/MWh degradation cost, many marginal cycles become unprofitable; realistic dispatch shows fewer cycles and longer idle periods than the naive "any price spread > efficiency loss" rule would suggest. Real battery operators tune this parameter carefully against warranty terms and capacity-fade curves.
Extending to value stacking (ancillary services + arbitrage) often more than doubles revenue: the same capacity is partially reserved for frequency regulation, yielding $60–$100/MW-hour revenue during idle arbitrage periods. Real-world commercial batteries in PJM earn 60%+ of revenue from ancillary services, not arbitrage.
Extensions & variants
Value-stacking LP
Co-optimizes arbitrage, regulation, spinning reserve, and capacity payments. Adds variables for reserve bids and constraints tying energy to reserve availability. Commercial operators earn 50–70% of revenue from ancillary services.
Stochastic price LP
When day-ahead prices are uncertain, the scheduling becomes a two-stage stochastic LP with scenarios on the price vector. First-stage (morning) decisions must be made before realized prices; second-stage recourse adjusts within the day. Capture most of the deterministic-optimum value with practical computational cost.
Peak-shaving and demand charges
Commercial and industrial customers often pay a demand charge ($/kW) on their highest 15-min monthly net load. Battery dispatch minimizes the peak, not energy cost. Objective becomes $\min \max_t (L_t - d_t + c_t)$, which linearizes with a single auxiliary variable.
Solar self-consumption
Behind-the-meter battery optimizes solar self-consumption: charge from excess PV, discharge during morning/evening load peaks. Objective accounts for net-metering tariff structure and often time-of-use energy prices.
Battery investment & sizing
Upstream question: how much $E^{\max}$ and $P^{\max}$ should be built? Becomes an MILP where sizing variables are upper-level and operational LP is lower-level. Couples to GEP.
Degradation-aware optimization
Explicit cycle-counting and state-of-health tracking over multi-year horizons. Nonlinear (capacity fades with time and cycle depth) but tractable via piecewise linearization or SOC-averaging approximations. Critical for warranty-bounded commercial dispatch.