Resetting functionality

Index

Paths

Paths are internal types that are used for the identification of a reset. They are used internally for dispatch.

The following function is included for extracting the values from paths:

Resetting new values

If you must reset a different type of value than outlined below, you must also create a new type. This is especially important when creating a new AbstractInitData.

Reset types

Reset types are introduced to differentiate on what must be reset in a given element. They are used internally for dispatch.

Resetting new values

If you must reset a different type of value than outlined below, you must also create a new type.

In this case, you must also create a new method for ResetType as this function is used internally.

EnergyModelsRecedingHorizon.AbstractReset — Type
abstract type AbstractReset

Supertype for types resetting values in fields in the individual AbstractElements. The individual subtype is related to the chosen AbstractPath as outlined above.

New subtypes

We currently have reset types for elements (e.g., nodes, links, areas, or transmission), operational profiles, and initial data. The individual types are automatically deduced through the constructor ResetType.

If you require resetting different fields than the provided, you must include a new AbstractPath subtype, a new mutable composite type as subtype of AbstractReset, and a new method for the constructor ResetType.

source
EnergyModelsRecedingHorizon.OperReset — Type
mutable struct OperReset <: AbstractReset

AbstractReset for resetting operational profiles within an element. The inner constructor is utilized for automatically creating the lens to the field path.

Inner constructor arguments

  • field_path::Vector is the path towards the field as identified through the function _find_update_paths.
  • x is the instance of a type for which the reset type is created.

Fields

  • lens::Union{PropertyLens,ComposedFunction} is the lens for resetting the field.
  • var is the variable when using ParametricOptInterface.
  • val::OperationalProfile is the complete operational profile from the original element. The individual values are extracted from this profile in the receding horizon framework.
source
EnergyModelsRecedingHorizon.PartitionReset — Type
mutable struct PartitionReset{AbstractResetBehavior} <: AbstractReset

AbstractReset for resetting partition profiles within an element. The inner constructor is utilized for

  • automatically creating the lens to the field path and
  • to decide whether the reset behaviour is
    • StandResBehav for the standard behavior with reset or
    • NoResBehav if it is called for the profile representing the period_duration of the node.

This differentiation only affects the ParametricOptInterface extension. The core structure will always apply the reset.

Inner constructor arguments

  • field_path::Vector is the path towards the field as identified through the function _find_update_paths.
  • x is the instance of a type for which the reset type is created.

Fields

  • lens::Union{PropertyLens,ComposedFunction} is the lens for resetting the field.
  • var is the variable when using ParametricOptInterface.
  • pps::PartitionProfile is the partition profile corresponding to the duration of the individual partition periods.
  • val::PartitionProfile is the complete partition profile from the original element. The individual values are extracted from this profile in the receding horizon framework.
PartitionReset

The PartitionReset type requires the user to declare a new method period_duration for the type x which utilizes the concept of partitions. An error is provided if no method is declared.

source
EnergyModelsRecedingHorizon.ElementReset — Type
mutable struct ElementReset <: AbstractReset

AbstractReset for resetting elements within another. The inner constructor is utilized for automatically creating the lens to the field path.

Inner constructor arguments

  • field_path::Vector is the path towards the field as identified through the function _find_update_paths.
  • x is the instance of a type for which the reset type is created.

Fields

  • lens::Union{PropertyLens,ComposedFunction} is the lens for resetting the field.
  • val::AbstractElement is the element in the field of the original instance. It is used for identifying the linked AbstractElement after it is reset.
source
EnergyModelsRecedingHorizon.TimeWeightReset — Type
mutable struct TimeWeightReset <: AbstractReset

AbstractReset for resetting the time weight used in future value calculations.

Inner constructor arguments

  • field_path::Vector is the path towards the field as identified through the function _find_update_paths.
  • x is the instance of a type for which the reset type is created.

Fields

  • lens::Union{PropertyLens,ComposedFunction} is the lens for resetting the field.
  • var is the variable when using ParametricOptInterface.
  • val is the time weight that should be used in the analysis.
source
EnergyModelsRecedingHorizon.InitReset — Type
mutable struct InitReset{T} <: AbstractReset where {T<:AbstractInitDataPath}

AbstractReset for resetting initial data of an element. The inner constructor is utilized for automatically creating the lens to the field path.

Inner constructor arguments

  • field_path::Vector is the path towards the field as identified through the function _find_update_paths.
  • path::AbstractInitDataPath is the AbstractPath of the init data. It includes additional information that is utilized when resetting an element.
  • x is the instance of a type for which the reset type is created.

Fields

  • lens::Union{PropertyLens,ComposedFunction} is the lens for resetting the field.
  • path::AbstractInitDataPath is the AbstractPath of the init data. It includes additional information that is utilized when resetting an element.
  • var is the variable when using ParametricOptInterface.
  • val is the initial data value that should be used in the analysis.
source
EnergyModelsRecedingHorizon.ResetType — Function
ResetType(field_path::Vector, _::OperPath, x)
ResetType(field_path::Vector, _::PartitionPath, x)
ResetType(field_path::Vector, _::ElementPath, x)
ResetType(field_path::Vector, _::TimeWeightPath, x)
ResetType(field_path::Vector, path::AbstractInitDataPath, x)

Constructor for AbstractReset types depending on their specified AbstractPath.

New types

If you create a new AbstractReset type (due to the creation of a new [AbstractPath] type), you must also create a new method for this function.

This is not necessary for a new subtype of AbstractInitDataPath.

source

The following function is included for identification purposes:

The following function is included to identify the individual partitions when creating a PartitionReset.

EnergyModelsRecedingHorizon.period_duration — Function
period_duration(x)
period_duration(res_type::PartitionReset, 𝒯::TS.TimeStructure)

