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.
Description
Adds reduce methods to a number of Resource monads, which do a "flat" resource reduction. That is, they use ThinResourceMonad.reduce to produce a single resource node, which collects all dependencies and reduces the dynamics, rather than the original Resources.reduce method, which creates a number of intermediate resources linear in the number of operands.
When doing large roll-ups, like a power model, those intermediate nodes each contribute a small performance overhead which can eventually add up. Providing a standard way to do reduction efficiently, and using that to do common operations like taking a sum or maximum, should help.
Verification
Some methods which use the new reduce operations, like PolynomialResources.min and max, already have unit tests. Those tests continue to pass unaltered.
Documentation
No documentation was invalidated - existing functions should have no logical changes, but they may be more efficient.
These
reduce
operators are mentioned in the streamline users' guide already. I wrote them once before and thought they were part of the main library, but I must have written them on another branch that has since been abandoned.Future work
N/A