Methodology

The battery backtest's optimisation model, the sequential decision problem it approximates, and how the leftover-energy value is fitted. The tariff comparison's battery option reuses the rolling plan described here, without the value function.

1. Notation

Time is split into the price steps of the data, t=1,…,Tt = 1,\dots,T, each of length Δtt\Delta t_t hours (1 h or 0.25 h; DST days simply have 23 or 25 hours of steps). All times are Europe/Berlin.

SymbolMeaningUnit
πt\pi_tDay-ahead spot price€/MWh
ct, dtc_t,\ d_tCharge power drawn (from the grid or PV), discharge power delivered (grid side)kW
ete_tStored energy at the end of step ttkWh
E‾, E‾\underline E,\ \overline EMinimum and maximum stored energy (usable capacity E‾−E‾\overline E-\underline E)kWh
P‾ch, P‾dis\overline P^{\mathrm{ch}},\ \overline P^{\mathrm{dis}}Charge and discharge power limitskW
ηc, ηd\eta_c,\ \eta_dCharge and discharge efficiency, ηc=ηd=ρ\eta_c=\eta_d=\sqrt{\rho} with round-trip efficiency ρ\rho–
κ\kappaWear cost per kWh delivered: battery price ÷ (rated full cycles × capacity × ηd\eta_d)€/kWh
LtL_tHousehold load (household mode only)kW
Gt, ytG_t,\ y_tPV output and PV exported (household mode with solar)kW
ffFeed-in tariff paid for exported PV€/kWh
ab, as, ar, τa^{b},\ a^{s},\ a^{r},\ \tauBuy adder, sell deduction, retail fees, VAT rate€/MWh, –

2. Prices seen by the battery

Money is in €, so prices are converted to €/kWh. In wholesale mode the battery buys and sells at spot with adders:

ptb=πt+ab1000,pts=πt−as1000,d‾t=P‾dis. p^{b}_t = \frac{\pi_t + a^{b}}{1000}, \qquad p^{s}_t = \frac{\pi_t - a^{s}}{1000}, \qquad \overline d_t = \overline P^{\mathrm{dis}}.

In household mode the battery sits behind the meter. Every kWh charged is bought at the retail price, every kWh discharged replaces a kWh the household would otherwise buy at the same retail price, and nothing is exported:

ptb=pts=(πt+ar)(1+τ)1000,d‾t=min⁡ ⁣(P‾dis, Lt). p^{b}_t = p^{s}_t = \frac{(\pi_t + a^{r})(1+\tau)}{1000}, \qquad \overline d_t = \min\!\big(\overline P^{\mathrm{dis}},\, L_t\big).

Because ptb=ptsp^b_t=p^s_t, the fixed part ar(1+τ)a^r(1+\tau) of the price only acts on the energy lost in a round trip, (1−ρ)(1-\rho) per kWh cycled. That is why the grid fee barely moves the household savings.

Household with solar

With PV, a kWh no longer has one price per step. Grid imports cost ptbp^b_t, PV surplus is exported at ff, so the bill of a step depends on the net load nt=Lt+ct−dt−Gtn_t = L_t + c_t - d_t - G_t:

Bt=Δtt(ptb [nt]+  −  ft min⁡ ⁣(Gt, [−nt]+)),ft=min⁡(f, ptb). B_t = \Delta t_t\Big(p^b_t\,[n_t]^+ \;-\; f_t\,\min\!\big(G_t,\,[-n_t]^+\big)\Big), \qquad f_t = \min(f,\ p^b_t).

In a step with surplus, charging costs only the forgone feed-in ftf_t, not ptbp^b_t. Capping the feed-in at the retail price keeps BtB_t convex in ntn_t, so it fits an LP; the cap only binds at spot prices far below zero. The battery still discharges only into the household, dt≤Ltd_t \le L_t, so it never exports grid energy.

3. The planning problem for one window

Every plan is an optimisation over a window of steps W={t0,…,t1}W=\{t_0,\dots,t_1\}, starting from the energy e^\hat e actually stored at t0t_0. As a maximisation of net savings (the code passes the equivalent minimisation to HiGHS):

