Skip to content

Statistical reduction components - #859

Open
cfrontin wants to merge 15 commits into
NatLabRockies:developfrom
cfrontin:feature/statistical
Open

cfrontin wants to merge 15 commits into
NatLabRockies:developfrom
cfrontin:feature/statistical

Conversation

@cfrontin

Copy link
Copy Markdown
Collaborator

Statistical reduction components

For the purposes of optimization, it is frequently the case that objectives and constraints are set by probabilistic summary or threshold statistics: e.g. 99.9% of the time, some output should be greater than a threshold or demand variable.

These components take 8760 (or other simulation length) inputs and produce either summary statistics (mean, median, percentiles, etc.) or threshold statistics (net commodity deficit/surplus, fractions of timestep in deficit/surplus) as outputs, which can be used as objectives or constraints.

Section 1: Type of Contribution

  • Feature Enhancement
    • Framework
    • New Model
    • Updated Model
    • Tools/Utilities
    • Other (please describe):
  • Bug Fix
  • Documentation Update
  • CI Changes
  • Other (please describe):

Section 2: Draft PR Checklist

  • Open draft PR
  • Describe the feature that will be added
  • Fill out TODO list steps
  • Describe requested feedback from reviewers on draft PR
  • Complete Section 8: New Model Checklist (if applicable)

TODO:

  • Step 1
  • Step 2

Type of Reviewer Feedback Requested (on Draft PR)

Structural feedback:

I think these should exist as components that are perhaps distinguished in some sense from traditional commodity streams since they are effectively fictitious consumers and may break some checking and flows.

Implementation feedback:

Other feedback:

Section 3: General PR Checklist

  • PR description thoroughly describes the new feature, bug fix, etc.
  • Added tests for new functionality or bug fixes
  • Tests pass (If not, and this is expected, please elaborate in the Section 6: Test Results)
  • Documentation
    • Docstrings are up-to-date
    • Related docs/ files are up-to-date, or added when necessary
    • Documentation has been rebuilt successfully
    • Examples have been updated (if applicable)
  • CHANGELOG.md
    • At least one complete sentence has been provided to describe the changes made in this PR
    • After the above, a hyperlink has been provided to the PR using the following format:
      "A complete thought. [PR XYZ]((https://github.com/NatLabRockies/H2Integrate/pull/XYZ)", where
      XYZ should be replaced with the actual number.

Section 4: Related Issues

Section 5: Impacted Areas of the Software

Section 5.1: New Files

  • path/to/file.extension
    • method1: What and why something was changed in one sentence or less.

Section 5.2: Modified Files

  • path/to/file.extension
    • method1: What and why something was changed in one sentence or less.

Section 6: Additional Supporting Information

Section 7: Test Results, if applicable

Section 8 (Optional): New Model Checklist

  • Model Structure:
    • Follows established naming conventions outlined in docs/developer_guide/coding_guidelines.md
    • Used attrs class to define the Config to load in attributes for the model
      • If applicable: inherit from BaseConfig or CostModelBaseConfig
    • Added: initialize() method, setup() method, compute() method
      • If applicable: inherit from CostModelBaseClass
  • Integration: Model has been properly integrated into H2Integrate
    • Add the new model to the appropriate __init__.py file to ensure it is properly imported and used in supported_models.py
    • Added to supported_models.py
    • If a new commodity_type is added, update create_financial_model in h2integrate_model.py
  • Tests: Unit tests have been added for the new model
    • Pytest-style unit tests
    • Unit tests are in a "test" folder within the folder a new model was added to
    • If applicable add integration tests
  • Example: If applicable, a working example demonstrating the new model has been created
    • Input file comments
    • Run file comments
    • Example has been tested and runs successfully in test_all_examples.py
  • Documentation:
    • Write docstrings using the Google style
    • Model added to the main models list in docs/user_guide/model_overview.md
      • Model documentation page added to the appropriate docs/ section
      • <model_name>.md is added to the _toc.yml
    • Run generate_class_hierarchy.py to update the class hierarchy diagram in docs/developer_guide/class_structure.md

@elenya-grant
elenya-grant self-requested a review September 1, 2026 17:50
@cfrontin
cfrontin marked this pull request as ready for review September 8, 2026 19:13
@cfrontin

cfrontin commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

I think this should be good to go- one last piece for the devs is where should I add documentation so that ppl can find these capabilities?

@johnjasa

Copy link
Copy Markdown
Collaborator

I think this should be good to go- one last piece for the devs is where should I add documentation so that ppl can find these capabilities?

It's a fun question because this is a fully new capability and it's not tied to any one technology.
I think a new page at the end of the User Guide section is the best bet for now; I'm open to other thoughts too.

@cfrontin
cfrontin marked this pull request as draft September 22, 2026 19:15
@cfrontin
cfrontin marked this pull request as ready for review September 22, 2026 19:15
… statistical components that have conflicting/irrelevant defaults
@cfrontin

Copy link
Copy Markdown
Collaborator Author

currently this PR is held up by #872. the new input-input connection required by the threshold statistics component requires a hotfix in the run scripts, like so:

# build the H2I model
h2i = h2integrate.H2IntegrateModel(case_to_run)

# HOTFIX: this is a change necessitated by issues documented in #872 re: input-input connections
# this *should* be actuated by the technology_interconnections (see commented line in plant_config.yaml)
# but right now it is effectuated by a very manual OpenMDAO connection as a hotfix
h2i.model.connect("electrical_load_demand.electricity_demand", "interconnect_counts.electricity_threshold")

# setup and run the H2I model
h2i.setup()

@johnjasa
johnjasa self-requested a review October 15, 2026 18:13
@johnjasa johnjasa added the ready for review This PR is ready for input from folks label Oct 15, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review This PR is ready for input from folks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants