Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #115 +/- ##
==========================================
+ Coverage 84.57% 85.01% +0.43%
==========================================
Files 45 46 +1
Lines 2658 2929 +271
==========================================
+ Hits 2248 2490 +242
- Misses 410 439 +29 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Threaded assembly and non-hourly event-energy conversion lack direct coverage, and the event docstring misstates the raw energy field.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds event-level shortfall recording, associated adequacy metrics, and JSON export support.
Changes:
- Introduces
ShortfallEventsResultand event recording. - Adds LOLEv and duration/energy metrics.
- Adds JSON exports, tests, examples, and documentation.
File summaries
| File | Description |
|---|---|
PRASFiles.jl/test/runtests.jl |
Tests shortfall and event exports. |
PRASFiles.jl/src/Results/write.jl |
Implements event-result JSON export. |
PRASFiles.jl/src/Results/utils.jl |
Defines exported event structures and conversions. |
PRASFiles.jl/src/PRASFiles.jl |
Imports event APIs and exports saveevents. |
PRASCore.jl/test/Simulations/runtests.jl |
Tests event recording and metrics. |
PRASCore.jl/test/Results/shortfall.jl |
Tests event interval selection. |
PRASCore.jl/src/Simulations/utils.jl |
Enables regional event shortfall lookup. |
PRASCore.jl/src/Simulations/recording.jl |
Records system and regional events. |
PRASCore.jl/src/Results/ShortfallEvents.jl |
Implements event results, accessors, and metrics. |
PRASCore.jl/src/Results/Results.jl |
Registers and exports event functionality. |
PRASCore.jl/src/Results/metrics.jl |
Defines event metric types. |
PRAS.jl/examples/pras_adequacy_metrics.jl |
Demonstrates LOLEv and event metrics. |
docs/src/resourceadequacy.md |
Documents LOLEv. |
docs/src/PRASFiles/index.md |
Documents event JSON exports. |
docs/src/PRASCore/api.md |
Adds event APIs to the reference. |
docs/src/PRAS/results.md |
Documents event semantics and usage. |
docs/src/images/shortfall-events.svg |
Illustrates event aggregation. |
docs/make.jl |
Adds PRASFiles documentation navigation. |
Review details
- Files reviewed: 17/18 changed files
- Comments generated: 3
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| """ | ||
| struct ShortfallEvents <: ResultSpec end | ||
|
|
||
| usesamplepartitions(::ShortfallEvents) = true |
Comment on lines
+277
to
+280
| function MeanEventEnergy(x::ShortfallEventsResult{N,L,T,P,E}) where {N,L,T,P,E} | ||
| p2e = conversionfactor(L, T, P, E) | ||
| energies = [ | ||
| p2e * event_energy(ev) |
| with positive shortfall. A `ShortfallEventsResult` can be indexed by sample | ||
| number to retrieve system-wide events or by region name and sample number to | ||
| retrieve regional events. Each event records its starting timestep, ending | ||
| timestep and unserved energy. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a new
ShortfallEventsresult specification that records shortfall events directly during simulation.We define an "adequacy event" as a set of event-periods that are contiguous at the highest available temporal resolution [1].
Events are recorded separately for each Monte Carlo sample at both system and regional levels.
ShortfallResultdoes not retain sufficient information to reconstruct individual events. At the same time, obtaining this information fromShortfallSamplesResultrequires storing and postprocessing the fullregions × timestamps × samplesshortfall tensor.ShortfallEventsinstead stores event boundaries and accumulated unserved energy, avoiding that dense tensor, which provides a more compact representation for event analysis, particularly when shortfalls are sparse.The implementation adds the following metrics at both system and regional levels:
With the implementation of
LOLEv, all metrics defined in [2] are now included in PRAS.Additionally, this PR extends
PRASFilesto support JSON export ofShortfallEventsResult. This includes both aggregate event-level metrics and optionally raw event records at the system and regional levels.Benchmarks
1) RTS-GMLC with 10× regional load: 3 regions, 8,784 hourly timesteps (2,000 MC samples, 6 threads)
The run recorded 2,000 system events and 6,000 regional events across all samples.
assesstime (s)ShortfallSamples()ShortfallEvents()2) 13-region system: 8,761 hourly timesteps (2,000 MC samples, 6 threads)
The run recorded 362 system events and 1,839 regional events across all samples.
assesstime (s)ShortfallSamples()ShortfallEvents()Note on Result size:
ShortfallSamplesstores every region-timestep-sample value, whereasShortfallEventsstores event records plus per-sample bookkeeping. Both results also reference regional metadata.Event storage is particularly compact when shortfalls are infrequent or persist across consecutive timesteps, while many separate short events can reduce or eliminate the size advantage.
[1] Stephen et al. (2022), "Clarifying the Interpretation and Use of the LOLE Resource Adequacy Metric"
[2] NERC (2018), "Probabilistic Adequacy and Measures Technical Reference Report"