max⁡c, d, e, z∑t∈WΔtt(ptsdt−ptbct−κ dt)  +  zs.t.et=et−1+Δtt(ηcct−dtηd),t∈W,et0−1=e^,0≤ct≤P‾ch,0≤dt≤d‾t,E‾≤et≤E‾,et1≥e~,z≤Vk+mk (et1−gk),k=0,…,K−1. \begin{aligned} \max_{c,\,d,\,e,\,z}\quad & \sum_{t\in W} \Delta t_t\big(p^{s}_t d_t - p^{b}_t c_t - \kappa\, d_t\big) \;+\; z \\ \text{s.t.}\quad & e_t = e_{t-1} + \Delta t_t\Big(\eta_c c_t - \frac{d_t}{\eta_d}\Big), \qquad t\in W,\quad e_{t_0-1}=\hat e, \\ & 0 \le c_t \le \overline P^{\mathrm{ch}}, \qquad 0 \le d_t \le \overline d_t, \qquad \underline E \le e_t \le \overline E, \\ & e_{t_1} \ge \tilde e, \\ & z \le V_k + m_k\,(e_{t_1} - g_k), \qquad k = 0,\dots,K-1 . \end{aligned}

The charge efficiency acts on the grid-side energy going in, the discharge efficiency on the energy taken out of the cells, so a full round trip returns ηcηd=ρ\eta_c\eta_d=\rho of what was bought.

Solar

In household mode, every step with Gt>0G_t>0 gets an export variable and a row that keeps grid import non-negative:

max⁡ ⋯−Δtt (ptb−ft) yt,ct−dt+yt  ≥  Gt−Lt,0≤yt≤Gt. \max\ \dots - \Delta t_t\,(p^b_t - f_t)\,y_t, \qquad c_t - d_t + y_t \;\ge\; G_t - L_t, \qquad 0 \le y_t \le G_t .

Together with the battery terms this is −Bt-B_t up to a constant: at the optimum yty_t is the surplus left after the load and the battery, min⁡(Gt,[−nt]+)\min(G_t,[-n_t]^+). Steps without PV keep exactly the LP above.

Wholesale with solar

The battery shares the grid connection with a PV plant whose output sells at ptsp^s_t and is curtailed when that is below zero. A variable 0≤wt≤min⁡(Gt,ct)0 \le w_t \le \min(G_t, c_t) is the PV put into the battery, with cost Δtt ([pts]+−ptb) wt\Delta t_t\,([p^s_t]^+ - p^b_t)\,w_t: it avoids the grid purchase and forgoes the sale. Profit stays the battery's own, measured against the plant without battery.

Terminal condition

The plan must end with at least e~\tilde e stored. The requested minimum eterme^{\mathrm{term}} is clipped to what can be reached at all, so the LP is never infeasible:

rt0−1=e^,rt=min⁡ ⁣(E‾,  rt−1+ηcP‾chΔtt),e~=max⁡ ⁣(E‾,  min⁡(eterm, rt1−ε)). r_{t_0-1}=\hat e,\quad r_t = \min\!\big(\overline E,\; r_{t-1} + \eta_c \overline P^{\mathrm{ch}}\Delta t_t\big), \qquad \tilde e = \max\!\big(\underline E,\; \min(e^{\mathrm{term}},\, r_{t_1}-\varepsilon)\big).

Terminal value

The last group of constraints is the hypograph of a concave piecewise-linear function V^\hat V on the grid g0<⋯<gKg_0<\dots<g_K with values VkV_k and slopes mk=(Vk+1−Vk)/(gk+1−gk)m_k=(V_{k+1}-V_k)/(g_{k+1}-g_k). Since zz is maximised, at the optimum

z=min⁡k(Vk+mk(et1−gk))=V^(et1), z = \min_k\big(V_k + m_k(e_{t_1}-g_k)\big) = \hat V(e_{t_1}),

which is exact only because V^\hat V is concave (Section 6). Without a value function the zz terms are dropped, i.e. V^≡0\hat V\equiv 0.

MILP where needed

