Skip to content

Commit

Permalink
Merge pull request #78 from Electa-Git/prepare_release
Browse files Browse the repository at this point in the history
Prepare release
  • Loading branch information
hakanergun authored Dec 7, 2022
2 parents 340aa3f + f181d08 commit 4b0690c
Show file tree
Hide file tree
Showing 24 changed files with 861 additions and 598 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
fail-fast: false
matrix:
version:
- '1.5'
- '1.8'
- '1.6'
- '1'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
Expand Down
21 changes: 10 additions & 11 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "PowerModelsACDC"
uuid = "ff45984e-d068-5f4c-9e32-c4133509d236"
autors = ["Hakan Ergun", "Frederik Geth", "Jay Dave"]
repo = "https://github.com/Electa-Git/PowerModelsACDC.jl"
version = "0.5.3"
version = "0.6.0"

[deps]
InfrastructureModels = "2030c09a-7f63-5d83-885d-db604e0e9cc0"
Expand All @@ -11,22 +11,21 @@ Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9"
PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655"

[compat]
Cbc = ">= 0.9"
HiGHS = "~0.3, ~1"
InfrastructureModels = "~0.6, ~0.7"
Ipopt = ">= 0.8"
JuMP = "~0.22.0"
Juniper = ">= 0.8"
Memento = "~1.0, ~1.1, ~1.2, ~1.3"
PowerModels = "0.19.1"
SCS = ">= 0.8"
julia = "^1"
Ipopt = "~0.8, ~0.9, 1"
JuMP = "~0.22.0, ~0.23, ~1"
Juniper = "~0.8, ~0.9"
Memento = "~1.0, ~1.1, ~1.2, ~1.3, ~1.4"
PowerModels = "~0.19"
julia = "~1.6, ~1.7, ~1.8"

[extras]
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
Juniper = "2ddba703-00a4-53a7-87a5-e8b9971dde84"
SCS = "c946c3f1-0d1f-5ce8-9dea-7daa1f7e2d13"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Ipopt", "SCS", "Cbc", "Juniper"]
test = ["Test", "Ipopt", "HiGHS", "Juniper"]
4 changes: 0 additions & 4 deletions src/PowerModelsACDC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@ include("prob/acdcpf.jl")
include("prob/acdcopf_bf.jl")
include("prob/acdcopf_iv.jl")
include("prob/tnepopf.jl")
include("prob/acdctnepopf.jl")
include("prob/tnepopf_bf.jl")
include("prob/acdctnepopf_bf.jl")
include("prob/mp_tnepopf.jl")
include("prob/mp_acdctnepopf.jl")
include("prob/mp_tnepopf_bf.jl")
include("prob/mp_acdctnepopf_bf.jl")



Expand Down
144 changes: 79 additions & 65 deletions src/core/base.jl
Original file line number Diff line number Diff line change
@@ -1,35 +1,46 @@
function add_ref_dcgrid!(ref::Dict{Symbol,<:Any}, data::Dict{String,<:Any})
for (n, nw_ref) in ref[:it][:pm][:nw]
if haskey(nw_ref, :convdc)
#Filter converters & DC branches with status 0 as well as wrong bus numbers
nw_ref[:convdc] = Dict([x for x in nw_ref[:convdc] if (x.second["status"] == 1 && x.second["busdc_i"] in keys(nw_ref[:busdc]) && x.second["busac_i"] in keys(nw_ref[:bus]))])
if haskey(nw_ref, :branchdc)
nw_ref[:branchdc] = Dict([x for x in nw_ref[:branchdc] if (x.second["status"] == 1 && x.second["fbusdc"] in keys(nw_ref[:busdc]) && x.second["tbusdc"] in keys(nw_ref[:busdc]))])

