-
Notifications
You must be signed in to change notification settings - Fork 3
Fix get_demand_limiting_capacity to account for seasonal/annual activity limits
#1326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
fd8da62
Fix `get_demand_limiting_capacity` to account for seasonal/annual act…
tsmbland 5b37988
Clarify inline comment
tsmbland 03cde35
Update results files
tsmbland f27c319
Fix for timeslices with zero supply
tsmbland 26772c1
Fix for timeslices with zero activity
tsmbland 6555b33
Don't need numbers in TimeSliceLevel
tsmbland a7472f2
Improve docstring
tsmbland ec89be1
Add test
tsmbland 9272707
Potential fix for pull request finding
tsmbland 6179fc4
containing_selection_at_level returns Option
tsmbland 8075d34
Merge branch 'main' into demand_limiting_capacity_fix
tsmbland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,6 +94,28 @@ impl TimeSliceSelection { | |
| } | ||
| } | ||
|
|
||
| /// Get the [`TimeSliceSelection`] containing this selection at the specified level. | ||
| pub fn containing_selection_at_level(&self, level: TimeSliceLevel) -> TimeSliceSelection { | ||
| assert!( | ||
| level >= self.level(), | ||
| "Cannot get containing selection at finer level" | ||
| ); | ||
|
|
||
|
Comment on lines
+97
to
+105
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with Copilot: I'd return |
||
| let mut selection = self.clone(); | ||
|
|
||
| while selection.level() < level { | ||
| selection = match selection { | ||
| TimeSliceSelection::Single(time_slice_id) => { | ||
| TimeSliceSelection::Season(time_slice_id.season.clone()) | ||
| } | ||
| TimeSliceSelection::Season(_) => TimeSliceSelection::Annual, | ||
| TimeSliceSelection::Annual => unreachable!(), | ||
| }; | ||
| } | ||
|
|
||
| selection | ||
| } | ||
|
|
||
| /// Iterate over the subset of time slices in this selection | ||
| pub fn iter<'a>( | ||
| &'a self, | ||
|
|
@@ -192,7 +214,15 @@ impl Display for TimeSliceSelection { | |
|
|
||
| /// The time granularity for a particular operation | ||
| #[derive( | ||
| PartialEq, PartialOrd, Copy, Clone, Debug, DeserializeLabeledStringEnum, strum::EnumIter, | ||
| PartialEq, | ||
| Eq, | ||
| PartialOrd, | ||
| Ord, | ||
| Copy, | ||
| Clone, | ||
| Debug, | ||
| DeserializeLabeledStringEnum, | ||
| strum::EnumIter, | ||
| )] | ||
| pub enum TimeSliceLevel { | ||
| /// Treat individual time slices separately | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,50 +1,47 @@ | ||
| milestone_year,asset_id,group_id,capacity,num_units | ||
| 2020,0,,24.0, | ||
| 2020,1,,19.0, | ||
| 2025,0,,24.0, | ||
| 2025,2,,23.939952120095757, | ||
| 2025,3,,9.575980848038302, | ||
| 2025,4,,5.107189785620431, | ||
| 2030,0,,24.0, | ||
| 2025,3,,13.299973400053199, | ||
| 2025,4,,1.3299973400053235, | ||
| 2030,2,,23.939952120095757, | ||
| 2030,3,,9.575980848038302, | ||
| 2030,4,,5.107189785620431, | ||
| 2030,3,,13.299973400053199, | ||
| 2030,4,,1.3299973400053235, | ||
| 2030,5,,5.939988120023763, | ||
| 2030,6,,5.975988048023905, | ||
| 2030,6,,12.73337453325093, | ||
| 2035,2,,23.939952120095757, | ||
| 2035,3,,9.575980848038302, | ||
| 2035,3,,13.299973400053199, | ||
| 2035,5,,5.939988120023763, | ||
| 2035,6,,5.975988048023905, | ||
| 2035,6,,12.73337453325093, | ||
| 2035,7,,6.119987760024477, | ||
| 2035,8,,5.875188249623504, | ||
| 2035,8,,11.679816640366745, | ||
| 2040,2,,23.939952120095757, | ||
| 2040,3,,9.575980848038302, | ||
| 2040,3,,13.299973400053199, | ||
| 2040,5,,5.939988120023763, | ||
| 2040,6,,5.975988048023905, | ||
| 2040,6,,12.73337453325093, | ||
| 2040,7,,6.119987760024477, | ||
| 2040,8,,5.875188249623504, | ||
| 2040,9,,5.939988120023762, | ||
| 2040,10,,16.775966448067106, | ||
| 2040,11,,2.6567946864106284, | ||
| 2040,8,,11.679816640366745, | ||
| 2040,9,,5.939988120023761, | ||
| 2040,10,,1.0999978000044013, | ||
| 2045,2,,23.939952120095757, | ||
| 2045,3,,9.575980848038302, | ||
| 2045,3,,13.299973400053199, | ||
| 2045,5,,5.939988120023763, | ||
| 2045,6,,5.975988048023905, | ||
| 2045,6,,12.73337453325093, | ||
| 2045,7,,6.119987760024477, | ||
| 2045,8,,5.875188249623504, | ||
| 2045,9,,5.939988120023762, | ||
| 2045,10,,16.775966448067106, | ||
| 2045,12,,5.939988120023759, | ||
| 2045,13,,8.320303359393275, | ||
| 2045,8,,11.679816640366745, | ||
| 2045,9,,5.939988120023761, | ||
| 2045,10,,1.0999978000044013, | ||
| 2045,11,,5.939988120023761, | ||
| 2045,12,,6.4042111915775575, | ||
| 2050,2,,23.939952120095757, | ||
| 2050,3,,9.575980848038302, | ||
| 2050,3,,13.299973400053199, | ||
| 2050,5,,5.939988120023763, | ||
| 2050,6,,5.975988048023905, | ||
| 2050,6,,12.73337453325093, | ||
| 2050,7,,6.119987760024477, | ||
| 2050,8,,5.875188249623504, | ||
| 2050,9,,5.939988120023762, | ||
| 2050,10,,16.775966448067106, | ||
| 2050,12,,5.939988120023759, | ||
| 2050,13,,8.320303359393275, | ||
| 2050,14,,6.1199877600244745, | ||
| 2050,15,,5.703540592918827, | ||
| 2050,8,,11.679816640366745, | ||
| 2050,9,,5.939988120023761, | ||
| 2050,10,,1.0999978000044013, | ||
| 2050,11,,5.939988120023761, | ||
| 2050,12,,6.4042111915775575, | ||
| 2050,13,,6.11998776002448, | ||
| 2050,14,,6.950586098827813, |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.