Skip to content

Commit f937b80

Browse files
committed
giving network expansion variables _ne names
1 parent 9ac67b6 commit f937b80

File tree

4 files changed

+263
-333
lines changed

4 files changed

+263
-333
lines changed

src/core/base.jl

+19-14
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,35 @@ type GenericPowerModel{T<:AbstractPowerFormulation} <: AbstractPowerModel
4040
end
4141

4242
# default generic constructor
43-
function GenericPowerModel{T}(data::Dict{AbstractString,Any}, vars::T; setting = Dict{AbstractString,Any}(), solver = JuMP.UnsetSolver())
44-
data, sets = process_raw_data(data)
43+
function GenericPowerModel{T}(data::Dict{AbstractString,Any}, vars::T; setting = Dict{AbstractString,Any}(), solver = JuMP.UnsetSolver(), data_processor = process_raw_mp_data)
44+
data, sets, ext = data_processor(data)
4545
pm = GenericPowerModel{T}(
4646
Model(solver = solver), # model
4747
data, # data
4848
sets, # sets
4949
setting, # setting
5050
Dict{AbstractString,Any}(), # solution
51-
Dict{Symbol,Any}() # ext
51+
ext # ext
5252
)
5353

5454
return pm
5555
end
5656

57-
function process_raw_data(data::Dict{AbstractString,Any})
57+
function process_raw_mp_data(data::Dict{AbstractString,Any})
5858
make_per_unit(data)
59-
unify_transformer_taps(data)
60-
add_branch_parameters(data)
59+
60+
min_theta_delta = calc_min_phase_angle(data)
61+
max_theta_delta = calc_max_phase_angle(data)
62+
63+
unify_transformer_taps(data["branch"])
64+
add_branch_parameters(data["branch"], min_theta_delta, max_theta_delta)
65+
6166
standardize_cost_order(data)
6267
sets = build_sets(data)
63-
return data, sets
68+
69+
ext = Dict{Symbol,Any}()
70+
71+
return data, sets, ext
6472
end
6573

6674
#
@@ -235,20 +243,17 @@ function make_per_unit(mva_base::Number, data::Number)
235243
#println("$(parent) $(data)")
236244
end
237245

238-
function unify_transformer_taps(data::Dict{AbstractString,Any})
239-
for branch in data["branch"]
246+
function unify_transformer_taps(branches)
247+
for branch in branches
240248
if branch["tap"] == 0.0
241249
branch["tap"] = 1.0
242250
end
243251
end
244252
end
245253

246254
# NOTE, this function assumes all values are p.u. and angles are in radians
247-
function add_branch_parameters(data::Dict{AbstractString,Any})
248-
min_theta_delta = calc_min_phase_angle(data)
249-
max_theta_delta = calc_max_phase_angle(data)
250-
251-
for branch in data["branch"]
255+
function add_branch_parameters(branches, min_theta_delta, max_theta_delta)
256+
for branch in branches
252257
r = branch["br_r"]
253258
x = branch["br_x"]
254259
tap_ratio = branch["tap"]

src/core/variable.jl

+4-7
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ function variable_reactive_line_flow{T}(pm::GenericPowerModel{T}; bounded = true
8989
return q
9090
end
9191

92-
function compute_voltage_product_bounds{T}(pm::GenericPowerModel{T})
93-
buspairs = pm.set.buspairs
94-
buspair_indexes = pm.set.buspair_indexes
95-
92+
function compute_voltage_product_bounds(buspairs, buspair_indexes)
9693
wr_min = Dict([(bp, -Inf) for bp in buspair_indexes])
9794
wr_max = Dict([(bp, Inf) for bp in buspair_indexes])
9895
wi_min = Dict([(bp, -Inf) for bp in buspair_indexes])
@@ -126,7 +123,7 @@ end
126123

127124
function variable_complex_voltage_product{T}(pm::GenericPowerModel{T}; bounded = true)
128125
if bounded
129-
wr_min, wr_max, wi_min, wi_max = compute_voltage_product_bounds(pm)
126+
wr_min, wr_max, wi_min, wi_max = compute_voltage_product_bounds(pm.set.buspairs, pm.set.buspair_indexes)
130127

131128
@variable(pm.model, wr_min[bp] <= wr[bp in pm.set.buspair_indexes] <= wr_max[bp], start = getstart(pm.set.buspairs, bp, "wr_start", 1.0))
132129
@variable(pm.model, wi_min[bp] <= wi[bp in pm.set.buspair_indexes] <= wi_max[bp], start = getstart(pm.set.buspairs, bp, "wi_start"))
@@ -138,7 +135,7 @@ function variable_complex_voltage_product{T}(pm::GenericPowerModel{T}; bounded =
138135
end
139136

140137
function variable_complex_voltage_product_on_off{T}(pm::GenericPowerModel{T})
141-
wr_min, wr_max, wi_min, wi_max = compute_voltage_product_bounds(pm)
138+
wr_min, wr_max, wi_min, wi_max = compute_voltage_product_bounds(pm.set.buspairs, pm.set.buspair_indexes)
142139

143140
bi_bp = Dict([(i, (b["f_bus"], b["t_bus"])) for (i,b) in pm.set.branches])
144141

@@ -149,7 +146,7 @@ function variable_complex_voltage_product_on_off{T}(pm::GenericPowerModel{T})
149146
end
150147

151148
function variable_complex_voltage_product_matrix{T}(pm::GenericPowerModel{T})
152-
wr_min, wr_max, wi_min, wi_max = compute_voltage_product_bounds(pm)
149+
wr_min, wr_max, wi_min, wi_max = compute_voltage_product_bounds(pm.set.buspairs, pm.set.buspair_indexes)
153150

154151
w_index = 1:length(pm.set.bus_indexes)
155152
lookup_w_index = Dict([(bi, i) for (i,bi) in enumerate(pm.set.bus_indexes)])

src/form/wr.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ function constraint_voltage_magnitude_sqr_to_on_off{T}(pm::GenericPowerModel{T})
224224
end
225225

226226
function constraint_complex_voltage_product_on_off{T}(pm::GenericPowerModel{T})
227-
wr_min, wr_max, wi_min, wi_max = compute_voltage_product_bounds(pm)
227+
wr_min, wr_max, wi_min, wi_max = compute_voltage_product_bounds(pm.set.buspairs, pm.set.buspair_indexes)
228228

229229
bi_bp = Dict([(i, (b["f_bus"], b["t_bus"])) for (i,b) in pm.set.branches])
230230

0 commit comments

Comments
 (0)