Skip to content

Commit

Permalink
FIX: stochastic version
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjospina committed Sep 16, 2024
1 parent db11a1d commit 1e3e0eb
Showing 1 changed file with 45 additions and 10 deletions.
55 changes: 45 additions & 10 deletions src/form_decomposition/acp_stochastic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,57 @@ function constraint_transmission_power_balance_stochastic(pm::_PM.AbstractACPMod
qbound_load = get(_PM.var(pm, n), :qbound_load, Dict()); _PM._check_var_keys(qbound_load, bus_arcs_boundary_from, "reactive power", "boundary")

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)
+ pbound_load[bus_arcs_boundary_from[1]][1]
==
sum(pg[g] for g in bus_gens)
- sum(ps[s] for s in bus_storage)
- sum(pd for (i,pd) in bus_pd)
- sum(gs for (i,gs) in bus_gs)*vm^2
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)
+ pbound_load[bus_arcs_boundary_from[end]][1]
==
sum(pg[g] for g in bus_gens)
- sum(ps[s] for s in bus_storage)
- sum(pd for (i,pd) in bus_pd)
- sum(gs for (i,gs) in bus_gs)*vm^2
)

cstr_q = JuMP.@constraint(pm.model,
sum(q[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)
+ qbound_load[bus_arcs_boundary_from[1]][1]
+ qbound_load[bus_arcs_boundary_from[end]][1]
==
sum(qg[g] for g in bus_gens)
- sum(qs[s] for s in bus_storage)
- sum(qd for (i,qd) in bus_qd)
+ sum(bs for (i,bs) in bus_bs)*vm^2
)

# for boundary in bus_arcs_boundary_from

# 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)
# + pbound_load[boundary][1]
# ==
# sum(pg[g] for g in bus_gens)
# - sum(ps[s] for s in bus_storage)
# - sum(pd for (i,pd) in bus_pd)
# - sum(gs for (i,gs) in bus_gs)*vm^2
# )

# cstr_q = JuMP.@constraint(pm.model,
# sum(q[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)
# + qbound_load[boundary][1]
# ==
# sum(qg[g] for g in bus_gens)
# - sum(qs[s] for s in bus_storage)
# - sum(qd for (i,qd) in bus_qd)
# + sum(bs for (i,bs) in bus_bs)*vm^2
# )

# 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 All @@ -80,14 +108,21 @@ function constraint_transmission_boundary_power_scaled_equalization_stochastic(p
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_org = _PM.var(pm, nw, :pbound_load, f_idx_org)
qbound_load_org = _PM.var(pm, nw, :qbound_load, 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)
pbound_load = _PM.var(pm, nw, :pbound_load, f_idx)
qbound_load = _PM.var(pm, nw, :qbound_load, 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])

JuMP.@constraint(pm.model, pbound_load[1] == pbound_load_org[1])
JuMP.@constraint(pm.model, qbound_load[1] == qbound_load_org[1])

end

0 comments on commit 1e3e0eb

Please sign in to comment.