Resetting functionality

Index

Paths

Path 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.

EnergyModelsRecedingHorizon.AbstractResetType
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 the constructor ResetType.

source
EnergyModelsRecedingHorizon.ElementResetType
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.OperResetType
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.TimeWeightResetType
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.InitResetType
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.ResetTypeFunction
ResetType(field_path::Vector, _::OperPath, 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:

Resetting new values

If you must reset a different type of value than outlined below, you must also create a new type. If you create a new AbstractPath, it is not neccesary to create a new type.

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

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.AbstractSubType
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.SubstitutionFunction
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_subFunction
_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.UpdateCaseType
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

  • model::ModelSub is the substitution type for the RecHorEnergyModel.
  • opers::Dict is a dictionary for mapping the operational periods of the receding horizon problem to the operational periods of the full 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_eleFunction
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.updatedFunction
updated(𝒰::UpdateCase, x_org::AbstractElement)
updated(𝒰::UpdateCase, x_org::Resource)
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 the input is an AbstractSub, it returns the value of the field new.

source
EnergyModelsRecedingHorizon.originalFunction
original(𝒰::UpdateCase, x_new::AbstractElement)
original(𝒰::UpdateCase, x_new::Resource)
original(𝒰::UpdateCase, x_new::TS.TimePeriod)
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 the input is an AbstractSub, it returns the value of the field org.

source