To rule out charging and discharging in the same step, the rolling and 24-hour plans add a binary utu_t per step:

ct≤P‾chut,dt≤d‾t (1−ut),ut∈{0,1}. c_t \le \overline P^{\mathrm{ch}} u_t, \qquad d_t \le \overline d_t\,(1-u_t), \qquad u_t\in\{0,1\}.

The big-M constants are the step's own bounds, so the relaxation is as tight as this formulation allows. Each window is first solved as an LP. Only if that LP charges and discharges in the same step is the window re-solved as the MILP, to a relative gap of 10−610^{-6} with a 60 s limit. An LP optimum without simultaneous flows is feasible for the MILP, and the LP is a relaxation of the MILP, so it is also the MILP optimum. The result is exactly the MILP's (unless the 60 s limit is hit, when the best solution found so far is used), and the slow solve only runs on the rare negative-price windows.

When the LP charges and discharges at once

Running both directions in the same step, with d=ρcd=\rho c so the stored energy is unchanged, pays

Δt c [ρ (pts−κ)−ptb]. \Delta t\, c\,\big[\rho\,(p^s_t-\kappa) - p^b_t\big].

This only matters when the battery has no room left to absorb more energy, and it is positive only for deeply negative prices. In wholesale mode:

πt<− ab+ρ (as+1000 κ)1−ρ, \pi_t < -\,\frac{a^{b} + \rho\,(a^{s} + 1000\,\kappa)}{1-\rho},

e.g. below −270 €/MWh at ρ=0.9\rho=0.9, κ=0.03\kappa=0.03 €/kWh and zero adders (checked numerically with HiGHS). The LP is then dumping energy as heat, which a real battery cannot do. The MILP rules it out. In household mode the retail price would have to fall below −ρκ/(1−ρ)-\rho\kappa/(1-\rho), which essentially never happens.

Why it can pay at all: at a negative price the grid pays for taking energy, and a battery that is already full can only take more by losing it. Per kWh charged at −790 €/MWh with ρ=0.9\rho=0.9 and κ=0.088\kappa=0.088 €/kWh:

EnergyMoney
Charge1 kWh from the grid+0.790 € (paid to take it)
Discharge in the same step0.9 kWh to the grid−0.711 € (delivering at a negative price costs)
Wear on the discharge−0.079 € (0.9 × 0.088)
Net0.1 kWh lost as heat, stored energy unchanged0.000 €

Only the lost 1−ρ1-\rho is really sold, while wear falls on all of the ρ\rho discharged. That is the factor 1/(1−ρ)=101/(1-\rho)=10 in the threshold: the price has to be about ten times the wear (in €/MWh) before the trick pays.

With the page's default battery (7 kWh, 3500 €, 6000 cycles, ρ=0.9\rho=0.9), κ=3500/(6000⋅7⋅0.949)≈0.088\kappa = 3500/(6000\cdot 7\cdot 0.949) \approx 0.088 €/kWh, so the wholesale threshold is about −790 €/MWh. That is below the day-ahead price floor of −500 €/MWh, so with these defaults the LP never does it and no window is re-solved as a MILP, in wholesale mode too. A MILP shows up only with low wear and full-battery steps at deeply negative prices: at −500 €/MWh and zero adders it needs κ\kappa below about 0.056 €/kWh, and with κ=0\kappa=0 any negative price on a full battery triggers it. The MILP still takes money from negative prices, but only as a real battery can: charge in one step, discharge in a later one.

4. The sequential decision problem (MDP)

The backtest is a sequential decision problem under price uncertainty. The battery is a price taker: its actions do not move prices, and only the stored energy carries over from one step to the next.

Information

Day-ahead prices for day D+1D+1 become known once the auction clears, at decision time θ\theta on day DD (13:00 by default). The natural stage is therefore the interval between two decision times, [θD,θD+1)[\theta_D,\theta_{D+1}). At θD\theta_D the information state is

ID={πt:t≤end of D+1}. I_D = \{\pi_t : t \le \text{end of } D+1\}.

Elements

