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 individual fields of all types whose value(s) change(s).
In addition, the UpdateCase 𝒰 is updated with the mapping between the operational periods of the optimization (through 𝒯ᵣₕ) and the original (through opers) problem.
POIExt.update_model! — Function
update_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, 𝒰::UpdateCase, 𝒮::Vector{<:AbstractSub}, opers::Vector{<:TS.TimePeriod})
_update_parameter_values!(m, 𝒰::UpdateCase, 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, 𝒰::UpdateCase, res_type::ElementReset, opers::Vector)
_update_parameter!(m, 𝒰::UpdateCase, res_type::OperReset, opers::Vector)
_update_parameter!(m, 𝒰::UpdateCase, res_type::InitReset{EMRH.InitDataPath}, opers::Vector)
_update_parameter!(m, 𝒰::UpdateCase, res_type::TimeWeightReset, opers::Vector)
_update_parameter!(m, 𝒰::UpdateCase, res_type::PartitionReset{StandResBehav}, opers::Vector)
_update_parameter!(m, 𝒰::UpdateCase, res_type::PartitionReset{NoResBehav}, opers::Vector)
_update_parameter!(m, 𝒰::UpdateCase, res_type::EmptyReset, 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.res_type::PartitionReset{StandResBehav}creates a new partition profile based on the original partition profile and the set of partition periods, identified throughopers, updating each parameter with it.res_type::PartitionReset{NoResBehav}results in no update,res_type::EmptyResetresults in no update,
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 — Method
EMRH.run_model_rh(case::AbstractCase, modeltype::RecHorEnergyModel, optimizer::POI.Optimizer; check_timeprofiles::Bool = true, use_op_per_strat::Bool=false, optimizer_param::Dict=Dict(MOI.Silent() => 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! — Method
EMRH._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 — Method
EMRH._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)
EMRH._reset_field(m, x_rh, res_type::PartitionReset{StandResBehav}, 𝒰::UpdateCase, 𝒯ᴿᴴ::TimeStructure)
EMRH._reset_field(m, x_rh, res_type::PartitionReset{NoResBehav}, 𝒰::UpdateCase, 𝒯ᴿᴴ::TimeStructure)
EMRH._reset_field(m, x_rh, res_type::EmptyReset, 𝒰::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.res_type::PartitionReset{StandResBehav}creates multiple MOI parameters and a new partition profile based on the original partition profile, and resets the field with it.res_type::PartitionReset{NoResBehav}does not reset any field or introduce variables. It is used to avoid problems with partition profile resetting. It will however check, that the specifiedperiod_durationis consistent with the time structure.res_type::EmptyResetdoes not reset any field or introduce variables.
EnergyModelsBase
EnergyModelsBase.constraints_capacity_installed — Function
EMB.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.