diff --git a/CHANGELOG.md b/CHANGELOG.md index 1272f8490..8d48c6b97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,13 @@ PowerModels.jl Change Log ========================= ### Staged +- nothing + +### v0.9.2 - Added tracking of modifications in check_network_data - Added validate option to parse_file - Added silence() function to suppress info and warn messages +- Improved support for storage units in summary function ### v0.9.1 - Fixed print_summary in Julia v1.0 diff --git a/REQUIRE b/REQUIRE index dce0c9d0b..29933437c 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,6 +1,6 @@ julia 0.6 JSON 0.6 -InfrastructureModels 0.0.11 0.2- +InfrastructureModels 0.0.13 0.2- MathProgBase 0.5.4 JuMP 0.17 0.19- Compat 1.0 diff --git a/docs/src/parser.md b/docs/src/parser.md index b420d4636..4d073e1e2 100644 --- a/docs/src/parser.md +++ b/docs/src/parser.md @@ -25,8 +25,6 @@ We also provide the following (internal) helper methods: parse_matpower_file parse_matpower_string matpower_to_powermodels -row_to_typed_dict -row_to_dict mp_cost_data split_loads_shunts standardize_cost_terms diff --git a/src/core/data.jl b/src/core/data.jl index 6536f0c41..85724c40e 100644 --- a/src/core/data.jl +++ b/src/core/data.jl @@ -136,14 +136,60 @@ end "prints the text summary for a data file to IO" function summary(io::IO, file::String; kwargs...) data = parse_file(file) - InfrastructureModels.summary(io, data; kwargs...) + summary(io, data; kwargs...) return data end +pm_component_types_order = Dict( + "bus" => 1.0, "load" => 2.0, "shunt" => 3.0, "gen" => 4.0, "storage" => 5.0, + "branch" => 6.0, "dcline" => 7.0 +) + +pm_component_parameter_order = Dict( + "bus_i" => 1.0, "load_bus" => 2.0, "shunt_bus" => 3.0, "gen_bus" => 4.0, + "storage_bus" => 5.0, "f_bus" => 6.0, "t_bus" => 7.0, + + "bus_name" => 9.1, "base_kv" => 9.2, "bus_type" => 9.3, + + "vm" => 10.0, "va" => 11.0, + "pd" => 20.0, "qd" => 21.0, + "gs" => 30.0, "bs" => 31.0, + "pg" => 40.0, "qg" => 41.0, "vg" => 42.0, "mbase" => 43.0, + "energy" => 44.0, + "br_r" => 50.0, "br_x" => 51.0, "g_fr" => 52.0, "b_fr" => 53.0, + "g_to" => 54.0, "b_to" => 55.0, "tap" => 56.0, "shift" => 57.0, + "vf" => 58.1, "pf" => 58.2, "qf" => 58.3, + "vt" => 58.4, "pt" => 58.5, "qt" => 58.6, + "loss0" => 58.7, "loss1" => 59.8, + + "vmin" => 60.0, "vmax" => 61.0, + "pmin" => 62.0, "pmax" => 63.0, + "qmin" => 64.0, "qmax" => 65.0, + "rate_a" => 66.0, "rate_b" => 67.0, "rate_c" => 68.0, + "pminf" => 69.0, "pmaxf" => 70.0, "qminf" => 71.0, "qmaxf" => 72.0, + "pmint" => 73.0, "pmaxt" => 74.0, "qmint" => 75.0, "qmaxt" => 76.0, + "energy_rating" => 77.01, "charge_rating" => 77.02, + "discharge_rating" => 77.03, "charge_efficiency" => 77.04, + "discharge_efficiency" => 77.05, "thermal_rating" => 77.06, + "qmin" => 77.07, "qmax" => 77.08, "qmin" => 77.09, "qmax" => 77.10, + "r" => 77.11, "x" => 77.12, "standby_loss" => 77.13, + + "status" => 80.0, "gen_status" => 81.0, "br_status" => 82.0, + + "model" => 90.0, "ncost" => 91.0, "cost" => 92.0, "startup" => 93.0, "shutdown" => 94.0 +) + +pm_component_status_parameters = Set(["status", "gen_status", "br_status"]) + + "prints the text summary for a data dictionary to IO" function summary(io::IO, data::Dict{String,Any}; kwargs...) - InfrastructureModels.summary(io, data; kwargs...) + InfrastructureModels.summary(io, data; + component_types_order = pm_component_types_order, + component_parameter_order = pm_component_parameter_order, + component_status_parameters = pm_component_status_parameters, + kwargs...) end diff --git a/src/io/matpower.jl b/src/io/matpower.jl index 19aa953ab..178556b14 100644 --- a/src/io/matpower.jl +++ b/src/io/matpower.jl @@ -15,37 +15,6 @@ function parse_matpower(file::Union{IO, String}; validate=true) end -### very generic helper functions ### - -"takes a row from a matrix and assigns the values names and types" -function row_to_typed_dict(row_data, columns) - dict_data = Dict{String,Any}() - for (i,v) in enumerate(row_data) - if i <= length(columns) - name, typ = columns[i] - dict_data[name] = InfrastructureModels.check_type(typ, v) - else - dict_data["col_$(i)"] = v - end - end - return dict_data -end - -"takes a row from a matrix and assigns the values names" -function row_to_dict(row_data, columns) - dict_data = Dict{String,Any}() - for (i,v) in enumerate(row_data) - if i <= length(columns) - dict_data[columns[i]] = v - else - dict_data["col_$(i)"] = v - end - end - return dict_data -end - - - ### Data and functions specific to Matpower format ### mp_data_names = ["mpc.version", "mpc.baseMVA", "mpc.bus", "mpc.gen", @@ -189,7 +158,7 @@ function parse_matpower_string(data_string::String) if haskey(matlab_data, "mpc.bus") buses = [] for bus_row in matlab_data["mpc.bus"] - bus_data = row_to_typed_dict(bus_row, mp_bus_columns) + bus_data = InfrastructureModels.row_to_typed_dict(bus_row, mp_bus_columns) bus_data["index"] = InfrastructureModels.check_type(Int, bus_row[1]) push!(buses, bus_data) end @@ -201,7 +170,7 @@ function parse_matpower_string(data_string::String) if haskey(matlab_data, "mpc.gen") gens = [] for (i, gen_row) in enumerate(matlab_data["mpc.gen"]) - gen_data = row_to_typed_dict(gen_row, mp_gen_columns) + gen_data = InfrastructureModels.row_to_typed_dict(gen_row, mp_gen_columns) gen_data["index"] = i push!(gens, gen_data) end @@ -213,7 +182,7 @@ function parse_matpower_string(data_string::String) if haskey(matlab_data, "mpc.branch") branches = [] for (i, branch_row) in enumerate(matlab_data["mpc.branch"]) - branch_data = row_to_typed_dict(branch_row, mp_branch_columns) + branch_data = InfrastructureModels.row_to_typed_dict(branch_row, mp_branch_columns) branch_data["index"] = i push!(branches, branch_data) end @@ -225,7 +194,7 @@ function parse_matpower_string(data_string::String) if haskey(matlab_data, "mpc.dcline") dclines = [] for (i, dcline_row) in enumerate(matlab_data["mpc.dcline"]) - dcline_data = row_to_typed_dict(dcline_row, mp_dcline_columns) + dcline_data = InfrastructureModels.row_to_typed_dict(dcline_row, mp_dcline_columns) dcline_data["index"] = i push!(dclines, dcline_data) end @@ -235,7 +204,7 @@ function parse_matpower_string(data_string::String) if haskey(matlab_data, "mpc.storage") storage = [] for (i, storage_row) in enumerate(matlab_data["mpc.storage"]) - storage_data = row_to_typed_dict(storage_row, mp_storage_columns) + storage_data = InfrastructureModels.row_to_typed_dict(storage_row, mp_storage_columns) storage_data["index"] = i push!(storage, storage_data) end @@ -246,7 +215,7 @@ function parse_matpower_string(data_string::String) if haskey(matlab_data, "mpc.bus_name") bus_names = [] for (i, bus_name_row) in enumerate(matlab_data["mpc.bus_name"]) - bus_name_data = row_to_typed_dict(bus_name_row, mp_bus_name_columns) + bus_name_data = InfrastructureModels.row_to_typed_dict(bus_name_row, mp_bus_name_columns) bus_name_data["index"] = i push!(bus_names, bus_name_data) end @@ -296,7 +265,7 @@ function parse_matpower_string(data_string::String) end tbl = [] for (i, row) in enumerate(matlab_data[k]) - row_data = row_to_dict(row, column_names) + row_data = InfrastructureModels.row_to_dict(row, column_names) row_data["index"] = i push!(tbl, row_data) end