5
5
setdata, setsolver, solve,
6
6
run_generic_model, build_generic_model, solve_generic_model,
7
7
ismultinetwork, nw_ids, nws,
8
- ismultiphase, phase_ids ,
8
+ ismulticonductor, conductor_ids ,
9
9
ids, ref, var, ext
10
10
11
11
@@ -52,7 +52,7 @@ mutable struct GenericPowerModel{T<:AbstractPowerFormulation}
52
52
var:: Dict{Symbol,Any} # JuMP variables
53
53
con:: Dict{Symbol,Any} # JuMP constraint references
54
54
cnw:: Int # current network index value
55
- cph :: Int # current phase index value
55
+ ccnd :: Int # current conductor index value
56
56
57
57
# Extension dictionary
58
58
# Extensions should define a type to hold information particular to
@@ -75,17 +75,17 @@ function GenericPowerModel(data::Dict{String,Any}, T::DataType; ext = Dict{Strin
75
75
nw_var = var[:nw ][nw_id] = Dict {Symbol,Any} ()
76
76
nw_con = con[:nw ][nw_id] = Dict {Symbol,Any} ()
77
77
78
- nw_var[:ph ] = Dict {Int,Any} ()
79
- nw_con[:ph ] = Dict {Int,Any} ()
78
+ nw_var[:cnd ] = Dict {Int,Any} ()
79
+ nw_con[:cnd ] = Dict {Int,Any} ()
80
80
81
- for ph_id in nw[:phase_ids ]
82
- nw_var[:ph ][ph_id ] = Dict {Symbol,Any} ()
83
- nw_con[:ph ][ph_id ] = Dict {Symbol,Any} ()
81
+ for cnd_id in nw[:conductor_ids ]
82
+ nw_var[:cnd ][cnd_id ] = Dict {Symbol,Any} ()
83
+ nw_con[:cnd ][cnd_id ] = Dict {Symbol,Any} ()
84
84
end
85
85
end
86
86
87
87
cnw = minimum ([k for k in keys (var[:nw ])])
88
- cph = minimum ([k for k in keys (var[:nw ][cnw][:ph ])])
88
+ ccnd = minimum ([k for k in keys (var[:nw ][cnw][:cnd ])])
89
89
90
90
pm = GenericPowerModel {T} (
91
91
Model (solver = solver), # model
@@ -96,22 +96,22 @@ function GenericPowerModel(data::Dict{String,Any}, T::DataType; ext = Dict{Strin
96
96
var,
97
97
con,
98
98
cnw,
99
- cph ,
99
+ ccnd ,
100
100
ext
101
101
)
102
102
103
103
return pm
104
104
end
105
105
106
- # ## Helper functions for working with multinetworks and multiphases
106
+ # ## Helper functions for working with multinetworks and multiconductors
107
107
ismultinetwork (pm:: GenericPowerModel ) = (length (pm. ref[:nw ]) > 1 )
108
108
nw_ids (pm:: GenericPowerModel ) = keys (pm. ref[:nw ])
109
109
nws (pm:: GenericPowerModel ) = pm. ref[:nw ]
110
110
111
- ismultiphase (pm:: GenericPowerModel , nw:: Int ) = haskey (pm. ref[:nw ][nw], :phases )
112
- ismultiphase (pm:: GenericPowerModel ; nw:: Int = pm. cnw) = haskey (pm. ref[:nw ][nw], :phases )
113
- phase_ids (pm:: GenericPowerModel , nw:: Int ) = pm. ref[:nw ][nw][:phase_ids ]
114
- phase_ids (pm:: GenericPowerModel ; nw:: Int = pm. cnw) = pm. ref[:nw ][nw][:phase_ids ]
111
+ ismulticonductor (pm:: GenericPowerModel , nw:: Int ) = haskey (pm. ref[:nw ][nw], :conductors )
112
+ ismulticonductor (pm:: GenericPowerModel ; nw:: Int = pm. cnw) = haskey (pm. ref[:nw ][nw], :conductors )
113
+ conductor_ids (pm:: GenericPowerModel , nw:: Int ) = pm. ref[:nw ][nw][:conductor_ids ]
114
+ conductor_ids (pm:: GenericPowerModel ; nw:: Int = pm. cnw) = pm. ref[:nw ][nw][:conductor_ids ]
115
115
116
116
117
117
ids (pm:: GenericPowerModel , nw:: Int , key:: Symbol ) = keys (pm. ref[:nw ][nw][key])
@@ -122,35 +122,35 @@ ref(pm::GenericPowerModel, nw::Int) = pm.ref[:nw][nw]
122
122
ref (pm:: GenericPowerModel , nw:: Int , key:: Symbol ) = pm. ref[:nw ][nw][key]
123
123
ref (pm:: GenericPowerModel , nw:: Int , key:: Symbol , idx) = pm. ref[:nw ][nw][key][idx]
124
124
ref (pm:: GenericPowerModel , nw:: Int , key:: Symbol , idx, param:: String ) = pm. ref[:nw ][nw][key][idx][param]
125
- ref (pm:: GenericPowerModel , nw:: Int , key:: Symbol , idx, param:: String , ph :: Int ) = pm. ref[:nw ][nw][key][idx][param][ph ]
125
+ ref (pm:: GenericPowerModel , nw:: Int , key:: Symbol , idx, param:: String , cnd :: Int ) = pm. ref[:nw ][nw][key][idx][param][cnd ]
126
126
127
127
ref (pm:: GenericPowerModel ; nw:: Int = pm. cnw) = pm. ref[:nw ][nw]
128
128
ref (pm:: GenericPowerModel , key:: Symbol ; nw:: Int = pm. cnw) = pm. ref[:nw ][nw][key]
129
129
ref (pm:: GenericPowerModel , key:: Symbol , idx; nw:: Int = pm. cnw) = pm. ref[:nw ][nw][key][idx]
130
- ref (pm:: GenericPowerModel , key:: Symbol , idx, param:: String ; nw:: Int = pm. cnw, ph :: Int = pm. cph ) = pm. ref[:nw ][nw][key][idx][param][ph ]
130
+ ref (pm:: GenericPowerModel , key:: Symbol , idx, param:: String ; nw:: Int = pm. cnw, cnd :: Int = pm. ccnd ) = pm. ref[:nw ][nw][key][idx][param][cnd ]
131
131
132
132
133
133
Base. var (pm:: GenericPowerModel , nw:: Int ) = pm. var[:nw ][nw]
134
134
Base. var (pm:: GenericPowerModel , nw:: Int , key:: Symbol ) = pm. var[:nw ][nw][key]
135
135
Base. var (pm:: GenericPowerModel , nw:: Int , key:: Symbol , idx) = pm. var[:nw ][nw][key][idx]
136
- Base. var (pm:: GenericPowerModel , nw:: Int , ph :: Int ) = pm. var[:nw ][nw][:ph ][ph ]
137
- Base. var (pm:: GenericPowerModel , nw:: Int , ph :: Int , key:: Symbol ) = pm. var[:nw ][nw][:ph ][ph ][key]
138
- Base. var (pm:: GenericPowerModel , nw:: Int , ph :: Int , key:: Symbol , idx) = pm. var[:nw ][nw][:ph ][ph ][key][idx]
136
+ Base. var (pm:: GenericPowerModel , nw:: Int , cnd :: Int ) = pm. var[:nw ][nw][:cnd ][cnd ]
137
+ Base. var (pm:: GenericPowerModel , nw:: Int , cnd :: Int , key:: Symbol ) = pm. var[:nw ][nw][:cnd ][cnd ][key]
138
+ Base. var (pm:: GenericPowerModel , nw:: Int , cnd :: Int , key:: Symbol , idx) = pm. var[:nw ][nw][:cnd ][cnd ][key][idx]
139
139
140
- Base. var (pm:: GenericPowerModel ; nw:: Int = pm. cnw, ph :: Int = pm. cph ) = pm. var[:nw ][nw][:ph ][ph ]
141
- Base. var (pm:: GenericPowerModel , key:: Symbol ; nw:: Int = pm. cnw, ph :: Int = pm. cph ) = pm. var[:nw ][nw][:ph ][ph ][key]
142
- Base. var (pm:: GenericPowerModel , key:: Symbol , idx; nw:: Int = pm. cnw, ph :: Int = pm. cph ) = pm. var[:nw ][nw][:ph ][ph ][key][idx]
140
+ Base. var (pm:: GenericPowerModel ; nw:: Int = pm. cnw, cnd :: Int = pm. ccnd ) = pm. var[:nw ][nw][:cnd ][cnd ]
141
+ Base. var (pm:: GenericPowerModel , key:: Symbol ; nw:: Int = pm. cnw, cnd :: Int = pm. ccnd ) = pm. var[:nw ][nw][:cnd ][cnd ][key]
142
+ Base. var (pm:: GenericPowerModel , key:: Symbol , idx; nw:: Int = pm. cnw, cnd :: Int = pm. ccnd ) = pm. var[:nw ][nw][:cnd ][cnd ][key][idx]
143
143
144
144
con (pm:: GenericPowerModel , nw:: Int ) = pm. con[:nw ][nw]
145
145
con (pm:: GenericPowerModel , nw:: Int , key:: Symbol ) = pm. con[:nw ][nw][key]
146
146
con (pm:: GenericPowerModel , nw:: Int , key:: Symbol , idx) = pm. con[:nw ][nw][key][idx]
147
- con (pm:: GenericPowerModel , nw:: Int , ph :: Int ) = pm. con[:nw ][nw][:ph ][ph ]
148
- con (pm:: GenericPowerModel , nw:: Int , ph :: Int , key:: Symbol ) = pm. con[:nw ][nw][:ph ][ph ][key]
149
- con (pm:: GenericPowerModel , nw:: Int , ph :: Int , key:: Symbol , idx) = pm. con[:nw ][nw][:ph ][ph ][key][idx]
147
+ con (pm:: GenericPowerModel , nw:: Int , cnd :: Int ) = pm. con[:nw ][nw][:cnd ][cnd ]
148
+ con (pm:: GenericPowerModel , nw:: Int , cnd :: Int , key:: Symbol ) = pm. con[:nw ][nw][:cnd ][cnd ][key]
149
+ con (pm:: GenericPowerModel , nw:: Int , cnd :: Int , key:: Symbol , idx) = pm. con[:nw ][nw][:cnd ][cnd ][key][idx]
150
150
151
- con (pm:: GenericPowerModel ; nw:: Int = pm. cnw, ph :: Int = pm. cph ) = pm. con[:nw ][nw][:ph ][ph ]
152
- con (pm:: GenericPowerModel , key:: Symbol ; nw:: Int = pm. cnw, ph :: Int = pm. cph ) = pm. con[:nw ][nw][:ph ][ph ][key]
153
- con (pm:: GenericPowerModel , key:: Symbol , idx; nw:: Int = pm. cnw, ph :: Int = pm. cph ) = pm. con[:nw ][nw][:ph ][ph ][key][idx]
151
+ con (pm:: GenericPowerModel ; nw:: Int = pm. cnw, cnd :: Int = pm. ccnd ) = pm. con[:nw ][nw][:cnd ][cnd ]
152
+ con (pm:: GenericPowerModel , key:: Symbol ; nw:: Int = pm. cnw, cnd :: Int = pm. ccnd ) = pm. con[:nw ][nw][:cnd ][cnd ][key]
153
+ con (pm:: GenericPowerModel , key:: Symbol , idx; nw:: Int = pm. cnw, cnd :: Int = pm. ccnd ) = pm. con[:nw ][nw][:cnd ][cnd ][key][idx]
154
154
155
155
156
156
@@ -193,16 +193,16 @@ function build_generic_model(file::String, model_constructor, post_method; kwar
193
193
end
194
194
195
195
" "
196
- function build_generic_model (data:: Dict{String,Any} , model_constructor, post_method; multinetwork= false , multiphase = false , kwargs... )
196
+ function build_generic_model (data:: Dict{String,Any} , model_constructor, post_method; multinetwork= false , multiconductor = false , kwargs... )
197
197
# NOTE, this model constructor will build the ref dict using the latest info from the data
198
198
pm = model_constructor (data; kwargs... )
199
199
200
200
if ! multinetwork && ismultinetwork (pm)
201
201
error (LOGGER, " attempted to build a single-network model with multi-network data" )
202
202
end
203
203
204
- if ! multiphase && ismultiphase (pm)
205
- error (LOGGER, " attempted to build a single-phase model with multi-phase data" )
204
+ if ! multiconductor && ismulticonductor (pm)
205
+ error (LOGGER, " attempted to build a single-conductor model with multi-conductor data" )
206
206
end
207
207
208
208
post_method (pm)
@@ -272,10 +272,10 @@ function build_ref(data::Dict{String,Any})
272
272
end
273
273
end
274
274
275
- if ! haskey (ref, :phases )
276
- ref[:phase_ids ] = 1 : 1
275
+ if ! haskey (ref, :conductors )
276
+ ref[:conductor_ids ] = 1 : 1
277
277
else
278
- ref[:phase_ids ] = 1 : ref[:phases ]
278
+ ref[:conductor_ids ] = 1 : ref[:conductors ]
279
279
end
280
280
281
281
# filter turned off stuff
@@ -367,7 +367,7 @@ function build_ref(data::Dict{String,Any})
367
367
368
368
ref[:ref_buses ] = ref_buses
369
369
370
- ref[:buspairs ] = buspair_parameters (ref[:arcs_from ], ref[:branch ], ref[:bus ], ref[:phase_ids ])
370
+ ref[:buspairs ] = buspair_parameters (ref[:arcs_from ], ref[:branch ], ref[:bus ], ref[:conductor_ids ])
371
371
372
372
off_angmin, off_angmax = calc_theta_delta_bounds (nw_data)
373
373
ref[:off_angmin ] = off_angmin
@@ -386,7 +386,7 @@ function build_ref(data::Dict{String,Any})
386
386
end
387
387
ref[:ne_bus_arcs ] = ne_bus_arcs
388
388
389
- ref[:ne_buspairs ] = buspair_parameters (ref[:ne_arcs_from ], ref[:ne_branch ], ref[:bus ], ref[:phase_ids ])
389
+ ref[:ne_buspairs ] = buspair_parameters (ref[:ne_arcs_from ], ref[:ne_branch ], ref[:bus ], ref[:conductor_ids ])
390
390
end
391
391
392
392
end
@@ -412,20 +412,20 @@ end
412
412
413
413
414
414
" compute bus pair level structures"
415
- function buspair_parameters (arcs_from, branches, buses, phase_ids )
415
+ function buspair_parameters (arcs_from, branches, buses, conductor_ids )
416
416
buspair_indexes = collect (Set ([(i,j) for (l,i,j) in arcs_from]))
417
417
418
- bp_angmin = Dict ([(bp, MultiPhaseVector ([- Inf for h in phase_ids ])) for bp in buspair_indexes])
419
- bp_angmax = Dict ([(bp, MultiPhaseVector ([ Inf for h in phase_ids ])) for bp in buspair_indexes])
418
+ bp_angmin = Dict ([(bp, MultiConductorVector ([- Inf for c in conductor_ids ])) for bp in buspair_indexes])
419
+ bp_angmax = Dict ([(bp, MultiConductorVector ([ Inf for c in conductor_ids ])) for bp in buspair_indexes])
420
420
bp_branch = Dict ([(bp, Inf ) for bp in buspair_indexes])
421
421
422
422
for (l,branch) in branches
423
423
i = branch[" f_bus" ]
424
424
j = branch[" t_bus" ]
425
425
426
- for h in phase_ids
427
- bp_angmin[(i,j)][h ] = max (bp_angmin[(i,j)][h ], branch[" angmin" ][h ])
428
- bp_angmax[(i,j)][h ] = min (bp_angmax[(i,j)][h ], branch[" angmax" ][h ])
426
+ for c in conductor_ids
427
+ bp_angmin[(i,j)][c ] = max (bp_angmin[(i,j)][c ], branch[" angmin" ][c ])
428
+ bp_angmax[(i,j)][c ] = min (bp_angmax[(i,j)][c ], branch[" angmax" ][c ])
429
429
end
430
430
bp_branch[(i,j)] = min (bp_branch[(i,j)], l)
431
431
end
0 commit comments