Variables for Mathematical Programs
CommonOPF provides standard variables names so that the packages that build upon CommonOPF can leverage common results getters and VariableBounds
.
Variable Containers
CommonOPF provides variable containers to standardize indexing across OPF models. The order of indexing is:
var_symbol
like:v
bus_or_edge
time_step
- phase in
[1, 2, 3]
(ifMultiPhase
model)
Single phase models
CommonOPF.add_time_vector_variables!
— Functionadd_time_vector_variables!(
m::JuMP.AbstractModel,
net::Network{SinglePhase},
var_symbol::Symbol,
indices::AbstractVector{T}
) where {T}
Add variables to the m.obj_dict
indexed on:
var_symbol
like:v
indices
, typically aVector{String}
for bus indices or aVector{Tuple{String, String}}
for edge indices (like("bus1", "bus2")
)- timesteps in
1:net.Ntimesteps
For example, accessing the edge variable :sij
one edge ("bus1", "bus2")
voltage variable at time step 5
looks like:
m[:sij][("bus1", "bus2")][5]
Multiphase models
CommonOPF.multiphase_bus_variable_container
— Functionmultiphase_bus_variable_container(; default::DefaultType=missing)
Return a DefaultDict of DefaultDict with three key types for indexing variables on:
AbstractString
for bus namesInt
for time stepAbstractVecOrMat
for vectors or matrices of phase variables
CommonOPF.multiphase_edge_variable_container
— Functionmultiphase_edge_variable_container(; default::DefaultType=missing)
Return a DefaultDict of DefaultDict with three key types for indexing variables on:
Tuple{String, String}
for edge namesInt
for time stepAbstractVecOrMat
for vectors or matrices of phase variables
Variable Bounds
CommonOPF.VariableBounds
— Typestruct VariableBounds
Limits for decision variables in mathematical programs. Upper and lower values can be specified for power, current, and voltage variables. The VariableBounds
struct is attached to Network.bounds
upon creation of the Network
.
mutable struct VariableBounds
s_upper_real::Union{Real, Missing}
s_lower_real::Union{Real, Missing}
s_upper_imag::Union{Real, Missing}
s_lower_imag::Union{Real, Missing}
v_upper_mag::Union{Real, Missing}
v_lower_mag::Union{Real, Missing}
i_upper_mag::Union{Real, Missing}
i_lower_mag::Union{Real, Missing}
end
CommonOPF.VariableBounds
— Methodfunction VariableBounds(ntwk::Dict)
Check for the keys of the VariableBounds
struct in the ntwk
dictionary. Any missing bounds are set to missing
.