Skip to main content

Crate flexpool_plan

Crate flexpool_plan 

Source
Expand description

flexpool day-ahead planning: from a forecast to a schedule, water values and limit orders per battery pool, and their paper result.

Pure: a forecast, its error correlation, the storage and the market rules in; a plan out. The linear programme maximises (1 − β)·E(revenue) + β·CVaR 10 % over Gaussian-copula scenarios (Rockafellar–Uryasev), solved by Clarabel; the energy-balance duals are the water values the orders are priced from. f64 stays inside; order volumes and prices leave through flexpool_core::quantize().

Structs§

Fill
An order after the auction.
Market
What the market rules say about orders on the day.
Order
One day-ahead limit order.
Outcome
How a committed plan did against the published prices.
PoolPlan
A pool’s plan.
Revenue
Revenue across the scenarios, €.
Schedule
A solved schedule.
Step
One market time unit of a pool’s plan.
Storage
One pool’s batteries as one storage.

Enums§

PlanError
Why there is no plan.
Risk
How much weight the worst 10 % of scenarios get.
Side
Buy or sell.

Constants§

CVAR_ALPHA
The CVaR tail: the worst 10 % of scenarios.
SCENARIOS
Scenarios drawn per day.
SOC_MAX
Upper end of the window.
SOC_MIN
State of charge window as shares of usable energy.
SOC_START
Start (and minimum end) state of charge as a share of usable energy.

Functions§

draw
SCENARIOS price paths for forecast (one value per interval), latent AR(1) with rho per step, clamped to [lo, hi], deterministic for seed.
evaluate
Executes plan on paper against prices and compares it with perfect foresight.
execute
Paper execution of orders against published prices (one per unit starting at starts): a sell fills at a price at or above its limit, a buy at or below; the storage’s window holds. Returns the fills and the revenue, €.
inverse_normal
Φ⁻¹(p) by Acklam’s rational approximation (relative error < 1.2e-9), for p in (0, 1).
orders
One limit order per unit with a net flow, for the net volume, with protective limits: a sell at or above the lowest scenario price, a buy at or below the highest. Each order carries the expected price and the water value that explain it.
plan
A plan for storage over scenarios (one price per unit of hours, units starting at starts).
price_at
The price at normal score z for quantiles q: piecewise linear between the knots, linear beyond them with the outer slopes. At the knots it returns the quantiles exactly.
solve
Solves max (1 − β)·E(R) + β·CVaR₀.₁(R) over scenarios (each one price per interval of hours).