Returns the duration of the period partitions of the element x or the period partitions of the PartitionReset res_type for a given time structure 𝒯.

source

The following types were included to create a parametric type for PartitionReset to describe the behavior of the AbstractReset:

EnergyModelsRecedingHorizon.AbstractResetBehavior — Type
abstract type AbstractResetBehavior

Supertype for behaviors of resets, that is how the reset or if the reset should take place. The behavior is only utilized for the ParametricOptInterface extension as some profiles should never be substituted with a variable.

source
EnergyModelsRecedingHorizon.StandResBehav — Type
struct StandResBehav <: AbstractResetBehavior

AbstractResetBehavior in which the reset should operate as standardized, i.e., the AbstractReset subtype will allow for the standard reset.

source

Substitution types

Substitution types correspond to types that store information of the individual original instance, the updated instance, and all required resets of an object:

EnergyModelsRecedingHorizon.AbstractSub — Type
abstract type AbstractSub

Supertype for the creation of Substitution types.

Substitution types are used for simpler identification of the structures for substitutions.

New elements

If you include a new element, you must introduce a new AbstractSub type for the element.

source
EnergyModelsRecedingHorizon.Substitution — Function
Substitution(x::T, resets::Vector{<:AbstractReset}) where {T}
Substitution(new::T, org::T, resets::Vector{<:AbstractReset}) where {T<:Resource}
Substitution(new::T, org::T, resets::Vector{<:AbstractReset}) where {T<:RecHorEnergyModel}
Substitution(new::T, org::T, resets::Vector{<:AbstractReset}) where {T<:AbstractElement}

Constructor for AbstractSub types depending on the specified type of the input.

source

The following function is included for extracting the values from substitution types:

The following function is included for simplifying the overall code structure:

EnergyModelsRecedingHorizon._ele_to_sub — Function
_ele_to_sub(::Type{<:EMB.Node})
_ele_to_sub(::Type{<:Link})
_ele_to_sub(::Type{<:FutureValue})

Returns the subtype of AbstractSub for a given element.

New elements

If you include a new element, you must introduce a new method for this function.

source
Introducing new Elements

If you introduce new AbstractElements, you must also create a new subtype of AbstractSub, similar to NodeSub or LinkSub. The new subtype should have the same fields as the other subtypes.

In this case, you must also create a new method for _ele_to_sub

Update case type

All update information for updating/resetting the case dictionary and the model is stored within a single type:

EnergyModelsRecedingHorizon.UpdateCase — Type
mutable struct UpdateCase <: AbstractCase

Type including all information required for updating the individual fields of the elements in a receding horizon model.

This type follows in general the same structure as the Case type introduced in EnergyModelsBase in which the individual vectors of Resources or AbstractElements are replaced with the corresponding vectors of AbstractSub.

Fields

  • T::TS.TimeStructure is the time structure of the original problem.
  • model::ModelSub is the substitution type for the RecHorEnergyModel.
  • map_org::Dict is a dictionary for mapping the types of the receding horizon problem to the types of the full problem.
  • map_updated::Dict is a dictionary for mapping the types of the full problem to the types of the receding horizon problem.
  • products::Vector{<:ProductSub} is a vector of substitution types for the individual Resources.
  • elements::elements::Vector{Vector} is a vector of vectors of substitution types for the individual AbstractElements.
source

The following functions are included for extracting the values from paths:

EnergyModelsRecedingHorizon.get_sub_ele — Function
get_sub_ele(𝒮ᵛᵉᶜ::Vector{Vector}, x::Type{<:AbstractElement})
get_sub_ele(𝒰::UpdateCase, x::Type{<:AbstractElement})

Returns the Vector of AbstractSub corresponding to the type provided by x.

The function can be used both on an UpdateCase and the corresponding Vector{Vector}.

source
EnergyModelsRecedingHorizon.updated — Function
updated(𝒰::UpdateCase, x_org::T) where {T<:Union{TS.TimePeriod, Resource, AbstractElement}}
updated(𝒰::UpdateCase, x_org, x_ele)
updated(𝒰::UpdateCase, t_pd_org::T, x_org) where {T<:TS.PeriodPartition}
updated(𝒮::Vector{<:AbstractSub}, x_org::AbstractElement)
updated(s::AbstractSub)

Returns the updated (resetted) instance of the original instance x_org for a given UpdateCase. It is used for mapping and replacing instances of the type in fields.

If a third argument is provided, it returns the updated instance of the original instance x_org through the two argument method, except for period partitions. The updated period partition of the original period partition t_pd_org depends on the original instance x_org in which the partition is used.

If the input is an AbstractSub, it returns the value of the field new.

Period partitions

The mapping of period partitions is only available for partitions of elements that utilize a PartitionProfile, see _update_periods_mapping!.

source
EnergyModelsRecedingHorizon.original — Function
original(𝒰::UpdateCase, x_new::T) where {T<:Union{TS.TimePeriod, Resource, AbstractElement}}
original(𝒰::UpdateCase, x_new, x_ele)
original(𝒰::UpdateCase, t_pd_new::T, x_new) where {T<:TS.PeriodPartition}
original(𝒮::Vector{<:AbstractSub}, x_new::AbstractElement)
original(s::AbstractSub)

Returns the original instance of the new (resetted) instance x_new for a given UpdateCase. It is used for results extraction.

If a third argument is provided, it returns the original instance of the new instance x_new through the two argument method, except for period partitions. The original period partition of the new period partition t_pd_new depends on the new instance x_new in which the partition is used.

If the input is an AbstractSub, it returns the value of the field org.

Period partitions

The mapping of period partitions is only available for partitions of elements that utilize a PartitionProfile, see _update_periods_mapping!.

source