From 68a7bcb3dad48bb4cc32b1a8b8f7585cf61a5e89 Mon Sep 17 00:00:00 2001 From: Jose Date: Thu, 5 Dec 2024 09:15:58 -0700 Subject: [PATCH] update to code for ts merge --- src/core/objective.jl | 23 ++++++++++++++++++++++- src/form/wr.jl | 17 +++++++++++------ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/core/objective.jl b/src/core/objective.jl index 6538281..cf10cbc 100644 --- a/src/core/objective.jl +++ b/src/core/objective.jl @@ -9,7 +9,7 @@ function objective_blocker_placement_cost(pm::_PM.AbstractPowerModel) return JuMP.@objective(pm.model, Min, sum( - sum( blocker["multiplier"]*blocker["construction_cost"]*_PM.var(pm, n, :z_blocker, i) for (i,blocker) in nw_ref[:gmd_ne_blocker] ) + sum(blocker["multiplier"]*blocker["construction_cost"]*_PM.var(pm, n, :z_blocker, i) for (i,blocker) in nw_ref[:gmd_ne_blocker] ) for (n, nw_ref) in _PM.nws(pm)) ) @@ -45,4 +45,25 @@ function objective_bound_gmd_bus_v(pm::_PM.AbstractPowerModel, nw::Int=nw_id_def for (n, nw_ref) in _PM.nws(pm)) ) end +end + + +function objective_max_loadability(pm::_PM.AbstractPowerModel) + nws = _PM.nw_ids(pm) + + z_demand = Dict(n => _PM.var(pm, n, :z_demand) for n in nws) + z_shunt = Dict(n => _PM.var(pm, n, :z_shunt) for n in nws) + time_elapsed = Dict(n => get(_PM.ref(pm, n), :time_elapsed, 1) for n in nws) + + total_load = sum(sqrt(load["pd"]^2+load["qd"]^2) for (i,load) in _PM.ref(pm, 0, :load)) + + return JuMP.@objective(pm.model, Max, + sum( + ( + time_elapsed[n]*( + sum(z_demand[n][i]*sqrt(load["pd"]^2+load["qd"]^2) for (i,load) in _PM.ref(pm, n, :load))/total_load + ) + ) + for n in nws) + ) end \ No newline at end of file diff --git a/src/form/wr.jl b/src/form/wr.jl index 540d8ab..74d187c 100644 --- a/src/form/wr.jl +++ b/src/form/wr.jl @@ -185,6 +185,7 @@ function constraint_power_balance_gmd_shunt_ls(pm::_PM.AbstractWRModel, n::Int, z_demand = get(_PM.var(pm, n), :z_demand, Dict()); _PM._check_var_keys(z_demand, keys(bus_pd), "power factor", "load") z_shunt = get(_PM.var(pm, n), :z_shunt, Dict()); _PM._check_var_keys(z_shunt, keys(bus_gs), "power factor", "shunt") + wz_shunt = get(_PM.var(pm, n), :wz_shunt, Dict()); _PM._check_var_keys(wz_shunt, keys(bus_gs), "voltage square power factor scale", "shunt") # this is required for improved performance in NLP models if length(z_shunt) <= 0 @@ -196,7 +197,7 @@ function constraint_power_balance_gmd_shunt_ls(pm::_PM.AbstractWRModel, n::Int, sum(pg[g] for g in bus_gens) - sum(ps[s] for s in bus_storage) - sum(pd * z_demand[i] for (i,pd) in bus_pd) - - sum(gs * z_shunt[i] for (i,gs) in bus_gs) * w + - sum(gs * wz_shunt[i] for (i,gs) in bus_gs) ) cstr_q = JuMP.@constraint(pm.model, sum(q[a] + qloss[a] for a in bus_arcs) @@ -206,10 +207,10 @@ function constraint_power_balance_gmd_shunt_ls(pm::_PM.AbstractWRModel, n::Int, sum(qg[g] for g in bus_gens) - sum(qs[s] for s in bus_storage) - sum(qd * z_demand[i] for (i,qd) in bus_qd) - + sum(bs * z_shunt[i] for (i,bs) in bus_bs) * w + + sum(bs * wz_shunt[i] for (i,bs) in bus_bs) ) else - cstr_p = JuMP.@NLconstraint(pm.model, + cstr_p = JuMP.@constraint(pm.model, sum(p[a] for a in bus_arcs) + sum(p_dc[a_dc] for a_dc in bus_arcs_dc) + sum(psw[a_sw] for a_sw in bus_arcs_sw) @@ -217,9 +218,9 @@ function constraint_power_balance_gmd_shunt_ls(pm::_PM.AbstractWRModel, n::Int, sum(pg[g] for g in bus_gens) - sum(ps[s] for s in bus_storage) - sum(pd * z_demand[i] for (i,pd) in bus_pd) - - sum(gs * z_shunt[i] for (i,gs) in bus_gs) * w + - sum(gs * wz_shunt[i] for (i,gs) in bus_gs) ) - cstr_q = JuMP.@NLconstraint(pm.model, + cstr_q = JuMP.@constraint(pm.model, sum(q[a] + qloss[a] for a in bus_arcs) + sum(q_dc[a_dc] for a_dc in bus_arcs_dc) + sum(qsw[a_sw] for a_sw in bus_arcs_sw) @@ -227,10 +228,14 @@ function constraint_power_balance_gmd_shunt_ls(pm::_PM.AbstractWRModel, n::Int, sum(qg[g] for g in bus_gens) - sum(qs[s] for s in bus_storage) - sum(qd * z_demand[i] for (i,qd) in bus_qd) - + sum(bs * z_shunt[i] for (i,bs) in bus_bs) * w + + sum(bs * wz_shunt[i] for (i,bs) in bus_bs) ) end + for s in keys(bus_gs) + _IM.relaxation_product(pm.model, w, z_shunt[s], wz_shunt[s]) + end + if _IM.report_duals(pm) _PM.sol(pm, n, :bus, i)[:lam_kcl_r] = cstr_p _PM.sol(pm, n, :bus, i)[:lam_kcl_i] = cstr_q