# DC grid arcs for DC grid branches
nw_ref[:arcs_dcgrid_from] = [(i,branch["fbusdc"],branch["tbusdc"]) for (i,branch) in nw_ref[:branchdc]]
nw_ref[:arcs_dcgrid_to] = [(i,branch["tbusdc"],branch["fbusdc"]) for (i,branch) in nw_ref[:branchdc]]
nw_ref[:arcs_dcgrid] = [nw_ref[:arcs_dcgrid_from]; nw_ref[:arcs_dcgrid_to]]
nw_ref[:arcs_conv_acdc] = [(i,conv["busac_i"],conv["busdc_i"]) for (i,conv) in nw_ref[:convdc]]
#bus arcs of the DC grid
bus_arcs_dcgrid = Dict([(bus["busdc_i"], []) for (i,bus) in nw_ref[:busdc]])
for (l,i,j) in nw_ref[:arcs_dcgrid]
push!(bus_arcs_dcgrid[i], (l,i,j))
end
nw_ref[:bus_arcs_dcgrid] = bus_arcs_dcgrid
else
nw_ref[:branchdc] = Dict{String, Any}()
nw_ref[:arcs_dcgrid] = Dict{String, Any}()
nw_ref[:arcs_dcgrid_from] = Dict{String, Any}()
nw_ref[:arcs_dcgrid_to] = Dict{String, Any}()
nw_ref[:arcs_conv_acdc] = Dict{String, Any}()
if haskey(nw_ref, :busdc)
nw_ref[:bus_arcs_dcgrid] = Dict([(bus["busdc_i"], []) for (i,bus) in nw_ref[:busdc]])
else
nw_ref[:bus_arcs_dcgrid] = Dict{String, Any}()
end

end
if haskey(nw_ref, :convdc)
#Filter converters & DC branches with status 0 as well as wrong bus numbers
nw_ref[:convdc] = Dict([x for x in nw_ref[:convdc] if (x.second["status"] == 1 && x.second["busdc_i"] in keys(nw_ref[:busdc]) && x.second["busac_i"] in keys(nw_ref[:bus]))])

nw_ref[:arcs_conv_acdc] = [(i,conv["busac_i"],conv["busdc_i"]) for (i,conv) in nw_ref[:convdc]]

# bus_convs for AC side power injection of DC converters

# Bus converters for existing ac buses
bus_convs_ac = Dict([(i, []) for (i,bus) in nw_ref[:bus]])
for (i,conv) in nw_ref[:convdc]
push!(bus_convs_ac[conv["busac_i"]], i)
end
nw_ref[:bus_convs_ac] = bus_convs_ac
nw_ref[:bus_convs_ac] = assign_bus_converters!(nw_ref[:convdc], bus_convs_ac, "busac_i")

# bus_convs for AC side power injection of DC converters
# Bus converters for existing ac buses
bus_convs_dc = Dict([(bus["busdc_i"], []) for (i,bus) in nw_ref[:busdc]])
for (i,conv) in nw_ref[:convdc]
push!(bus_convs_dc[conv["busdc_i"]], i)
end
nw_ref[:bus_convs_dc] = bus_convs_dc
nw_ref[:bus_convs_dc]= assign_bus_converters!(nw_ref[:convdc], bus_convs_dc, "busdc_i")


# Add DC reference buses
ref_buses_dc = Dict{String, Any}()
for (k,v) in nw_ref[:convdc]
Expand Down Expand Up @@ -75,21 +86,12 @@ function add_ref_dcgrid!(ref::Dict{Symbol,<:Any}, data::Dict{String,<:Any})
else
nw_ref[:convdc] = Dict{String, Any}()
nw_ref[:busdc] = Dict{String, Any}()
nw_ref[:branchdc] = Dict{String, Any}()
# DC grid arcs for DC grid branches
nw_ref[:arcs_dcgrid] = Dict{String, Any}()
nw_ref[:arcs_dcgrid_from] = Dict{String, Any}()
nw_ref[:arcs_dcgrid_to] = Dict{String, Any}()
nw_ref[:arcs_conv_acdc] = Dict{String, Any}()
nw_ref[:bus_arcs_dcgrid] = Dict{String, Any}()
bus_convs_ac = Dict([(i, []) for (i,bus) in nw_ref[:bus]])
for (i,conv) in nw_ref[:convdc]
push!(bus_convs_ac[conv["busac_i"]], i)
end
nw_ref[:bus_convs_ac] = bus_convs_ac
nw_ref[:bus_convs_dc] = Dict{String, Any}()
nw_ref[:ref_buses_dc] = Dict{String, Any}()
nw_ref[:buspairsdc] = Dict{String, Any}()
# Bus converters for existing ac buses
bus_convs_ac = Dict([(i, []) for (i,bus) in nw_ref[:bus]])
nw_ref[:bus_convs_ac] = assign_bus_converters!(nw_ref[:convdc], bus_convs_ac, "busac_i")
end
end
end
Expand Down Expand Up @@ -188,12 +190,16 @@ end

