Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PowerModels.jl Change Log
### Staged
- Made case name recovery optional in PTI parsing
- Fixed Julia deprecation warning when calling sort on Dict
- Change `Int64` types to `Int`

### v0.19.1
- Add support for Memento v1.3
Expand Down
16 changes: 8 additions & 8 deletions src/core/admittance_matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ function calc_admittance_matrix(data::Dict{String,<:Any})
idx_to_bus = [x["index"] for x in buses]
bus_to_idx = Dict(x["index"] => i for (i,x) in enumerate(buses))

I = Int64[]
J = Int64[]
I = Int[]
J = Int[]
V = Complex{Float64}[]

for (i,branch) in data["branch"]
Expand Down Expand Up @@ -94,8 +94,8 @@ function calc_susceptance_matrix(data::Dict{String,<:Any})
bus_type = [x["bus_type"] for x in buses]
bus_to_idx = Dict(x["index"] => i for (i,x) in enumerate(buses))

I = Int64[]
J = Int64[]
I = Int[]
J = Int[]
V = Float64[]

for (i,branch) in data["branch"]
Expand Down Expand Up @@ -158,7 +158,7 @@ function calc_admittance_matrix_inv(am::AdmittanceMatrix, ref_idx::Int)

M = Matrix(am.matrix)

nonref_buses = Int64[i for i in 1:num_buses if i != ref_idx]
nonref_buses = Int[i for i in 1:num_buses if i != ref_idx]
am_inv = zeros(Float64, num_buses, num_buses)
am_inv[nonref_buses, nonref_buses] = inv(M[nonref_buses, nonref_buses])

