Markov Price Model for Seasonal Planning

This document explains the stochastic electricity price model used in SDDP seasonal planning. Reference: Kompendium 1, §6.5.


Why model price stochastically?

In the basic water value SDP (Phase 1) we used a flat price. That is fine for computing long-run average water values, but it misses an important effect:

The value of stored water depends on whether we expect prices to be high or low in the future.

If the price next week is expected to be high (cold winter, low wind), water is worth more. If the price is expected to be low (wet year, high wind), water is worth less. Ignoring this correlation understates the benefit of storing water for high-price periods.

Adding price as a Markov state variable allows the SDDP model to answer: "Should I release water this week, or hold it for the high-price week coming up?"


The discretisation approach

A continuous price process is hard to work with in dynamic programming — we would need to integrate over infinitely many possible future prices.

Instead we discretise: divide the price axis into P states:

State 1: very low    (bottom 20% of historical distribution)
State 2: low         (20–40th percentile)
State 3: medium      (40–60th percentile)
State 4: high        (60–80th percentile)
State 5: very high   (top 20%)

This is the same idea as discretising the reservoir volume in Phase 1 — trade exactness for tractability.


The three fitting steps

Step 1 — Compute state boundaries (quantiles)

Given a vector of historical weekly average prices, compute P−1 thresholds at equal quantile spacings:

boundaries = quantile(prices, [0.20, 0.40, 0.60, 0.80])   # for P=5

Why equal-probability bins? Each state is equally likely marginally, so the SDDP backward pass accumulates cuts at the same rate for every state. Equal-width bins would leave extreme states (very low, very high) under-sampled.

In code:

boundaries = compute_state_boundaries(historical_prices, 5)

Step 2 — Assign each observation to a state

Map each historical price to a state using binary search:

state = 1    if  price ≤ boundaries[1]
state = 2    if  boundaries[1] < price ≤ boundaries[2]
...
state = P    if  price > boundaries[P-1]

In code (uses searchsortedfirst — O(log P) per observation):

states = assign_states(historical_prices, boundaries)

Step 3 — Count transitions

Scan the labelled sequence and count how often state i is followed by state j. Normalise each row to get probabilities:

T[i, j] = count(state[t+1] == j AND state[t] == i)
           ────────────────────────────────────────
                    count(state[t] == i)

In code:

T = build_transition_matrix(states, 5)

Compose all three steps

model = fit_markov_price(historical_prices, 5)

What the transition matrix captures

For Norwegian electricity prices, a fitted P=5 matrix typically looks like:

                  → very low   low    medium   high   very high
from very low  [  0.55       0.30    0.10     0.04    0.01  ]
from low       [  0.20       0.45    0.25     0.08    0.02  ]
from medium    [  0.08       0.22    0.40     0.22    0.08  ]
from high      [  0.02       0.08    0.25     0.45    0.20  ]
from very high [  0.01       0.04    0.10     0.30    0.55  ]

Key observations:

  • Diagonal dominance: it is most likely to stay in the current state. This is the auto-correlation (persistence) of prices.
  • Symmetry around the middle: the chain is mean-reverting. From very low, the probability of going higher is larger than going lower.
  • Stationary distribution: with equal quantile bins, the long-run probability of each state is ≈ 20 %.

Using the model in SDDP

In the SDDP algorithm (Phase 6), the price state p enters in two places:

  1. The LP objective: revenue at stage t = expected_price(model, p_t) × production_t
  2. The cut pool index: separate Benders cuts are maintained for each price state. CutLibrary[t, p] holds the cuts valid when the price state at stage t is p.

The forward pass samples price transitions:

p_next = sample_next(model, p_current, rng)

The backward pass iterates over all price states at each stage to generate cuts for every (t, p) combination.


Synthetic model for testing

When real price data is not yet available, use:

model = synthetic_price_model(n_states=5, mean_price=400.0,
                               half_range=200.0, persistence=0.6)

This builds an analytically mean-reverting Markov chain with representative prices evenly spaced from mean_price − half_range to mean_price + half_range.


Resolution note

The Markov chain is fitted at whatever resolution the planning model uses:

  • Weekly resolution: each transition is week-to-week
  • Daily resolution: each transition is day-to-day (captures weekday/weekend patterns)
  • Hourly: not recommended for the price Markov model — use hourly prices as a deterministic intra-day pattern within each daily state instead

The MarkovPriceModel struct is the same regardless of resolution. Only the transition matrix differs. This is the PlanningResolution-agnostic design intended in Phase 0.5.