Skip to content

Commit

Permalink
update to code for ts merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jtabarez committed Dec 5, 2024
1 parent f760dd6 commit 68a7bcb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
23 changes: 22 additions & 1 deletion src/core/objective.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
)

Expand Down Expand Up @@ -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
17 changes: 11 additions & 6 deletions src/form/wr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -206,31 +207,35 @@ 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)
==
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)
==
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
Expand Down

0 comments on commit 68a7bcb

Please sign in to comment.