stateSD=(eD,  ID),eD=stored energy at θD,actionxD=(ct,dt)t∈[θD,θD+1)∈X(eD)(bounds of Section 3),transitioneD+1=eD+∑t∈[θD,θD+1)Δtt(ηcct−dtηd),ID+1=ID∪{πt:t∈D+2},rewardR(xD)=∑t∈[θD,θD+1)Δtt(ptsdt−ptbct−κ dt). \begin{aligned} \text{state} \quad & S_D = (e_D,\; I_D), \qquad e_D = \text{stored energy at } \theta_D,\\ \text{action} \quad & x_D = (c_t,d_t)_{t\in[\theta_D,\theta_{D+1})} \in \mathcal X(e_D) \quad\text{(bounds of Section 3)},\\ \text{transition} \quad & e_{D+1} = e_D + \sum_{t\in[\theta_D,\theta_{D+1})} \Delta t_t\Big(\eta_c c_t - \frac{d_t}{\eta_d}\Big), \qquad I_{D+1} = I_D \cup \{\pi_t : t \in D+2\},\\ \text{reward} \quad & R(x_D) = \sum_{t\in[\theta_D,\theta_{D+1})} \Delta t_t\big(p^{s}_t d_t - p^{b}_t c_t - \kappa\, d_t\big). \end{aligned}

The energy transition is deterministic; only the price information is random, and it evolves independently of the actions.

Bellman equation

The optimal non-anticipative policy satisfies

VD(e,ID)=max⁡x∈X(e){R(x)+E[VD+1(eD+1,ID+1) ∣ ID]}. \mathcal V_D(e, I_D) = \max_{x\in\mathcal X(e)} \Big\{ R(x) + \mathbb E\big[\mathcal V_{D+1}(e_{D+1}, I_{D+1}) \,\big|\, I_D\big] \Big\}.

Solving it exactly needs a model of the joint price distribution and a value function over energy and the price state. The backtest does not do that. It compares policies that approximate this recursion in different ways (Section 5).

5. Policies compared

Perfect foresight (upper bound)

One LP over the whole period, W={1,…,T}W=\{1,\dots,T\}, starting at e0e_0 and ending at or above eterme^{\mathrm{term}} like the other policies, with no terminal value:

ΠPF=max⁡x∈X∑t=1TΔtt(ptsdt−ptbct−κdt). \Pi^{\mathrm{PF}} = \max_{x\in\mathcal X} \sum_{t=1}^{T} \Delta t_t\big(p^s_t d_t - p^b_t c_t - \kappa d_t\big).

It knows all prices in advance, so no non-anticipative policy can beat it. It is always solved as an LP, even when the MILP option is on. That keeps it a valid upper bound, since the LP relaxation is at least as good as the MILP.

24-hour plan at midnight

Each day at 00:00, one window covering that day only, ending at or above eterme^{\mathrm{term}}, with V^≡0\hat V\equiv0. This is a myopic policy: energy left at midnight is worth nothing to the plan.

Rolling plan

Day 1 is planned at 00:00 for day 1. From then on, at θD\theta_D the window runs to the end of day D+1D+1, i.e. all prices currently known. Only the part up to θD+1\theta_{D+1} is executed, and the next plan starts from the energy actually reached. In MDP terms it is a deterministic lookahead policy:

xDroll=[arg⁡max⁡x∈X(eD)∑t=θDend D+1Δtt(ptsdt−ptbct−κdt)+V^(eend D+1)][θD,θD+1). x_D^{\mathrm{roll}} = \Big[\arg\max_{x\in\mathcal X(e_D)} \sum_{t=\theta_D}^{\text{end } D+1} \Delta t_t\big(p^s_t d_t - p^b_t c_t - \kappa d_t\big) + \hat V(e_{\text{end }D+1})\Big]_{[\theta_D,\theta_{D+1})}.

The prices inside the window are known, so the only approximation is the continuation after the window: V^≡0\hat V\equiv0 for "rolling", and the fitted V^m\hat V_m of the month after the window for "rolling with value function". The window that reaches the end of the backtest gets no terminal value, because energy left then scores zero for every policy. Compared with the exact Bellman equation, the plan also treats the stretch [θD+1, end D+1][\theta_{D+1},\,\text{end } D+1] as fixed, although the next stage will re-plan it after seeing day D+2D+2. It therefore slightly undervalues flexibility, a certainty-equivalent step.