function add_candidate_dcgrid!(ref::Dict{Symbol,<:Any}, data::Dict{String,<:Any})
for (n, nw_ref) in ref[:it][:pm][:nw]
if haskey(nw_ref, :convdc_ne)
if !haskey(nw_ref, :busdc_ne)
nw_ref[:busdc_ne] = Dict{String, Any}()
nw_ref[:ref_buses_dc_ne] = Dict{String, Any}()
else
nw_ref[:ref_buses_dc_ne] = Dict{String, Any}()
end
if haskey(nw_ref, :branchdc_ne)
nw_ref[:arcs_dcgrid_from_ne] = [(i,branch["fbusdc"],branch["tbusdc"]) for (i,branch) in nw_ref[:branchdc_ne]]
nw_ref[:arcs_dcgrid_to_ne] = [(i,branch["tbusdc"],branch["fbusdc"]) for (i,branch) in nw_ref[:branchdc_ne]]
nw_ref[:arcs_dcgrid_ne] = [nw_ref[:arcs_dcgrid_from_ne]; nw_ref[:arcs_dcgrid_to_ne]]
nw_ref[:arcs_conv_acdc_ne] = [(i,conv["busac_i"],conv["busdc_i"]) for (i,conv) in nw_ref[:convdc_ne]]
nw_ref[:arcs_conv_acdc_acbus_ne] = [(i,conv["busac_i"]) for (i,conv) in nw_ref[:convdc_ne]]
#bus arcs of the DC grid
bus_arcs_dcgrid_ne = Dict([(bus["busdc_i"], []) for (i,bus) in nw_ref[:busdc_ne]])
for (l,i,j) in nw_ref[:arcs_dcgrid_ne]
Expand All @@ -207,48 +213,46 @@ function add_candidate_dcgrid!(ref::Dict{Symbol,<:Any}, data::Dict{String,<:Any}
end
end
nw_ref[:bus_arcs_dcgrid_ne] = bus_arcs_dcgrid_ne
# bus_convs for AC side power injection of DC converters
bus_convs_ac = Dict([(i, []) for (i,bus) in nw_ref[:bus]])
for (i,conv) in nw_ref[:convdc_ne]
push!(bus_convs_ac[conv["busac_i"]], i)
nw_ref[:buspairsdc_ne] = buspair_parameters_dc_ne(nw_ref[:arcs_dcgrid_from_ne], nw_ref[:branchdc_ne], nw_ref[:busdc_ne], nw_ref[:busdc])
else
nw_ref[:branchdc_ne] = Dict{String, Any}()
nw_ref[:arcs_dcgrid_from_ne] = Dict{String, Any}()
nw_ref[:arcs_dcgrid_to_ne] = Dict{String, Any}()
nw_ref[:arcs_dcgrid_ne] = Dict{String, Any}()
nw_ref[:buspairsdc_ne] = Dict{String, Any}()
if haskey(nw_ref, :busdc_ne)
nw_ref[:bus_arcs_dcgrid_ne] = Dict([(bus["busdc_i"], []) for (i,bus) in nw_ref[:busdc_ne]])
else
nw_ref[:bus_arcs_dcgrid_ne] = Dict{String, Any}()
end
nw_ref[:bus_convs_ac_ne] = bus_convs_ac


# add new converters to existting DC buses
end
if haskey(nw_ref, :convdc_ne)
nw_ref[:arcs_conv_acdc_ne] = [(i,conv["busac_i"],conv["busdc_i"]) for (i,conv) in nw_ref[:convdc_ne]]
nw_ref[:arcs_conv_acdc_acbus_ne] = [(i,conv["busac_i"]) for (i,conv) in nw_ref[:convdc_ne]]

# Bus converters for existing ac buses
bus_convs_ac_ne = Dict([(i, []) for (i,bus) in nw_ref[:bus]])
nw_ref[:bus_convs_ac_ne] = assign_bus_converters!(nw_ref[:convdc_ne], bus_convs_ac_ne, "busac_i")
# Bus converters forexisting DC buses
bus_convs_dc_ne = Dict([(bus["busdc_i"], []) for (i,bus) in nw_ref[:busdc]])
for (i,conv) in nw_ref[:convdc_ne]
if haskey(bus_convs_dc_ne, conv["busdc_i"])
push!(bus_convs_dc_ne[conv["busdc_i"]], i)
end
end
nw_ref[:bus_convs_dc_ne] = bus_convs_dc_ne
nw_ref[:bus_convs_dc_ne] = assign_bus_converters!(nw_ref[:convdc_ne], bus_convs_dc_ne, "busdc_i")
# Bus converters for candidate DC buses
bus_ne_convs_dc_ne = Dict([(bus["busdc_i"], []) for (i,bus) in nw_ref[:busdc_ne]])
for (i,conv) in nw_ref[:convdc_ne]
if haskey(bus_ne_convs_dc_ne, conv["busdc_i"])
push!(bus_ne_convs_dc_ne[conv["busdc_i"]], i)
end
end
nw_ref[:bus_ne_convs_dc_ne] = bus_ne_convs_dc_ne
nw_ref[:ref_buses_dc_ne] = Dict{String, Any}()
nw_ref[:buspairsdc_ne] = buspair_parameters_dc_ne(nw_ref[:arcs_dcgrid_from_ne], nw_ref[:branchdc_ne], nw_ref[:busdc_ne], nw_ref[:busdc])
nw_ref[:bus_ne_convs_dc_ne] = assign_bus_converters!(nw_ref[:convdc_ne], bus_ne_convs_dc_ne, "busdc_i")
else
nw_ref[:convdc_ne] = Dict{String, Any}()
nw_ref[:busdc_ne] = Dict{String, Any}()
nw_ref[:branchdc_ne] = Dict{String, Any}()
# DC grid arcs for DC grid branches
nw_ref[:arcs_dcgrid_ne] = Dict{String, Any}()
nw_ref[:arcs_conv_acdc_ne] = Dict{String, Any}()
nw_ref[:bus_arcs_dcgrid_ne] = Dict{String, Any}()
bus_convs_ac = Dict([(i, []) for (i,bus) in nw_ref[:bus]])
for (i,conv) in nw_ref[:convdc_ne]
push!(bus_convs_ac[conv["busac_i"]], i)
end
nw_ref[:bus_convs_ac_ne] = bus_convs_ac
nw_ref[:bus_convs_dc_ne] = Dict{String, Any}()
nw_ref[:ref_buses_dc_ne] = Dict{String, Any}()
nw_ref[:buspairsdc_ne] = Dict{String, Any}()
nw_ref[:arcs_conv_acdc_acbus_ne] = Dict{String, Any}()

# Bus converters for existing ac buses
bus_convs_ac_ne = Dict([(i, []) for (i,bus) in nw_ref[:bus]])
nw_ref[:bus_convs_ac_ne] = assign_bus_converters!(nw_ref[:convdc_ne], bus_convs_ac_ne, "busac_i")
# Bus converters forexisting DC buses
bus_convs_dc_ne = Dict([(bus["busdc_i"], []) for (i,bus) in nw_ref[:busdc]])
nw_ref[:bus_convs_dc_ne] = assign_bus_converters!(nw_ref[:convdc_ne], bus_convs_dc_ne, "busdc_i")
# Bus converters for candidate DC buses
bus_ne_convs_dc_ne = Dict([(bus["busdc_i"], []) for (i,bus) in nw_ref[:busdc_ne]])
nw_ref[:bus_ne_convs_dc_ne] = assign_bus_converters!(nw_ref[:convdc_ne], bus_ne_convs_dc_ne, "busdc_i")
end
end
end
Expand Down Expand Up @@ -298,3 +302,13 @@ function buspair_parameters_dc_ne(arcs_dcgrid_from, branches, busesdc_ne, busesd

return buspairs
end


function assign_bus_converters!(convs, dict, key)
for (i,conv) in convs
if haskey(dict, conv[key])
push!(dict[conv[key]], i)
end
end
return dict
end
2 changes: 1 addition & 1 deletion src/formconv/dcp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function constraint_converter_losses_ne(pm::_PM.AbstractDCPModel, n::Int, i::Int
JuMP.@constraint(pm.model, pconv_ac + pconv_dc == a * z + b*cm_conv_ac )
else
JuMP.@constraint(pm.model, pconv_ac + pconv_dc >= a * z + b*cm_conv_ac )
JuMP.@constraint(pm.model, pconv_ac + pconv_dc >= -(a * z - b*cm_conv_ac) )
JuMP.@constraint(pm.model, pconv_ac + pconv_dc >= a * z - b*cm_conv_ac )
JuMP.@constraint(pm.model, pconv_ac + pconv_dc <= plmax)
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/prob/acdcopf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ end

""
function run_acdcopf(data::Dict{String,Any}, model_type::Type, solver; kwargs...)
return _PM.run_model(data, model_type, solver, post_acdcopf; ref_extensions = [add_ref_dcgrid!], kwargs...)
return _PM.solve_model(data, model_type, solver, post_acdcopf; ref_extensions = [add_ref_dcgrid!], kwargs...)
end

""
Expand Down
2 changes: 1 addition & 1 deletion src/prob/acdcopf_bf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ end

""
function run_acdcopf_bf(data::Dict{String,Any}, model_type::Type{T}, solver; kwargs...) where T <: _PM.AbstractBFModel
return _PM.run_model(data, model_type, solver, post_acdcopf_bf; ref_extensions = [add_ref_dcgrid!], kwargs...)
return _PM.solve_model(data, model_type, solver, post_acdcopf_bf; ref_extensions = [add_ref_dcgrid!], kwargs...)
end

function post_acdcopf_bf(pm::_PM.AbstractPowerModel)
Expand Down
2 changes: 1 addition & 1 deletion src/prob/acdcopf_iv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function run_acdcopf_iv(file::String, model_type, optimizer; kwargs...)
end

function run_acdcopf_iv(data::Dict{String,Any}, model_type::Type, optimizer; kwargs...)
return _PM.run_model(data, model_type, optimizer, build_acdcopf_iv; ref_extensions = [add_ref_dcgrid!], kwargs...)
return _PM.solve_model(data, model_type, optimizer, build_acdcopf_iv; ref_extensions = [add_ref_dcgrid!], kwargs...)
end

""
Expand Down
2 changes: 1 addition & 1 deletion src/prob/acdcpf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ end

""
function run_acdcpf(data::Dict{String,Any}, model_type::Type, solver; kwargs...)
return _PM.run_model(data, model_type, solver, post_acdcpf; ref_extensions = [add_ref_dcgrid!], kwargs...)
return _PM.solve_model(data, model_type, solver, post_acdcpf; ref_extensions = [add_ref_dcgrid!], kwargs...)
end

""
Expand Down
Loading

2 comments on commit 4b0690c

@hakanergun
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/73664

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.0 -m "<description of version>" 4b0690c4b7ee676bacc39b6a38100f31207346bb
git push origin v0.6.0

Please sign in to comment.