-
Notifications
You must be signed in to change notification settings - Fork 3
Partition duration for time structures #95
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 all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
75e32c2
Added partition_duration for TwoLevel{SimpleTimes}
JulStraus c2dd808
First take on PartitionProfile
JulStraus 03f8f77
Added support for TwoLevel and RepresentativePeriods
JulStraus a1cdb8a
Fixed formatting and docs
JulStraus 66cf9b0
Added support for TwoLevel and OperationalScenarios
JulStraus 84f559f
Restructured the folder
JulStraus 9ed65f4
Added support for TwoLevel with OperationalScenarios and Representati…
JulStraus 3b9d351
Added support for
JulStraus f4c9d4d
Apply suggestions from code review
JulStraus 32a3925
Minor additional changes
JulStraus e2d6be3
Renamed PartitionDuration to PeriodPartition
JulStraus 2464db3
Used JuliaFormatter
JulStraus 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 |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Add generic partition duration type | ||
| abstract type AbstractOpScenPart{T} <: PeriodPartition{T} end | ||
|
|
||
| ScenarioIndexable(::Type{<:AbstractOpScenPart}) = HasScenarioIndex() | ||
| _opscen(pd::AbstractOpScenPart) = pd.scen | ||
|
|
||
| # Add partition type with constructor for indexing when operational scenarios are present | ||
| struct OpScenPart{N,T} <: AbstractOpScenPart{T} | ||
| scen::Int | ||
| part::Int | ||
| chunk::NTuple{N,T} | ||
| end | ||
| PeriodPartition(itr::OperationalScenario, part, chunk) = OpScenPart(itr.scen, part, chunk) | ||
| eltype(::Type{PartitionDurationIterator{I}}) where {I<:OperationalScenario} = OpScenPart | ||
|
|
||
| Base.show(io::IO, pd::OpScenPart) = print(io, "sc$(pd.scen)-part$(pd.part)") | ||
|
|
||
| # Add function for generation of partitions from higher level | ||
| function partition_duration(ts::OperationalScenarios, dur) | ||
| return collect( | ||
| Iterators.flatten(partition_duration(osc, dur) for osc in opscenarios(ts)), | ||
| ) | ||
| end | ||
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 |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Add generic partition duration type | ||
| abstract type AbstractReprPart{T} <: PeriodPartition{T} end | ||
|
|
||
| RepresentativeIndexable(::Type{<:AbstractReprPart}) = HasReprIndex() | ||
| _rper(pd::AbstractReprPart) = pd.rp | ||
|
|
||
| # Add partition type with constructor for indexing when representative periods are present | ||
| struct ReprPart{N,T} <: AbstractReprPart{T} | ||
| rp::Int | ||
| part::Int | ||
| chunk::NTuple{N,T} | ||
| end | ||
| PeriodPartition(itr::RepresentativePeriod, part, chunk) = ReprPart(itr.rp, part, chunk) | ||
| eltype(::Type{PartitionDurationIterator{I}}) where {I<:RepresentativePeriod} = ReprPart | ||
|
|
||
| Base.show(io::IO, pd::ReprPart) = print(io, "rp$(pd.rp)-part$(pd.part)") | ||
|
|
||
| # Add partition type with constructor for indexing when representative periods and operational | ||
| # scenarios are present | ||
| struct ReprOpScenPart{N,T} <: AbstractReprPart{T} | ||
| rp::Int | ||
| scen::Int | ||
| part::Int | ||
| chunk::NTuple{N,T} | ||
| end | ||
| function PeriodPartition(itr::ReprOpScenario, part, chunk) | ||
| return ReprOpScenPart(itr.rp, itr.scen, part, chunk) | ||
| end | ||
| eltype(::Type{PartitionDurationIterator{I}}) where {I<:ReprOpScenario} = ReprOpScenPart | ||
|
|
||
| Base.show(io::IO, pd::ReprOpScenPart) = print(io, "rp$(pd.rp)-sc$(pd.scen)-part$(pd.part)") | ||
| ScenarioIndexable(::Type{<:ReprOpScenPart}) = HasScenarioIndex() | ||
| _opscen(pd::ReprOpScenPart) = pd.scen | ||
|
|
||
| # Add function for generation of partitions from higher level | ||
| function partition_duration(ts::RepresentativePeriods, dur) | ||
| return collect( | ||
| Iterators.flatten(partition_duration(rp, dur) for rp in repr_periods(ts)), | ||
| ) | ||
| end | ||
|
JulStraus marked this conversation as resolved.
|
||
| function partition_duration( | ||
| ts::RepresentativePeriod{T,OP}, | ||
| dur, | ||
| ) where {T,OP<:OperationalScenarios} | ||
| return collect( | ||
| Iterators.flatten(partition_duration(osc, dur) for osc in opscenarios(ts)), | ||
| ) | ||
| end | ||
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 |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # Add generic partition duration type | ||
| abstract type AbstractStratPart{T} <: PeriodPartition{T} end | ||
|
|
||
| StrategicIndexable(::Type{<:AbstractStratPart}) = HasStratIndex() | ||
| _strat_per(pd::AbstractStratPart) = pd.sp | ||
|
|
||
| # Add partition type with constructor for indexing when strategic periods are present | ||
| struct StratPart{N,T} <: AbstractStratPart{T} | ||
| sp::Int | ||
| part::Int | ||
| chunk::NTuple{N,T} | ||
| end | ||
| PeriodPartition(itr::StrategicPeriod, part, chunk) = StratPart(itr.sp, part, chunk) | ||
| eltype(::Type{PartitionDurationIterator{I}}) where {I<:StrategicPeriod} = StratPart | ||
|
|
||
| Base.show(io::IO, pd::StratPart) = print(io, "sp$(pd.sp)-part$(pd.part)") | ||
|
|
||
| # Add partition type with constructor for indexing when strategic and representative periods | ||
| # are present | ||
| struct StratReprPart{N,T} <: AbstractStratPart{T} | ||
| sp::Int | ||
| rp::Int | ||
| part::Int | ||
| chunk::NTuple{N,T} | ||
| end | ||
| function PeriodPartition(itr::StratReprPeriod, part, chunk) | ||
| return StratReprPart(itr.sp, itr.rp, part, chunk) | ||
| end | ||
| eltype(::Type{PartitionDurationIterator{I}}) where {I<:StratReprPeriod} = StratReprPart | ||
|
|
||
| Base.show(io::IO, pd::StratReprPart) = print(io, "sp$(pd.sp)-rp$(pd.rp)-part$(pd.part)") | ||
| RepresentativeIndexable(::Type{<:StratReprPart}) = HasReprIndex() | ||
| _rper(pd::StratReprPart) = pd.rp | ||
|
|
||
| # Add partition type with constructor for indexing when strategic periods and operational | ||
| # scenarios are present | ||
| struct StratOpScenPart{N,T} <: AbstractStratPart{T} | ||
| sp::Int | ||
| scen::Int | ||
| part::Int | ||
| chunk::NTuple{N,T} | ||
| end | ||
| function PeriodPartition(itr::StratOpScenario, part, chunk) | ||
| return StratOpScenPart(itr.sp, itr.scen, part, chunk) | ||
| end | ||
| eltype(::Type{PartitionDurationIterator{I}}) where {I<:StratOpScenario} = StratOpScenPart | ||
|
|
||
| function Base.show(io::IO, pd::StratOpScenPart) | ||
| return print(io, "sp$(pd.sp)-sc$(pd.scen)-part$(pd.part)") | ||
| end | ||
| ScenarioIndexable(::Type{<:StratOpScenPart}) = HasScenarioIndex() | ||
| _opscen(pd::StratOpScenPart) = pd.scen | ||
|
|
||
| # Add partition type with constructor for indexing when strategic periods, representative | ||
| # periods and operational scenarios are present | ||
| struct StratReprOpScenPart{N,T} <: AbstractStratPart{T} | ||
| sp::Int | ||
| rp::Int | ||
| scen::Int | ||
| part::Int | ||
| chunk::NTuple{N,T} | ||
| end | ||
| function PeriodPartition(itr::StratReprOpScenario, part, chunk) | ||
| return StratReprOpScenPart(itr.sp, itr.rp, itr.scen, part, chunk) | ||
| end | ||
| function eltype(::Type{PartitionDurationIterator{I}}) where {I<:StratReprOpScenario} | ||
| return StratReprOpScenPart | ||
| end | ||
|
|
||
| function Base.show(io::IO, pd::StratReprOpScenPart) | ||
| return print(io, "sp$(pd.sp)-rp$(pd.rp)-sc$(pd.scen)-part$(pd.part)") | ||
| end | ||
| RepresentativeIndexable(::Type{<:StratReprOpScenPart}) = HasReprIndex() | ||
| ScenarioIndexable(::Type{<:StratReprOpScenPart}) = HasScenarioIndex() | ||
| _rper(pd::StratReprOpScenPart) = pd.rp | ||
| _opscen(pd::StratReprOpScenPart) = pd.scen | ||
|
|
||
| # Add function for generation of partitions from higher level | ||
| function partition_duration(ts::TwoLevel, dur) | ||
| return collect( | ||
| Iterators.flatten(partition_duration(sp, dur) for sp in strategic_periods(ts)), | ||
| ) | ||
| end | ||
|
JulStraus marked this conversation as resolved.
|
||
| function partition_duration( | ||
| ts::StrategicPeriod{S,T,OP}, | ||
| dur, | ||
| ) where {S,T,OP<:RepresentativePeriods} | ||
| return collect( | ||
| Iterators.flatten(partition_duration(rp, dur) for rp in repr_periods(ts)), | ||
| ) | ||
| end | ||
| function partition_duration( | ||
| ts::StrategicPeriod{S,T,OP}, | ||
| dur, | ||
| ) where {S,T,OP<:OperationalScenarios} | ||
| return collect( | ||
| Iterators.flatten(partition_duration(osc, dur) for osc in opscenarios(ts)), | ||
| ) | ||
| end | ||
| function partition_duration( | ||
| ts::StratReprPeriod{T,RepresentativePeriod{T,OP}}, | ||
| dur, | ||
| ) where {T,OP<:OperationalScenarios} | ||
| return collect( | ||
| Iterators.flatten(partition_duration(osc, dur) for osc in opscenarios(ts)), | ||
| ) | ||
| end | ||
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.