From db11a1ddc4c265f93282ab01022d1a2f3aad8030 Mon Sep 17 00:00:00 2001 From: jjospina Date: Mon, 16 Sep 2024 10:29:32 -0600 Subject: [PATCH] REF: stochastic formulation to get the same power on all versions. --- src/core/base.jl | 8 +++---- src/form_decomposition/acp_stochastic.jl | 23 +++++++++++++++++++++ src/prob/opfitd_decomposition_stochastic.jl | 1 + 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/core/base.jl b/src/core/base.jl index bae9287..9cd9ad8 100755 --- a/src/core/base.jl +++ b/src/core/base.jl @@ -359,8 +359,8 @@ function instantiate_model_decomposition( master_boundary_vars_vector = Vector{Vector{Vector{JuMP.VariableRef}}}(undef, number_of_subproblems) # Threaded loop for instantiating subproblems - Threads.@threads for i in 1:1:number_of_subproblems # faster but causes +RAM usage - # for i in 1:1:number_of_subproblems + # Threads.@threads for i in 1:1:number_of_subproblems # faster but causes +RAM usage + for i in 1:1:number_of_subproblems ckt_name = ckts_names_vector[i] ckt_data = ckts_data_vector[i] @@ -492,8 +492,8 @@ function instantiate_model_decomposition( boundary_vars_vector = Vector{Vector{Vector{JuMP.VariableRef}}}(undef, number_of_subproblems) # Threaded loop for instantiating subproblems - Threads.@threads for i in 1:1:number_of_subproblems # faster but causes +RAM usage - # for i in 1:number_of_subproblems + # Threads.@threads for i in 1:1:number_of_subproblems # faster but causes +RAM usage + for i in 1:number_of_subproblems ckt_name = ckts_names_vector[i] ckt_data = ckts_data_vector[i] diff --git a/src/form_decomposition/acp_stochastic.jl b/src/form_decomposition/acp_stochastic.jl index 1ed559f..75b90e4 100644 --- a/src/form_decomposition/acp_stochastic.jl +++ b/src/form_decomposition/acp_stochastic.jl @@ -68,3 +68,26 @@ function constraint_transmission_power_balance_stochastic(pm::_PM.AbstractACPMod end end + + +function constraint_transmission_boundary_power_scaled_equalization_stochastic(pm::_PM.AbstractACPModel, i::Int; nw::Int=nw_id_default) + + boundary = _PM.ref(pm, nw, :boundary, i) + f_bus = boundary["f_bus"] # convention: from bus Transmission always! + t_bus = boundary["t_bus"] # convention: to bus Distribution always! + + # Original (1st real connection to transmission) + f_idx_org = (100001, f_bus, t_bus) + pbound_load_scaled_org = _PM.var(pm, nw, :pbound_load_scaled, f_idx_org) + qbound_load_scaled_org = _PM.var(pm, nw, :qbound_load_scaled, f_idx_org) + + # Pbound_load vars + f_idx = (i, f_bus, t_bus) + pbound_load_scaled = _PM.var(pm, nw, :pbound_load_scaled, f_idx) + qbound_load_scaled = _PM.var(pm, nw, :qbound_load_scaled, f_idx) + + # Add scaling constraint + JuMP.@constraint(pm.model, pbound_load_scaled[1] == pbound_load_scaled_org[1]) + JuMP.@constraint(pm.model, qbound_load_scaled[1] == qbound_load_scaled_org[1]) + +end diff --git a/src/prob/opfitd_decomposition_stochastic.jl b/src/prob/opfitd_decomposition_stochastic.jl index 3f3e60b..8637a9d 100755 --- a/src/prob/opfitd_decomposition_stochastic.jl +++ b/src/prob/opfitd_decomposition_stochastic.jl @@ -88,6 +88,7 @@ function build_opfitd_decomposition_stochastic(pm_model::_PM.AbstractPowerModel) # Boundary constraints for i in _PM.ids(pm_model, :boundary) constraint_transmission_boundary_power_shared_vars_scaled(pm_model, i) + constraint_transmission_boundary_power_scaled_equalization_stochastic(pm_model, i) end # PM cost function