System Design Atlas

Generation forecasts and energy balances

05 / 10Worked example

Data and states

What changes to the forecast run must apply together, and what remains protected after completion?

The contracts require an authoritative datastore for forecast run P-33. Average power of 4 MW over 0.25 hours yields 1 MWh. With a forecast of 1.1 MWh, actual minus forecast is −0.1 MWh. Power in MW and energy in MWh use separate fields and are not added. State and command result are stored together, so the same change request remains recognisable after restart.

Starting point Approval binds the model and input version.

Assumptions for the example case

A fictional example design for a generation facility using fixed 15-minute intervals and separate forecast and measurement versions. Each interval spans 900 seconds, inclusive at the start and exclusive at the end; a measurement at exactly 900 seconds belongs to the next interval. All figures and test targets are illustrative assumptions.

Authoritative data and permitted state transitions

Entities and life cycle

Forecast run P-33Input hash, model version and forecast value
Interval I-33UTC start, duration and facility reference
Measurement revision M-33Actual values, completeness and provenance
Prognoselauf P-33 → Intervall I-33Creates value per interval
Prognoselauf P-33 → Messrevision M-33Compared against selected revision
1vorbereitet → berechnet
2berechnet → freigegeben
3freigegeben → verglichen → abgeschlossen
4verworfen | abgeschlossen (terminal)

Each comparison binds forecast version, measurement revision and the same interval.

An average power of 4 MW for 0.25 hours gives 1 MWh. For a forecast of 1.1 MWh, actual minus forecast is −0.1 MWh. Power in MW and energy in MWh receive different fields and are not added.

Domain entities and relationships

EntityAuthoritative attributesRelationship
Balance intervalI-33; UTC start and 900 seconds durationAll compared values refer to the same period of time.
Forecast runP-33; model and input versionThe forecast is preserved as the result produced at that time.
Measurement revisionM-33; source, revision, unit and valueNew measurement revision replaces the current view, not the history.
ComparisonForecast, measurement revision and difference in MWhMultiple comparison revisions can evaluate the same forecast run.

Balance interval

Authoritative attributes
I-33; UTC start and 900 seconds duration
Relationship
All compared values refer to the same period of time.

Forecast run

Authoritative attributes
P-33; model and input version
Relationship
The forecast is preserved as the result produced at that time.

Measurement revision

Authoritative attributes
M-33; source, revision, unit and value
Relationship
New measurement revision replaces the current view, not the history.

Comparison

Authoritative attributes
Forecast, measurement revision and difference in MWh
Relationship
Multiple comparison revisions can evaluate the same forecast run.

Permitted state transitions

Starting pointTargetPrecondition
vorbereitetberechnetInput version and model version are recorded.
berechnetfreigegebenForecasters confirm the run.
freigegebenverglichenComplete measurement revision of the same interval is present.
verglichenabgeschlossenThe energy balance team confirms the comparison version.
vorbereitet or berechnetverworfenIncomplete input or calculation errors.
abgeschlossen or verworfenterminalCorrections create new comparison revisions, not a rewrite of the run.

vorbereitet

Target
berechnet
Precondition
Input version and model version are recorded.

berechnet

Target
freigegeben
Precondition
Forecasters confirm the run.

freigegeben

Target
verglichen
Precondition
Complete measurement revision of the same interval is present.

verglichen

Target
abgeschlossen
Precondition
The energy balance team confirms the comparison version.

vorbereitet or berechnet

Target
verworfen
Precondition
Incomplete input or calculation errors.

abgeschlossen or verworfen

Target
terminal
Precondition
Corrections create new comparison revisions, not a rewrite of the run.

Atomic changes and versions

Content reference
An average power of 4 MW for 0.25 hours gives 1 MWh. For a forecast of 1.1 MWh, actual minus forecast is −0.1 MWh. Power in MW and energy in MWh receive different fields and are not added.
Shared commit
The forecast API checks interval, model version, input hash and forecast energy, then writes the business change, command result and any pending work in one transaction. Commit makes these changes durably visible together. Before commit, rollback ends the attempt without partial effects.
Concurrency
Measurement revisions 4 and 5 arrive in both orders. The current actual-value view remains at revision 5; the comparison using revision 4 remains available in history.
Terminal completion
A new correction to actual measurements does not alter a completed forecast run; it creates a new comparison revision with provenance.

Cover the full scope of the case

Concrete rule
Intervals are identified by UTC start and duration. A local daylight-saving display does not change the 900-second duration or energy conversion. Reject values for different facilities or intervals before calculating a difference.

Derive storage needs from access patterns

Authoritative relational datastore
All compared values refer to the same interval. The forecast is preserved as the result produced at that time. The design therefore selects a relational metadata store with uniqueness constraints and short transactions. Historical versions remain referenceable; a rebuildable read model must not overwrite authoritative state.
Large content and measurement series
Derived views and extensive measurement or event histories are read separately according to their access patterns. Binding state decisions remain in the authoritative datastore.

Corrections extend the comparison history

Corrections extend the comparison history

Corrections extend the comparison history.

Measurement revisions 4 and 5 arrive in both orders. The current actual-value view remains at revision 5; the comparison using revision 4 remains available in history.

A new correction to actual measurements does not alter a completed forecast run; it creates a new comparison revision with provenance. The exercise specifies the input and expected result.

Alternative considered
Separate unversioned changes allow an older state to overwrite the newer one.
Trade-off
Changes to forecast run P-33 are serialized briefly.
Reassess
Measured waiting times for 96 interval corrections from one day at the same facility justify reviewing transaction duration.

Try it yourself

Explain the two possible winner orders in the case contract. Also determine the behaviour after terminal completion.

A hint for your attempt

Content revision and aggregate version have different tasks.

Compare with a possible solution
Concurrency
Measurement revisions 4 and 5 arrive in both orders. The current actual-value view remains at revision 5; the comparison using revision 4 remains available in history.
Completion
A new correction to actual measurements does not alter a completed forecast run; it creates a new comparison revision with provenance.

Apply to your project

Which states must remain protected in your model against late replay?

Next, computation jobs use frozen manifests.