Internals - ParametricOptInterface extension
Index
EnergyModelsBase.constraints_capacity_installedEnergyModelsRecedingHorizon._reset_fieldEnergyModelsRecedingHorizon._update_case_types!EnergyModelsRecedingHorizon.run_model_rhPOIExt._init_update_case!POIExt._update_parameter!POIExt._update_parameter_values!POIExt.update_model!
Extension
Utility functions
POIExt._init_update_case! — Function_init_update_case!(m, 𝒰, opers, 𝒯ᵣₕ)Initialize the JuMP model m and the UpdateCase 𝒰 with the anonymous variables corresponding to the inidividual fields of all types whose value(s) change(s).
In addition, the UpdateCase 𝒰 is updated with the new mapping between the operational periods of the optimization (through 𝒯ᵣₕ) and the original (through opers) problem.
POIExt.update_model! — Functionupdate_model!(m, 𝒰, opers, 𝒯ᵣₕ)Update the JuMP model m with the new values given by the vector of operational periods of the original problem opers.
In addition, the UpdateCase 𝒰 is updated with the new mapping between the operational periods of the optimization (through 𝒯ᵣₕ) and the original (through opers) problem.
POIExt._update_parameter_values! — Function_update_parameter_values!(m, 𝒮::Vector{<:AbstractSub}, opers::Vector{<:TS.TimePeriod})
_update_parameter_values!(m, s:::AbstractSub, opers::Vector{<:TS.TimePeriod})Updates the parameters from m with the values within the Vector{<:AbstractSub} or AbstractSub indexed by opers. The update only takes place when the field resets of a given AbstractSub is not empty. In this case, the subroutine _update_parameter! is called to set the parameter to the new value.
POIExt._update_parameter! — Method_update_parameter!(m, res_type::ElementReset, opers::Vector)
_update_parameter!(m, res_type::OperReset, opers::Vector)
_update_parameter!(m, res_type::InitReset{EMRH.InitDataPath}, opers::Vector)
_update_parameter!(m, res_type::TimeWeightReset, opers::Vector)Set the parameter value in m for a given res_type:
res_type::ElementResetresults in no update,res_type::InitReset{EMRH.InitDataPath}updates the value directly fromres_type,res_type::TimeWeightResetupdates the value directly fromres_type,res_type::OperResetcreates a new operational profile based on the original operational profile and the set of operational periods inopers, updating each parameter with it.
EnergyModelsRecedingHorizon
Exported methods
Because the receding horizon implementation using ParametricOptInterface relies on pre-allocation of the input parameters for time profiles, its use is only allowed with PeriodHorizons, as it is a horizon type that preserves the length of the input time profiles.
EnergyModelsRecedingHorizon.run_model_rh — MethodEMRH.run_model_rh(case::AbstractCase, model::EMRH.RecHorEnergyModel, optimizer::POI.Optimizer; check_timeprofiles::Bool = true)When the optimizer is a ParametricOptInterface.Optimizer type, it utilizes ParametricOptInterface (POI) for resetting the individual values.
When using POI, the horizon type must be a PeriodHorizons type with each individual horizon having the same durations for its periods. This is checked using an @assert macro.
Internal methods
EnergyModelsRecedingHorizon._update_case_types! — MethodEMRH._update_case_types!(m, 𝒮::Vector{<:AbstractSub}, 𝒰::UpdateCase, opers::Vector{<:TS.TimePeriod})
EMRH._update_case_types!(m, s:::AbstractSub, 𝒰::UpdateCase, opers::Vector{<:TS.TimePeriod})Updates the elements within the Vector{<:AbstractSub} or AbstractSub with the new values, The update only takes place when the field reset of a given AbstractSub is not empty. In this case, the subfunction _reset_field is called.
The variables for ParametricOptInterface are saved in the model m.
EnergyModelsRecedingHorizon._reset_field — MethodEMRH._reset_field(m, x_rh, res_type::ElementReset, 𝒰::UpdateCase, 𝒯ᴿᴴ::TimeStructure)
EMRH._reset_field(m, x_rh, res_type::Union{InitReset,TimeWeightReset}, 𝒰::UpdateCase, 𝒯ᴿᴴ::TimeStructure)
EMRH._reset_field(m, x_rh, res_type::OperReset, 𝒰::UpdateCase, 𝒯ᴿᴴ::TimeStructure)Resets the field expressed through res_type of element x_rh with the new value. The type of the new value is depending on the specified res_type:
res_type::ElementResetuses𝒰for identifying the new element and does not create new parameters,res_type::InitResetandres_type::TimeWeightResetcreate a single new MOI parameter and resets the field with it,res_type::OperResetcreates multiple MOI parameters and a new operational profile based on the original operational profile, and resets the field with it.
EnergyModelsBase
EnergyModelsBase.constraints_capacity_installed — FunctionEMB.constraints_capacity_installed(m, n::Node, 𝒯::TimeStructure, modeltype::RecHorEnergyModel)
EMB.constraints_capacity_installed(m, n::Storage, 𝒯::TimeStructure, modeltype::RecHorEnergyModel)
EMB.constraints_capacity_installed(m, l::Link, 𝒯::TimeStructure, modeltype::RecHorEnergyModel)When modeltype is a receding horizon model, the function utilizes constraints instead of the function JuMP.fix for constraining the capacity as it is not possible to fix to a POI parameter.
Fixing variables is not possible if the parameter is a POI parameter. It is instead necessary to utilize constraints. Improved speed can be achieved by calling
# before the constraint
MOI.set(m, POI.ConstraintsInterpretation(), POI.ONLY_BOUNDS)
# and
MOI.set(m, POI.ConstraintsInterpretation(), POI.ONLY_CONSTRAINTS)
# after the constraint.