Constraints
Constraint Templates
Constraint templates help simplify data wrangling across multiple Power Flow formulations by providing an abstraction layer between the network data and network constraint definitions. The constraint template's job is to extract the required parameters from a given network data structure and pass the data as named arguments to the Power Flow formulations.
These templates should be defined over AbstractPowerModel and should not refer to model variables. For more details, see the files: core/constraint_template.jl and core/constraint.jl (core/constraint_template.jl provides higher level APIs, and pulls out index information from the data dictionaries, before calling out to methods defined in core/constraint.jl).
Voltage Constraints
PowerModels.constraint_model_voltage — Function
This constraint captures problem agnostic constraints that are used to link the model's voltage variables together, in addition to the standard problem formulation constraints.
Notable examples include the constraints linking the voltages in the ACTPowerModel, constraints linking convex relaxations of voltage variables.
do nothing, most models to not require any model-specific voltage constraints
PowerModels.constraint_model_voltage_on_off — Function
This constraint captures problem agnostic constraints that are used to link the model's voltage variables together, in addition to the standard problem formulation constraints. The on/off name indicates that the voltages in this constraint can be set to zero via an indicator variable
Notable examples include the constraints linking the voltages in the ACTPowerModel, constraints linking convex relaxations of voltage variables.
do nothing, most models to not require any model-specific on/off voltage constraints
do nothing, this model does not have complex voltage constraints
do nothing, this model does not have complex voltage variables
PowerModels.constraint_ne_model_voltage — Function
This constraint captures problem agnostic constraints that are used to link the model's voltage variables together, in addition to the standard problem formulation constraints. The network expantion name (ne) indicates that the voltages in this constraint can be set to zero via an indicator variable
Notable examples include the constraints linking the voltages in the ACTPowerModel, constraints linking convex relaxations of voltage variables.
do nothing, most models to not require any model-specific network expansion voltage constraints
do nothing, this model does not have complex voltage constraints
do nothing, this model does not have complex voltage variables
Generator Constraints
PowerModels.constraint_gen_setpoint_reactive — Function
qq[i] == qq
qq[i] == qq
do nothing, apo models do not have reactive variables
Bus Constraints
Setpoint Constraints
PowerModels.constraint_voltage_magnitude_setpoint — Function
v[i] == vm
v[i] == vm
do nothing, this model does not have voltage variables
Power Balance Constraints
PowerModels.constraint_power_balance — Function
constraint_power_balance(pm::AbstractPowerModel, i::Int; nw::Int=nw_id_default)PowerModels.constraint_power_balance_ls — Function
constraint_power_balance_ls(pm::AbstractPowerModel, i::Int; nw::Int=nw_id_default)Nodal power balance with constant power factor load and shunt shedding.
PowerModels.constraint_ne_power_balance — Function
constraint_ne_power_balance(pm::AbstractPowerModel, i::Int; nw::Int=nw_id_default)Branch Constraints
Ohm's Law Constraints
PowerModels.constraint_ohms_yt_from — Function
Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)
p[f_idx] == (g+g_fr)/tm*v[f_bus]^2 + (-g*tr+b*ti)/tm^2*(v[f_bus]*v[t_bus]*cos(t[f_bus]-t[t_bus])) + (-b*tr-g*ti)/tm^2*(v[f_bus]*v[t_bus]*sin(t[f_bus]-t[t_bus]))
q[f_idx] == -(b+b_fr)/tm*v[f_bus]^2 - (-b*tr-g*ti)/tm^2*(v[f_bus]*v[t_bus]*cos(t[f_bus]-t[t_bus])) + (-g*tr+b*ti)/tm^2*(v[f_bus]*v[t_bus]*sin(t[f_bus]-t[t_bus]))Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)
Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)
p[f_idx] == -b*(t[f_bus] - t[t_bus])nothing to do, no voltage angle variables
Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)
PowerModels.constraint_ohms_yt_to — Function
Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)
p[t_idx] == (g+g_to)*v[t_bus]^2 + (-g*tr-b*ti)/tm^2*(v[t_bus]*v[f_bus]*cos(t[t_bus]-t[f_bus])) + (-b*tr+g*ti)/tm^2*(v[t_bus]*v[f_bus]*sin(t[t_bus]-t[f_bus]))
q[t_idx] == -(b+b_to)*v[t_bus]^2 - (-b*tr+g*ti)/tm^2*(v[t_bus]*v[f_bus]*cos(t[f_bus]-t[t_bus])) + (-g*tr-b*ti)/tm^2*(v[t_bus]*v[f_bus]*sin(t[t_bus]-t[f_bus]))Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)
nothing to do, this model is symetric
Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)
Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)
PowerModels.constraint_ohms_y_from — Function
Creates Ohms constraints for AC models (y post fix indicates that Y values are in rectangular form)
p[f_idx] == (g+g_fr)*(v[f_bus]/tr)^2 + -g*v[f_bus]/tr*v[t_bus]*cos(t[f_bus]-t[t_bus]-as) + -b*v[f_bus]/tr*v[t_bus]*sin(t[f_bus]-t[t_bus]-as)
q[f_idx] == -(b+b_fr)*(v[f_bus]/tr)^2 + b*v[f_bus]/tr*v[t_bus]*cos(t[f_bus]-t[t_bus]-as) + -g*v[f_bus]/tr*v[t_bus]*sin(t[f_bus]-t[t_bus]-as)PowerModels.constraint_ohms_y_to — Function
Creates Ohms constraints for AC models (y post fix indicates that Y values are in rectangular form)
p[t_idx] == (g+g_to)*v[t_bus]^2 + -g*v[t_bus]*v[f_bus]/tr*cos(t[t_bus]-t[f_bus]+as) + -b*v[t_bus]*v[f_bus]/tr*sin(t[t_bus]-t[f_bus]+as)
q[t_idx] == -(b+b_to)*v[t_bus]^2 + b*v[t_bus]*v[f_bus]/tr*cos(t[f_bus]-t[t_bus]+as) + -g*v[t_bus]*v[f_bus]/tr*sin(t[t_bus]-t[f_bus]+as)On/Off Ohm's Law Constraints
PowerModels.constraint_ohms_yt_from_on_off — Function
p[f_idx] == z*(g/tm*v[f_bus]^2 + (-g*tr+b*ti)/tm^2*(v[f_bus]*v[t_bus]*cos(t[f_bus]-t[t_bus])) + (-b*tr-g*ti)/tm^2*(v[f_bus]*v[t_bus]*sin(t[f_bus]-t[t_bus])))
q[f_idx] == z*(-(b+c/2)/tm*v[f_bus]^2 - (-b*tr-g*ti)/tm^2*(v[f_bus]*v[t_bus]*cos(t[f_bus]-t[t_bus])) + (-g*tr+b*ti)/tm^2*(v[f_bus]*v[t_bus]*sin(t[f_bus]-t[t_bus])))-b*(t[f_bus] - t[t_bus] + vad_min*(1-z_branch[i])) <= p[f_idx] <= -b*(t[f_bus] - t[t_bus] + vad_max*(1-z_branch[i]))
Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)
p[f_idx] == g/tm*w_fr[i] + (-g*tr+b*ti)/tm*(wr[i]) + (-b*tr-g*ti)/tm*(wi[i])
q[f_idx] == -(b+c/2)/tm*w_fr[i] - (-b*tr-g*ti)/tm*(wr[i]) + (-g*tr+b*ti)/tm*(wi[i])PowerModels.constraint_ohms_yt_to_on_off — Function
p[t_idx] == z*(g*v[t_bus]^2 + (-g*tr-b*ti)/tm^2*(v[t_bus]*v[f_bus]*cos(t[t_bus]-t[f_bus])) + (-b*tr+g*ti)/tm^2*(v[t_bus]*v[f_bus]*sin(t[t_bus]-t[f_bus])))
q[t_idx] == z*(-(b+c/2)*v[t_bus]^2 - (-b*tr+g*ti)/tm^2*(v[t_bus]*v[f_bus]*cos(t[f_bus]-t[t_bus])) + (-g*tr-b*ti)/tm^2*(v[t_bus]*v[f_bus]*sin(t[t_bus]-t[f_bus])))nothing to do, this model is symetric
Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)
p[t_idx] == g*w_to[i] + (-g*tr-b*ti)/tm*(wr[i]) + (-b*tr+g*ti)/tm*(-wi[i])
q[t_idx] == -(b+c/2)*w_to[i] - (-b*tr+g*ti)/tm*(wr[i]) + (-g*tr-b*ti)/tm*(-wi[i])PowerModels.constraint_ne_ohms_yt_from — Function
p_ne[f_idx] == z*(g/tm*v[f_bus]^2 + (-g*tr+b*ti)/tm^2*(v[f_bus]*v[t_bus]*cos(t[f_bus]-t[t_bus])) + (-b*tr-g*ti)/tm^2*(v[f_bus]*v[t_bus]*sin(t[f_bus]-t[t_bus])))
q_ne[f_idx] == z*(-(b+c/2)/tm*v[f_bus]^2 - (-b*tr-g*ti)/tm^2*(v[f_bus]*v[t_bus]*cos(t[f_bus]-t[t_bus])) + (-g*tr+b*ti)/tm^2*(v[f_bus]*v[t_bus]*sin(t[f_bus]-t[t_bus])))Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)
p[f_idx] == g/tm*w_fr_ne[i] + (-g*tr+b*ti)/tm*(wr_ne[i]) + (-b*tr-g*ti)/tm*(wi_ne[i])
q[f_idx] == -(b+c/2)/tm*w_fr_ne[i] - (-b*tr-g*ti)/tm*(wr_ne[i]) + (-g*tr+b*ti)/tm*(wi_ne[i])PowerModels.constraint_ne_ohms_yt_to — Function
p_ne[t_idx] == z*(g*v[t_bus]^2 + (-g*tr-b*ti)/tm^2*(v[t_bus]*v[f_bus]*cos(t[t_bus]-t[f_bus])) + (-b*tr+g*ti)/tm^2*(v[t_bus]*v[f_bus]*sin(t[t_bus]-t[f_bus])))
q_ne[t_idx] == z*(-(b+c/2)*v[t_bus]^2 - (-b*tr+g*ti)/tm^2*(v[t_bus]*v[f_bus]*cos(t[f_bus]-t[t_bus])) + (-g*tr-b*ti)/tm^2*(v[t_bus]*v[f_bus]*sin(t[t_bus]-t[f_bus])))nothing to do, this model is symetric
Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)
p[t_idx] == g*w_to_ne[i] + (-g*tr-b*ti)/tm*(wr_ne[i]) + (-b*tr+g*ti)/tm*(-wi_ne[i])
q[t_idx] == -(b+c/2)*w_to_ne[i] - (-b*tr+g*ti)/tm*(wr_ne[i]) + (-g*tr-b*ti)/tm*(-wi_ne[i])Current
PowerModels.constraint_current_balance — Function
Kirchhoff's current law applied to buses sum(cr + im*ci) = 0
PowerModels.constraint_power_magnitude_sqr — Function
p[f_idx]^2 + q[f_idx]^2 <= w[f_bus]/tm*cm[f_bus,t_bus]
PowerModels.constraint_power_magnitude_sqr_on_off — Function
p[arc_from]^2 + q[arc_from]^2 <= w[f_bus]/tm*cm[i]
PowerModels.constraint_power_magnitude_link — Function
cm[f_bus,t_bus] == (g^2 + b^2)*(w[f_bus]/tm + w[t_bus] - 2*(tr*wr[f_bus,t_bus] + ti*wi[f_bus,t_bus])/tm) - c*q[f_idx] - ((c/2)/tm)^2*w[f_bus]
PowerModels.constraint_power_magnitude_link_on_off — Function
ccm[f_bus,t_bus] == (g^2 + b^2)*(w[f_bus]/tm + w[t_bus] - 2*(tr*wr[f_bus,t_bus] + ti*wi[f_bus,t_bus])/tm) - c*q[f_idx] - ((c/2)/tm)^2*w[f_bus]
Thermal Limit Constraints
PowerModels.constraint_thermal_limit_from — Function
constraint_thermal_limit_from(pm::AbstractPowerModel, n::Int, i::Int)Adds the (upper and lower) thermal limit constraints for the desired branch to the PowerModel.
p[f_idx]^2 + q[f_idx]^2 <= rate_a^2
[rate_a, p[f_idx], q[f_idx]] in SecondOrderCone
p[f_idx]^2 + q[f_idx]^2 <= rate_a^2
-rate_a <= p[f_idx] <= rate_a
PowerModels.constraint_thermal_limit_to — Function
p[t_idx]^2 + q[t_idx]^2 <= rate_a^2
[rate_a, p[t_idx], q[t_idx]] in SecondOrderCone
p[t_idx]^2 + q[t_idx]^2 <= rate_a^2
nothing to do, this model is symetric
PowerModels.constraint_thermal_limit_from_on_off — Function
p[f_idx]^2 + q[f_idx]^2 <= (rate_a * z_branch[i])^2
PowerModels.constraint_thermal_limit_to_on_off — Function
p[t_idx]^2 + q[t_idx]^2 <= (rate_a * z_branch[i])^2
nothing to do, this model is symetric
PowerModels.constraint_ne_thermal_limit_from — Function
p_ne[f_idx]^2 + q_ne[f_idx]^2 <= (rate_a * branch_ne[i])^2
PowerModels.constraint_ne_thermal_limit_to — Function
p_ne[t_idx]^2 + q_ne[t_idx]^2 <= (rate_a * branch_ne[i])^2
nothing to do, this model is symetric
Current Limit Constraints
PowerModels.constraint_current_to — Function
Defines how current distributes over series and shunt impedances of a pi-model branch
PowerModels.constraint_current_from — Function
Defines how current distributes over series and shunt impedances of a pi-model branch
PowerModels.constraint_current_limit_to — Function
constraint_current_limit_to(pm::AbstractPowerModel, i::Int; nw::Int=nw_id_default)Bounds the current magnitude at the to side of a branch
PowerModels.constraint_current_limit_from — Function
constraint_current_limit_from(pm::AbstractPowerModel, i::Int; nw::Int=nw_id_default)Bounds the current magnitude at the from side of a branch
Phase Angle Difference Constraints
PowerModels.constraint_voltage_angle_difference — Function
Bounds the voltage angle difference between bus pairs
branch voltage angle difference bounds
t[f_bus] - t[t_bus] <= angmax
t[f_bus] - t[t_bus] >= angminnothing to do, no voltage angle variables
PowerModels.constraint_voltage_angle_difference_on_off — Function
angmin <= z_branch[i]*(t[f_bus] - t[t_bus]) <= angmax
angmin*z_branch[i] + vad_min*(1-z_branch[i]) <= t[f_bus] - t[t_bus] <= angmax*z_branch[i] + vad_max*(1-z_branch[i])
angmin*z_branch[i] + vad_min*(1-z_branch[i]) <= t[f_bus] - t[t_bus] <= angmax*z_branch[i] + vad_max*(1-z_branch[i])
angmin*wr[i] <= wi[i] <= angmax*wr[i]
PowerModels.constraint_ne_voltage_angle_difference — Function
angmin <= branch_ne[i]*(t[f_bus] - t[t_bus]) <= angmax
angmin*branch_ne[i] + vad_min*(1-branch_ne[i]) <= t[f_bus] - t[t_bus] <= angmax*branch_ne[i] + vad_max*(1-branch_ne[i])
angmin*branch_ne[i] + vad_min*(1-branch_ne[i]) <= t[f_bus] - t[t_bus] <= angmax*branch_ne[i] + vad_max*(1-branch_ne[i])
angmin*wr_ne[i] <= wi_ne[i] <= angmax*wr_ne[i]
Loss Constraints
PowerModels.constraint_power_losses — Function
Defines branch flow model power flow equations
Defines linear branch flow model power flow equations
PowerModels.constraint_power_losses_lb — Function
p[f_idx] + p[t_idx] >= 0
q[f_idx] + q[t_idx] >= -c/2*(v[f_bus]^2/tr^2 + v[t_bus]^2)PowerModels.constraint_voltage_magnitude_difference — Function
Defines voltage drop over a branch, linking from and to side voltage magnitude
Defines voltage drop over a branch, linking from and to side voltage magnitude
PowerModels.constraint_voltage_drop — Function
Defines voltage drop over a branch, linking from and to side complex voltage
Storage Constraints
PowerModels.constraint_storage_thermal_limit — Function
constraint_storage_thermal_limit(pm::AbstractPowerModel, i::Int; nw::Int=nw_id_default)PowerModels.constraint_storage_current_limit — Function
constraint_storage_current_limit(pm::AbstractPowerModel, i::Int; nw::Int=nw_id_default)PowerModels.constraint_storage_complementarity_nl — Function
constraint_storage_complementarity_nl(pm::AbstractPowerModel, i::Int; nw::Int=nw_id_default)PowerModels.constraint_storage_complementarity_mi — Function
constraint_storage_complementarity_mi(pm::AbstractPowerModel, i::Int; nw::Int=nw_id_default)PowerModels.constraint_storage_losses — Function
Neglects the active and reactive loss terms associated with the squared current magnitude.
PowerModels.constraint_storage_state_initial — Function
constraint_storage_state_initial(pm::AbstractPowerModel, n::Int, i::Int, energy, charge_eff, discharge_eff, time_elapsed)PowerModels.constraint_storage_state — Function
constraint_storage_state(pm::AbstractPowerModel, i::Int; nw::Int=nw_id_default)DC Line Constraints
PowerModels.constraint_dcline_power_losses — Function
Creates Line Flow constraint for DC Lines (Matpower Formulation)
p_fr + p_to == loss0 + p_fr * loss1PowerModels.constraint_dcline_setpoint_active — Function
pf[i] == pf, pt[i] == pt
p_fr[i] == pref_fr, p_to[i] == pref_to
Switch Constraints
PowerModels.constraint_switch_state — Function
enforces static switch constraints
PowerModels.constraint_switch_on_off — Function
enforces controlable switch constraints
PowerModels.constraint_switch_thermal_limit — Function
enforces an mva limit on the power flow over a switch