Resetting functionality
Index
EnergyModelsRecedingHorizon.AbstractInitDataPathEnergyModelsRecedingHorizon.AbstractPathEnergyModelsRecedingHorizon.AbstractResetEnergyModelsRecedingHorizon.AbstractSubEnergyModelsRecedingHorizon.ElementPathEnergyModelsRecedingHorizon.ElementResetEnergyModelsRecedingHorizon.FutureValueSubEnergyModelsRecedingHorizon.InitDataPathEnergyModelsRecedingHorizon.InitResetEnergyModelsRecedingHorizon.LinkSubEnergyModelsRecedingHorizon.ModelSubEnergyModelsRecedingHorizon.NodeSubEnergyModelsRecedingHorizon.OperPathEnergyModelsRecedingHorizon.OperResetEnergyModelsRecedingHorizon.ProductSubEnergyModelsRecedingHorizon.TimeWeightPathEnergyModelsRecedingHorizon.TimeWeightResetEnergyModelsRecedingHorizon.UpdateCaseEnergyModelsRecedingHorizon.ResetTypeEnergyModelsRecedingHorizon.SubstitutionEnergyModelsRecedingHorizon._ele_to_subEnergyModelsRecedingHorizon.get_sub_eleEnergyModelsRecedingHorizon.get_sub_elements_vecEnergyModelsRecedingHorizon.get_sub_modelEnergyModelsRecedingHorizon.get_sub_periodsEnergyModelsRecedingHorizon.get_sub_productsEnergyModelsRecedingHorizon.is_init_resetEnergyModelsRecedingHorizon.model_keyEnergyModelsRecedingHorizon.originalEnergyModelsRecedingHorizon.resetsEnergyModelsRecedingHorizon.updated
Paths
Path are internal types that are used for the identification of a reset. They are used internally for dispatch.
EnergyModelsRecedingHorizon.AbstractPath — Typeabstract type AbstractPathSupertype for identification of the type which is resetted by a lens.
EnergyModelsRecedingHorizon.OperPath — Typestruct OperPath <: AbstractPathInternal type for paths pointing towards operational profiles.
EnergyModelsRecedingHorizon.ElementPath — Typestruct ElementPath <: AbstractPathInternal type for paths pointing towards elements.
EnergyModelsRecedingHorizon.TimeWeightPath — Typestruct TimeWeightPath <: AbstractPathInternal type for paths pointing towards the time weight of a future value.
EnergyModelsRecedingHorizon.AbstractInitDataPath — Typeabstract type AbstractInitDataPath <: AbstractPathSupertype for identification of the AbstractPath types that are used for initial data. If you create a new AbstractInitData type, you must also create a new AbstractInitDataPath subtype
EnergyModelsRecedingHorizon.InitDataPath — Typestruct InitDataPath <: AbstractInitDataPathInternal type for paths pointing towards InitData.
Fields
key::Symbolis the key in theInitData(and correspondingly in the JuMP model).
The following function is included for extracting the values from paths:
EnergyModelsRecedingHorizon.model_key — Methodmodel_key(idp::InitDataPath)Returns the model key (field key) of InitDataPath idp.
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.AbstractReset — Typeabstract type AbstractResetSupertype for types resetting values in fields in the individual AbstractElements. The individual subtype is related to the chosen AbstractPath as outlined above.
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.
EnergyModelsRecedingHorizon.ElementReset — Typemutable struct ElementReset <: AbstractResetAbstractReset for resetting elements within another. The inner constructor is utilized for automatically creating the lens to the field path.
Inner constructor arguments
field_path::Vectoris the path towards the field as identified through the function_find_update_paths.xis 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::AbstractElementis the element in the field of the original instance. It is used for identifying the linkedAbstractElementafter it is reset.
EnergyModelsRecedingHorizon.OperReset — Typemutable struct OperReset <: AbstractResetAbstractReset 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::Vectoris the path towards the field as identified through the function_find_update_paths.xis the instance of a type for which the reset type is created.
Fields
lens::Union{PropertyLens,ComposedFunction}is the lens for resetting the field.varis the variable when usingParametricOptInterface.val::OperationalProfileis the complete operational profile from the original element. The individual values are extracted from this profile in the receding horizon framework.
EnergyModelsRecedingHorizon.TimeWeightReset — Typemutable struct TimeWeightReset <: AbstractResetAbstractReset for resetting the time weight used in future value calculations.
Inner constructor arguments
field_path::Vectoris the path towards the field as identified through the function_find_update_paths.xis the instance of a type for which the reset type is created.
Fields
lens::Union{PropertyLens,ComposedFunction}is the lens for resetting the field.varis the variable when usingParametricOptInterface.valis the time weight that should be used in the analysis.
EnergyModelsRecedingHorizon.InitReset — Typemutable 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::Vectoris the path towards the field as identified through the function_find_update_paths.path::AbstractInitDataPathis theAbstractPathof the init data. It includes additional information that is utilized when resetting an element.xis 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::AbstractInitDataPathis theAbstractPathof the init data. It includes additional information that is utilized when resetting an element.varis the variable when usingParametricOptInterface.valis the initial data value that should be used in the analysis.
EnergyModelsRecedingHorizon.ResetType — FunctionResetType(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.
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.
The following function is included for identification purposes:
EnergyModelsRecedingHorizon.is_init_reset — Functionis_init_reset(rt::AbstractReset)Function fo identifying whether the AbstractReset rt is of type InitReset.
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.AbstractSub — Typeabstract type AbstractSubSupertype for the creation of Substitution types.
Substitution types are used for simpler identification of the structures for substitutions.
If you include a new element, you must introduce a new AbstractSub type for the element.
EnergyModelsRecedingHorizon.ModelSub — Typemutable struct ModelSub{T<:RecHorEnergyModel} <: AbstractSubAbstractSub for RecHorEnergyModel.
Fields
new::Tis the new instance after resetting its values.org::Tis the original instance before resetting its values.resets::Vector{<:AbstractReset}areAbstractResettypes for the givenRecHorEnergyModel.
EnergyModelsRecedingHorizon.ProductSub — Typemutable struct ProductSub{T<:Resource} <: AbstractSubAbstractSub for Resources.
Fields
new::Tis the new instance after resetting its values.org::Tis the original instance before resetting its values.resets::Vector{<:AbstractReset}areAbstractResettypes for the givenResource.
EnergyModelsRecedingHorizon.NodeSub — Typemutable struct NodeSub{T<:EMB.Node} <: AbstractSubAbstractSub for Nodes.
Fields
new::Tis the new instance after resetting its values.org::Tis the original instance before resetting its values.resets::Vector{<:AbstractReset}areAbstractResettypes for the givenNode.
EnergyModelsRecedingHorizon.LinkSub — Typemutable struct LinkSub{T<:Link} <: AbstractSubAbstractSub for Links.
Fields
new::Tis the new instance after resetting its values.org::Tis the original instance before resetting its values.resets::Vector{<:AbstractReset}areAbstractResettypes for the givenLink.
EnergyModelsRecedingHorizon.FutureValueSub — Typemutable struct FutureValueSub{T<:FutureValue} <: AbstractSubAbstractSub for FutureValues.
Fields
new::Tis the new instance after resetting its values.org::Tis the original instance before resetting its values.resets::Vector{<:AbstractReset}areAbstractResettypes for the givenFutureValue.
EnergyModelsRecedingHorizon.Substitution — FunctionSubstitution(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.
The following function is included for extracting the values from substitution types:
EnergyModelsRecedingHorizon.resets — Functionresets(s::AbstractSub)Returns the Vector{AbstractReset} of the AbstractSub s.
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.
If you include a new element, you must introduce a new method for this function.
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 — Typemutable struct UpdateCase <: AbstractCaseType 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::ModelSubis the substitution type for theRecHorEnergyModel.opers::Dictis 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 individualResources.elements::elements::Vector{Vector}is a vector of vectors of substitution types for the individualAbstractElements.
The following functions are included for extracting the values from paths:
EnergyModelsRecedingHorizon.get_sub_model — Functionget_sub_model(𝒰::UpdateCase)Returns the ModelSub type of UpdateCase 𝒰.
EnergyModelsRecedingHorizon.get_sub_periods — Functionget_sub_periods(𝒰::UpdateCase)Returns the periods mapping dictionary of UpdateCase 𝒰.
EnergyModelsRecedingHorizon.get_sub_products — Functionget_sub_products(𝒰::UpdateCase)Returns the products Vector of UpdateCase 𝒰.
EnergyModelsRecedingHorizon.get_sub_elements_vec — Functionget_sub_elements_vec(𝒰::UpdateCase)Returns the elements Vector{Vector} of UpdateCase 𝒰.
EnergyModelsRecedingHorizon.get_sub_ele — Functionget_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}.
EnergyModelsRecedingHorizon.updated — Functionupdated(𝒰::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.
EnergyModelsRecedingHorizon.original — Functionoriginal(𝒰::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.