Available time structures
TimeStruct.TimeStructure
— Typeabstract type TimeStructure{T}
Abstract type representing different time structures that consists of one or more time periods. The type 'T' gives the data type used for the duration of the time periods.
TimeStruct.SimpleTimes
— Typestruct SimpleTimes <: TimeStructure
A simple time structure conisisting of consecutive time periods of varying duration
Example
uniform = SimpleTimes(5, 1.0) # 5 periods of equal length
varying = SimpleTimes([2, 2, 2, 4, 10])
TimeStruct.CalendarTimes
— Typestruct CalendarTimes <: TimeStructure
A time structure that iterates flexible calendar periods using calendar arithmetic.
Example
ts = CalendarTimes(Dates.DateTime(2023, 1, 1), 12, Dates.Month(1))
ts_zoned = CalendarTimes(TimeZones.ZonedDateTime(Dates.DateTime(2023, 1, 1), tz"CET"), 52, Dates.Week(1))
TimeStruct.RepresentativePeriods
— TypeRepresentativePeriods <: TimeStructure
Time structure that allows a time period to be represented by one or more shorter representative time periods.
The representative periods are an ordered sequence of TimeStructures that are used for each representative period. In addition, each representative period has an associated share that specifies how much of the total duration that is attributed to it.
Example
# A year represented by two days with hourly resolution and relative shares of 0.7 and 0.3
periods = RepresentativePeriods(2, 8760, [0.7, 0.3], [SimpleTimes(24, 1), SimpleTimes(24,1)])
TimeStruct.OperationalScenarios
— Typestruct OperationalScenarios <: TimeStructure
Time structure that have multiple scenarios where each scenario has its own time structure and an associated probability. Note that all scenarios must use the same type for the duration.
TimeStruct.TwoLevel
— Typestruct TwoLevel <: TimeStructure
A time structure with two levels of time periods.
On the top level it has a sequence of strategic periods of varying duration. For each strategic period a separate time structure is used for operational decisions. Iterating the structure will go through all operational periods. It is possible to use different time units for the two levels by providing the number of operational time units per strategic time unit.
Example
periods = TwoLevel(5, 8760, SimpleTimes(24, 1)) # 5 years with 24 hours of operations for each year
Properties of time periods
TimeStruct.duration
— Functionduration(t::TimePeriod)
The duration of a time period in number of operational time units.
TimeStruct.isfirst
— Functionisfirst(t::TimePeriod)
Returns true if the time period is the first in a sequence and has no previous time period
TimeStruct.multiple
— Functionmultiple(t::TimePeriod)
Returns the number of times a time period should be counted for the whole time structure.
TimeStruct.probability
— Functionprobability(t::TimePeriod)
Returns the probability associated with the time period.
Iterating time structures
TimeStruct.repr_periods
— Functionrepr_periods(ts)
Iterator that iterates over representative periods in an RepresentativePeriods
time structure.
repr_periods(sper)
Iterator that iterates over representative periods for a specific strategic period.
repr_periods(ts)
Returns a collection of all representative periods for a TwoLevel time structure.
TimeStruct.opscenarios
— Functionopscenarios(ts)
Iterator that iterates over operational scenarios in an OperationalScenarios
time structure.
opscenarios(rep::RepresentativePeriod)
Iterator that iterates over operational scenarios in a RepresentativePeriod
time structure.
opscenarios(sp::StrategicPeriod)
Iterator that iterates over operational scenarios for a specific strategic period.
opscenarios(ts::TwoLevel)
Returns a collection of all operational scenarios for a TwoLevel time structure.
TimeStruct.strat_periods
— Functionstrat_periods(ts::TimeStructure)
Iterator to go through the strategic periods of a time structure.
The elements returned will be subtypes of AbstractStrategicPeriod
. If the time structure do not have strategic periods, the overall time structure will be wrapped as a single strategic period.
Example
periods = TwoLevel(5, SimpleTimes(10,1))
total_dur = sum(duration_strat(sp) for sp in strategic_periods(periods))
TimeStruct.withprev
— Functionwithprev(iter)
Iterator wrapper that yields (prev, t)
where prev
is the previous time period or nothing
for the first time period.
TimeStruct.chunk
— Functionchunk(iter, n; cyclic = false)
Iterator wrapper that yields chunks where each chunk is an iterator over at most n
consecutive time periods starting at each time period of the original iterator.
It is possible to get the n
consecutive time periods in a cyclic fashion, by setting cyclic
to true.
TimeStruct.chunk_duration
— Functionchunk_duration(iter, dur)
Iterator wrapper that yields chunks based on duration where each chunk is an iterator over the following time periods until at least dur
time is covered or the end is reached.
Time profiles
TimeStruct.FixedProfile
— TypeFixedProfile(val)
Time profile with a constant value for all time periods
TimeStruct.OperationalProfile
— TypeOperationalProfile
Time profile with a value that varies with the operational time period.
If too few values are provided, the last provided value will be repeated.
TimeStruct.RepresentativeProfile
— TypeRepresentativeProfile(vals)
Time profile with a separate time profile for each representative period.
If too few profiles are provided, the last given profile will be repeated.
TimeStruct.ScenarioProfile
— TypeScenarioProfile(vals)
Time profile with a separate time profile for each scenario
TimeStruct.StrategicProfile
— TypeStrategicProfile(vals)
Time profile with a separate time profile for each strategic period.
If too few profiles are provided, the last given profile will be repeated.
Discounting
TimeStruct.discount
— Functiondiscount(t, time_struct, discount_rate; type, timeunit_to_year)
Calculates the discount factor to be used for a time period t
using a fixed 'discount_rate. There are two types of discounting available, either discounting to the start of the time period or calculating an approximate value for the average discount factor over the whole time period (
type="avg"`).
TimeStruct.objective_weight
— Functionobjective_weight(t, time_struct, discount_rate; type, timeunit_to_year)
Returns an overall weight to be used for a time period t
in the objective function considering both discounting, probability and possible multiplicity.
TimeStruct.Discounter
— TypeDiscounter(discount_rate, timeunit_to_year, ts)
Structure to hold discount information to be used for a time structure.