Thanks @bartm for highlighting the issue of large batteries draining over time. Turns out my assumption was wrong. A longer forecasting window will cause the battery to drain, only at a slower rate. This is unwanted behavior:
I overhauled the battery state of energy logic to be able to modify the objective function. The solver is now reimbursed for the energy that it has at the end. But I have found this behavior to be very difficult to steer using a min function or quantile(buy_price, 20%).
For this case a quantile(buy_price, 30%) + cycle_cost works:
But I imagine the current implementation of a quantile is very depended, on the number of cheap and expensive hours. What does seem to work is median(buy_price) * inverter_efficiency + cycle_cost, It captures the true replenishment cost, but I do not know how well it works in edge cases. For now I leave it, but maybe in the future a min SoE is needed to have the battery stay in a certain region for large systems.


