Internals - ParametricOptInterface extension

Index

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.

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

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

source
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:

  1. res_type::ElementReset results in no update,
  2. res_type::InitReset{EMRH.InitDataPath} updates the value directly from res_type,
  3. res_type::TimeWeightReset updates the value directly from res_type,
  4. res_type::OperReset creates a new operational profile based on the original operational profile and the set of operational periods in opers, updating each parameter with it.
source

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_rhMethod
EMRH.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.

Using POI

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.

source

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.

source
EnergyModelsRecedingHorizon._reset_fieldMethod
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)

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:

  1. res_type::ElementReset uses 𝒰 for identifying the new element and does not create new parameters,
  2. res_type::InitReset and res_type::TimeWeightReset create a single new MOI parameter and resets the field with it,
  3. res_type::OperReset creates multiple MOI parameters and a new operational profile based on the original operational profile, and resets the field with it.
source

EnergyModelsBase

EnergyModelsBase.constraints_capacity_installedFunction
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.

Fixed variables

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