Expand Down Expand Up @@ -201,7 +201,7 @@ function injection_factors_va(am::AdmittanceMatrix{T}, ref_bus::Int, bus_id::Int

# need to remap the indexes to omit the ref_bus id
# a reverse lookup is also required
idx2_to_idx1 = Int64[]
idx2_to_idx1 = Int[]
for i in 1:length(am.idx_to_bus)
if i != ref_idx
push!(idx2_to_idx1, i)
Expand All @@ -210,8 +210,8 @@ function injection_factors_va(am::AdmittanceMatrix{T}, ref_bus::Int, bus_id::Int
idx1_to_idx2 = Dict(v => i for (i,v) in enumerate(idx2_to_idx1))

# rebuild the sparse version of the AdmittanceMatrix without the reference bus
I = Int64[]
J = Int64[]
I = Int[]
J = Int[]
V = Float64[]

I_src, J_src, V_src = findnz(am.matrix)
Expand Down
2 changes: 1 addition & 1 deletion src/core/constraint_template.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ end
function constraint_network_power_balance(pm::AbstractPowerModel, i::Int; nw::Int=nw_id_default)
comp_bus_ids = ref(pm, nw, :components, i)

comp_gen_ids = Set{Int64}()
comp_gen_ids = Set{Int}()
for bus_id in comp_bus_ids, gen_id in PowerModels.ref(pm, nw, :bus_gens, bus_id)
push!(comp_gen_ids, gen_id)
end
Expand Down
4 changes: 2 additions & 2 deletions src/core/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2652,7 +2652,7 @@ function calc_connected_components(data::Dict{String,<:Any}; edges=["branch", "d
end

active_bus = Dict(x for x in pm_data["bus"] if x.second["bus_type"] != 4)
active_bus_ids = Set{Int64}([bus["bus_i"] for (i,bus) in active_bus])
active_bus_ids = Set{Int}([bus["bus_i"] for (i,bus) in active_bus])

neighbors = Dict(i => Int[] for i in active_bus_ids)
for comp_type in edges
Expand All @@ -2667,7 +2667,7 @@ function calc_connected_components(data::Dict{String,<:Any}; edges=["branch", "d
end

component_lookup = Dict(i => Set{Int}([i]) for i in active_bus_ids)
touched = Set{Int64}()
touched = Set{Int}()

for i in active_bus_ids
if !(i in touched)
Expand Down
14 changes: 7 additions & 7 deletions src/core/data_basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ function calc_basic_incidence_matrix(data::Dict{String,<:Any})
Memento.warn(_LOGGER, "calc_basic_incidence_matrix requires basic network data and given data may be incompatible. make_basic_network can be used to transform data into the appropriate form.")
end

I = Int64[]
J = Int64[]
V = Int64[]
I = Int[]
J = Int[]
V = Int[]

b = [branch for (i,branch) in data["branch"] if branch["br_status"] != 0]
branch_ordered = sort(b, by=(x) -> x["index"])
Expand Down Expand Up @@ -274,8 +274,8 @@ function calc_basic_branch_susceptance_matrix(data::Dict{String,<:Any})
Memento.warn(_LOGGER, "calc_basic_branch_susceptance_matrix requires basic network data and given data may be incompatible. make_basic_network can be used to transform data into the appropriate form.")
end

I = Int64[]
J = Int64[]
I = Int[]
J = Int[]
V = Float64[]

b = [branch for (i,branch) in data["branch"] if branch["br_status"] != 0]
Expand Down Expand Up @@ -406,8 +406,8 @@ function calc_basic_jacobian_matrix(data::Dict{String,<:Any})
push!(neighbors[I[nz]], J[nz])
push!(neighbors[J[nz]], I[nz])
end
J0_I = Int64[]
J0_J = Int64[]
J0_I = Int[]
J0_J = Int[]
J0_V = Float64[]
for i in 1:num_bus
f_i_r = i
Expand Down
2 changes: 1 addition & 1 deletion src/core/objective.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
################################################################################

# enables support for v[1]
Base.getindex(v::JuMP.VariableRef, i::Int64) = v
Base.getindex(v::JuMP.VariableRef, i::Int) = v


"""
Expand Down
2 changes: 1 addition & 1 deletion src/core/ref.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function calc_buspair_parameters(buses, branches, conductor_ids, ismulticondcuto

buspair_indexes = Set((branch["f_bus"], branch["t_bus"]) for (i,branch) in branch_lookup)

bp_branch = Dict((bp, typemax(Int64)) for bp in buspair_indexes)
bp_branch = Dict((bp, typemax(Int)) for bp in buspair_indexes)

if ismulticondcutor
bp_angmin = Dict((bp, [-Inf for c in conductor_ids]) for bp in buspair_indexes)
Expand Down
8 changes: 4 additions & 4 deletions src/form/wrm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ end

struct _SDconstraintDecomposition
"Each sub-vector consists of bus IDs corresponding to a clique grouping"
decomp::Vector{Vector{Int64}}
decomp::Vector{Vector{Int}}
"`lookup_index[bus_id] --> idx` for mapping between 1:n and bus indices"
lookup_index::Dict
"A chordal extension and maximal cliques are uniquely determined by a graph ordering"
ordering::Vector{Int64}
ordering::Vector{Int}
end
import Base: ==
function ==(d1::_SDconstraintDecomposition, d2::_SDconstraintDecomposition)
Expand Down Expand Up @@ -396,7 +396,7 @@ function _prim(A, minweight=false)
candidate_edges = []
unvisited = collect(1:n)
next_node = 1 # convention
T = spzeros(Int64, n, n)
T = spzeros(Int, n, n)

while length(unvisited) > 1
current_node = next_node
Expand Down Expand Up @@ -479,5 +479,5 @@ computes the change in problem size for a proposed group merge.
function _problem_size(groups)
nvars(n::Integer) = n*(2*n + 1)
A = _prim(_overlap_graph(groups))
return sum(nvars.(Int64.(nonzeros(A)))) + sum(nvars.(length.(groups)))
return sum(nvars.(Int.(nonzeros(A)))) + sum(nvars.(length.(groups)))
end
Loading