6. Fitting the value of stored energy

V^m(e)\hat V_m(e) estimates how much more the following days are worth when a plan ends with ee instead of E‾\underline E stored. It should be fitted on history strictly before the backtest. By default the value period is all loaded prices, and the page warns when it overlaps the backtest.

For every historical day ss and every grid point gk=E‾+kK(E‾−E‾)g_k = \underline E + \tfrac{k}{K}(\overline E-\underline E), k=0,…,Kk=0,\dots,K with K=10K=10, solve the LP of Section 3 over the H=2H=2 days starting at midnight of ss, from e^=gk\hat e=g_k, with eterm=E‾e^{\mathrm{term}}=\underline E and no terminal value:

Js(gk)=max⁡∑t∈s, s+1Δtt(ptsdt−ptbct−κdt)s.t. et0−1=gk. J_s(g_k) = \max \sum_{t\in s,\,s+1} \Delta t_t\big(p^s_t d_t - p^b_t c_t - \kappa d_t\big) \quad\text{s.t. } e_{t_0-1}=g_k.

Group the days by calendar month mm and average the differences:

Vˉm(gk)=1∣Sm∣∑s∈Sm(Js(gk)−Js(E‾)). \bar V_m(g_k) = \frac{1}{|\mathcal S_m|}\sum_{s\in\mathcal S_m}\big(J_s(g_k) - J_s(\underline E)\big).

Concavity and monotonicity

The optimal value of a linear maximisation is concave in its right-hand side, and e^\hat e enters only there. So every JsJ_s is concave in e^\hat e, and so is their average. This is why the fit always uses the LP, never the MILP. To remove solver noise, each slope, taken from the already rebuilt point to the next raw point, is clipped to be non-negative and no larger than the previous one, and the curve is rebuilt from V^m(g0)=0\hat V_m(g_0)=0:

mk=min⁡ ⁣(mk−1,  max⁡ ⁣(0,  Vˉm(gk+1)−V^m(gk)gk+1−gk)),V^m(gk+1)=V^m(gk)+mk (gk+1−gk), m_k = \min\!\Big(m_{k-1},\; \max\!\big(0,\; \tfrac{\bar V_m(g_{k+1})-\hat V_m(g_k)}{g_{k+1}-g_k}\big)\Big), \qquad \hat V_m(g_{k+1}) = \hat V_m(g_k) + m_k\,(g_{k+1}-g_k),

with m−1=∞m_{-1}=\infty. The result is concave, so the hypograph constraints of Section 3 represent it exactly, and the rolling plan stays an LP. Months with no history get V^m≡0\hat V_m\equiv0.

Bias

Each JsJ_s uses perfect foresight over its two days, so Vˉm\bar V_m estimates E[max⁡⋅]\mathbb E[\max\cdot] rather than the value a non-anticipative policy can achieve (E[max⁡]≥max⁡E\mathbb E[\max]\ge\max\mathbb E). The fitted value of stored energy therefore tends to be optimistic. It also ignores the price state: a month has one curve, whatever tomorrow's prices look like.

Calibration

To correct the optimism, the curve is shrunk by a single factor chosen on the same history. For each α∈A={0, 0.25, 0.5, 0.75, 1}\alpha\in\mathcal A=\{0,\,0.25,\,0.5,\,0.75,\,1\} the rolling plan with terminal value αV^m\alpha\hat V_m is run over the history period, and the factor that earns most is kept:

α⋆=arg⁡max⁡α∈A  Πhistroll(αV^),V^m←α⋆V^m. \alpha^\star = \arg\max_{\alpha\in\mathcal A}\; \Pi^{\mathrm{roll}}_{\mathrm{hist}}\big(\alpha\hat V\big), \qquad \hat V_m \leftarrow \alpha^\star\hat V_m .

