Available time structures

TimeStruct.TimeStructureType
abstract 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.

source
TimeStruct.SimpleTimesType
struct 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])
source
TimeStruct.CalendarTimesType
struct 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))
source
TimeStruct.RepresentativePeriodsType
RepresentativePeriods <: 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)])
source
TimeStruct.OperationalScenariosType
struct 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.

source
TimeStruct.TwoLevelType
struct 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
source

Properties of time periods

TimeStruct.durationFunction
duration(t::TimePeriod)

The duration of a time period in number of operational time units.

source
TimeStruct.isfirstFunction
isfirst(t::TimePeriod)

Returns true if the time period is the first in a sequence and has no previous time period

source
TimeStruct.multipleFunction
multiple(t::TimePeriod)

Returns the number of times a time period should be counted for the whole time structure.

source

Iterating time structures

TimeStruct.repr_periodsFunction
repr_periods(ts)

Iterator that iterates over representative periods in an RepresentativePeriods time structure.

source
repr_periods(sper)

Iterator that iterates over representative periods for a specific strategic period.
source
repr_periods(ts)

Returns a collection of all representative periods for a TwoLevel time structure.
source
TimeStruct.opscenariosFunction
opscenarios(ts)

Iterator that iterates over operational scenarios in an OperationalScenarios time structure.

source
opscenarios(rep::RepresentativePeriod)

Iterator that iterates over operational scenarios in a RepresentativePeriod time structure.

source
opscenarios(sp::StrategicPeriod)

Iterator that iterates over operational scenarios for a specific strategic period.
source
opscenarios(ts::TwoLevel)

Returns a collection of all operational scenarios for a TwoLevel time structure.
source
TimeStruct.strat_periodsFunction
strat_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))
source
TimeStruct.withprevFunction
withprev(iter)

Iterator wrapper that yields (prev, t) where prev is the previous time period or nothing for the first time period.

source
TimeStruct.chunkFunction
chunk(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.

source
TimeStruct.chunk_durationFunction
chunk_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.

source

Time profiles

TimeStruct.OperationalProfileType
OperationalProfile

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.

source
TimeStruct.RepresentativeProfileType
RepresentativeProfile(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.

source
TimeStruct.StrategicProfileType
StrategicProfile(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.

source

Discounting

TimeStruct.discountFunction
discount(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"`).

source
TimeStruct.objective_weightFunction
objective_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.

source
TimeStruct.DiscounterType
Discounter(discount_rate, timeunit_to_year, ts)

Structure to hold discount information to be used for a time structure.

source