Scaling by α≥0\alpha\ge0 keeps V^m\hat V_m concave and non-decreasing, so the plan stays an LP. α=0\alpha=0 is the plain rolling plan, so on the history the calibrated plan can never do worse than ignoring leftover energy. Months without a curve behave the same for every α\alpha and do not affect the choice. The factor is chosen on the history used for the fit, so it avoids the backtest period only when the fit does. The cost is ∣A∣|\mathcal A| extra rolling runs over the history.

Number of solves and problem size

A step is one price interval (15 min, or 1 h for older data), not one solve. One window is one LP, with ct,dt,etc_t, d_t, e_t per step, plus yty_t (household) or wtw_t (wholesale) on PV steps, utu_t on a MILP re-solve and zz with a terminal value. For a backtest of NN days and a value history of NhN_h days:

PartLPsSteps per LP (quarter-hours)
Perfect foresight1all TT (a year of quarter-hours: 35,040 steps, about 105k variables without PV)
24-hour plan at midnightNNone day (96)
Rolling plan, each variantN+1N+1up to about 44 h (176): rest of today and all of tomorrow
Value fitup to (K+1)(Nh−1)=11(Nh−1)(K+1)(N_h-1) = 11(N_h-1)two days (192); only history days in the backtest's calendar months
Calibration∣A∣(Nh+1)=5(Nh+1)|\mathcal A|(N_h+1) = 5(N_h+1)as the rolling plan

The rolling plan has one more solve than days because day 1 is first planned at 00:00 and then again at θ\theta. With a year of history the value of stored energy costs 11⋅364+5⋅366=583411\cdot364 + 5\cdot366 = 5834 LPs, far more than any strategy. A MILP re-solve adds to the LP count: the window was first solved as an LP. The backtest page lists these counts under "Solves".

7. Evaluation

The executed schedules (Ct,Dt,Et)(C_t,D_t,E_t) of each policy are scored on the realised prices:

Π=∑tΔtt ptsDt⏟revenue  −  ∑tΔtt ptbCt⏟cost  −  ∑tΔtt κDt⏟wear,share=ΠpolicyΠPF. \Pi = \underbrace{\sum_t \Delta t_t\, p^s_t D_t}_{\text{revenue}} \;-\; \underbrace{\sum_t \Delta t_t\, p^b_t C_t}_{\text{cost}} \;-\; \underbrace{\sum_t \Delta t_t\,\kappa D_t}_{\text{wear}}, \qquad \text{share} = \frac{\Pi^{\mathrm{policy}}}{\Pi^{\mathrm{PF}}}.

In household mode both bills are summed from BtB_t of Section 2: without battery on LtL_t with C=D=0C=D=0, with battery on the same load and the executed Ct,DtC_t, D_t. Π\Pi is their difference net of wear. Without PV this is B0−∑tΔtt(ptsDt−ptbCt)B_0 - \sum_t \Delta t_t (p^s_t D_t - p^b_t C_t) with B0=∑tΔtt ptbLtB_0=\sum_t \Delta t_t\, p^b_t L_t.

Solar shares: consumption from solar is ∑tΔttmin⁡(Gt,Lt)\sum_t\Delta t_t\min(G_t, L_t) without battery; with battery, PV first serves the load and then the battery, and discharge counts as solar by the share of all charging that came from PV surplus over the period (an approximation, not tracked per stored kWh). An empty usable capacity means no battery: no power and no wear, so the page shows the bill with solar alone.

Full cycles are counted on the cell side, where the cells deliver Dt/ηdD_t/\eta_d:

N=∑tΔttDt/ηdE‾−E‾. N = \frac{\sum_t \Delta t_t D_t/\eta_d}{\overline E - \underline E}.

8. Why a plan charges or discharges

The backtest page's chart "Why it charges or discharges" draws a hold band for each strategy: below it the plan charges, above it the plan discharges, inside it the plan holds. The band is read off the window LP of Section 3; nothing extra is fitted.

Value of stored energy

Let μt\mu_t be the dual (shadow price) of the energy balance at step tt: the increase in the window's optimal savings per extra kWh stored at the end of tt, in €/kWh. It contains everything the plan sees: the prices in the window, losses, wear, the power and capacity limits, the terminal condition and, for the rolling plan with value function, V^\hat V. HiGHS returns it with the solution (the code negates the dual of its minimisation).

Thresholds

At the optimum no step can be improved on its own. Charging 1 kWh more costs ptbp^b_t and stores ηc\eta_c kWh worth ηcμt\eta_c\mu_t; discharging 1 kWh more earns pts−κp^s_t-\kappa and uses 1/ηd1/\eta_d kWh worth μt/ηd\mu_t/\eta_d. So

ct>0  ⇒  ptb≤ηc μt,dt>0  ⇒  pts≥μtηd+κ. c_t > 0 \;\Rightarrow\; p^{b}_t \le \eta_c\,\mu_t, \qquad d_t > 0 \;\Rightarrow\; p^{s}_t \ge \frac{\mu_t}{\eta_d} + \kappa .

The gap between the two thresholds is the cost of losses and wear. Inverting the prices of Section 2 puts them on the spot axis (θb=1000 ηcμt\theta^b=1000\,\eta_c\mu_t, θs=1000(μt/ηd+κ)\theta^s=1000(\mu_t/\eta_d+\kappa) in €/MWh):

household: πtb=θb1+τ−ar,πts=θs1+τ−ar;wholesale: πtb=θb−ab,πts=θs+as. \text{household: } \pi^{b}_t = \frac{\theta^b}{1+\tau} - a^r,\quad \pi^{s}_t = \frac{\theta^s}{1+\tau} - a^r; \qquad \text{wholesale: } \pi^{b}_t = \theta^b - a^b,\quad \pi^{s}_t = \theta^s + a^s .

Example with the household defaults (ara^r = 13.67 ct/kWh, τ\tau = 19 %, ρ\rho = 0.9, κ≈\kappa \approx 8.8 ct/kWh from Section 3): a charge edge at 0 €/MWh spot means μt≈17.1\mu_t \approx 17.1 ct/kWh, and the discharge edge is then about 89 €/MWh. With κ\kappa = 3 ct/kWh it would be about 40 €/MWh: wear is most of the gap.

Empty or full battery

On a step where the battery sits empty (or full) and neither charges nor discharges at a rate strictly inside its limits, μt\mu_t is not unique: any value between the neighbouring ones gives the same plan, and HiGHS returns one end. Charging and discharging there are priced from two values instead:

  • Charge side μtc\mu^c_t: a kWh charged on an empty battery stays in it until the battery next trades, so μtc=μt′c\mu^c_t = \mu^c_{t'} at the first later step t′t' that is not empty and idle.
  • Discharge side μtd\mu^d_t: a kWh taken from a full battery is missed where it next trades, so μtd=μt′d\mu^d_t = \mu^d_{t'} at the first later step that is not full and idle.

Past the end of the window the carried value is the slope of the terminal value: mkm_k of the segment just above et1e_{t_1} for μc\mu^c, just below for μd\mu^d, and 0 without V^\hat V. If the window ends full because e~=E‾\tilde e=\overline E, there is no clean discharge value and μtd\mu^d_t stays the dual. Everywhere else μtc=μtd=μt\mu^c_t=\mu^d_t=\mu_t. The charge edge uses μtc\mu^c_t, the discharge edge μtd\mu^d_t. Example: a battery empty overnight before a sunny day no longer shows the evening's discharge value as its charge edge, but the lower value a stored kWh has once the sun is up.

Solar surplus

While charging stays within the PV surplus (household: Gt−LtG_t - L_t; wholesale: all of GtG_t, since the plant sells everything), a charged kWh gives up the PV export instead of a purchase:

  • Wholesale: the PV would have sold at [pts]+[p^s_t]^+, so the charge edge moves up by the sell deduction, πtb=θb+as\pi^b_t = \theta^b + a^s (for μtc≥0\mu^c_t \ge 0). The discharge edge is unchanged.
  • Household, charging: the cost is the feed-in ftf_t, which does not depend on spot, so the step has no band. With the battery soaking up PV, ηcμtc=f\eta_c\mu^c_t = f.
  • Household, holding: if ηcμtc=f\eta_c\mu^c_t = f (a tie: storing pays the same as exporting, so any surplus step will do) there is no band. Otherwise the charge edge is the usual one (the battery charges once the retail price falls below ηcμtc\eta_c\mu^c_t). Discharging into a surplus only pushes out PV at ftf_t, so the discharge edge is the usual one if f≥θsf \ge \theta^s, and absent otherwise: no spot price makes it discharge.

Charging beyond the surplus imports at spot, and the plain band applies again.

Which LP

Each step takes μt\mu_t from the LP whose decision was executed there: the single LP for perfect foresight, that day's LP for the 24-hour plan, and the covering 13:00 solve (00:00 on day 1) for the rolling plans. μtc\mu^c_t and μtd\mu^d_t are carried back over that LP's whole window, including the part a rolling plan does not execute.

Limits

  • Indifference. While the battery soaks up PV at the feed-in, every surplus step costs the same, so which of them it charges in is arbitrary. Gaps between the charge bars there carry no meaning. The same happens off the grid: when μt\mu_t is set by buying at the day's lowest price (often a flat stretch at 0 €/MWh), the charge edge sits on that price, and steps a few hundredths of a €/MWh apart land on opposite sides of it. The plan then charges at full power in some of them and not in others, for almost no difference in savings. The tooltip flags steps within 1 €/MWh of an edge.
  • MILP windows have no duals, so those steps have no band.
  • How much, not whether. The band says whether the plan charges or discharges, not how much. Above the band the plan discharges as much as it can in that step: up to the battery's power, but in household mode never more than the household uses (dt≤Ltd_t \le L_t), and not when the battery is empty. Likewise below the band it charges up to the charge power, unless the battery is full.

9. Review notes and limitations

  • Checked and consistent: units (€/MWh → €/kWh, kW·h → kWh), the energy balance with ηc\eta_c on the way in and 1/ηd1/\eta_d on the way out, the hypograph form of the terminal value, the MILP big-M bounds, the 13:00 information set, and the absence of look-ahead in the value fit when the periods do not overlap.
  • Same end condition for every policy. All policies start at e0e_0, must end at or above eterme^{\mathrm{term}}, and get nothing for energy left at the end. The rolling plan with value function drops V^\hat V on its final window, so it does not hold back energy that would score zero.
  • LP energy dumping. Below the threshold of Section 3 the LP would charge and discharge at once. This affects only deeply negative wholesale prices. The rolling and 24-hour plans always use the LP-then-MILP fallback, which removes it at almost no cost. Perfect foresight and the value fit are always LPs, so they may still dump energy. That keeps perfect foresight an upper bound, but a slightly looser one.
  • Cycles are counted on the cell side (Dt/ηdD_t/\eta_d), while wear is charged per kWh delivered to the grid or household, as its label says.
  • Value function: the raw fit is optimistic (perfect foresight over two days). The calibration factor removes the average bias, but not its dependence on energy level or season. There is one curve per month, independent of the price state; alternatives are in docs/method.md. The concavity projection is a greedy slope clip, not a least-squares fit, which only matters when the averages are noisy.
  • Solar profile. PVGIS (EU JRC) gives the long-run yield for the address: monthly totals and the average day of each month, south-facing at the optimal tilt, 14 % losses. Open-Meteo's hourly irradiance on the panel for each past day sets which days and hours are sunny, scaled by one factor so those hours yield what the PVGIS average days give for them; days without weather (e.g. tomorrow) use the average day. So the shape follows real weather on the price days, but a sunnier-than-average year is scaled back to the long-run yield. Weather is reanalysis on a grid of a few tens of km, hourly (15-minute steps take their hour's mean); temperature effects are folded into the scale factor.
  • Feed-in is a fixed tariff, also paid at negative prices (newer German systems get nothing then), and PV is never curtailed.
  • Data gaps longer than one hour are closed: the step before the gap keeps the normal step length, and the battery state carries straight across the gap. Shorter gaps in 15-minute data are not detected: the step before simply lasts until the next price.