diff --git a/Project.toml b/Project.toml index 9da27367..3775e3e0 100644 --- a/Project.toml +++ b/Project.toml @@ -9,7 +9,6 @@ InfrastructureModels = "2030c09a-7f63-5d83-885d-db604e0e9cc0" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" JuMP = "4076af6c-e467-56ae-b986-b466b2749572" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9" NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" @@ -20,7 +19,6 @@ Ipopt = "~0.8, ~0.9, ~1" JSON = "~0.18, ~0.19, ~0.20, ~0.21" JuMP = "~0.22, ~0.23, 1" Juniper = "~0.8, ~0.9" -Memento = "~1.0, ~1.1, ~1.2, ~1.3, ~1.4" NLsolve = "4.0" SCS = "~0.9, ~1.0" julia = "1.6" diff --git a/src/PowerModels.jl b/src/PowerModels.jl index 95d053c2..b4510c5b 100644 --- a/src/PowerModels.jl +++ b/src/PowerModels.jl @@ -3,7 +3,6 @@ module PowerModels import LinearAlgebra, SparseArrays import JSON -import Memento import NLsolve @@ -13,25 +12,6 @@ import InfrastructureModels import InfrastructureModels: optimize_model!, @im_fields, nw_id_default const _IM = InfrastructureModels -# Create our module level logger (this will get precompiled) -const _LOGGER = Memento.getlogger(@__MODULE__) - -# Register the module level logger at runtime so that folks can access the logger via `getlogger(PowerModels)` -# NOTE: If this line is not included then the precompiled `PowerModels._LOGGER` won't be registered at runtime. -__init__() = Memento.register(_LOGGER) - -"Suppresses information and warning messages output by PowerModels, for fine grained control use the Memento package" -function silence() - Memento.info(_LOGGER, "Suppressing information and warning messages for the rest of this session. Use the Memento package for more fine-grained control of logging.") - Memento.setlevel!(Memento.getlogger(InfrastructureModels), "error") - Memento.setlevel!(Memento.getlogger(PowerModels), "error") -end - -"alows the user to set the logging level without the need to add Memento" -function logger_config!(level) - Memento.config!(Memento.getlogger("PowerModels"), level) -end - const _pm_global_keys = Set(["time_series", "per_unit"]) const pm_it_name = "pm" const pm_it_sym = Symbol(pm_it_name) diff --git a/src/core/admittance_matrix.jl b/src/core/admittance_matrix.jl index 7167dc4f..a32e923a 100644 --- a/src/core/admittance_matrix.jl +++ b/src/core/admittance_matrix.jl @@ -23,10 +23,10 @@ Base.show(io::IO, x::AdmittanceMatrix{<:Number}) = print(io, "AdmittanceMatrix($ "data should be a PowerModels network data model; only supports networks with exactly one reference bus" function calc_admittance_matrix(data::Dict{String,<:Any}) if length(data["dcline"]) > 0 - Memento.error(_LOGGER, "calc_admittance_matrix does not support data with dclines") + @error(_LOGGER, "calc_admittance_matrix does not support data with dclines") end if length(data["switch"]) > 0 - Memento.error(_LOGGER, "calc_admittance_matrix does not support data with switches") + @error(_LOGGER, "calc_admittance_matrix does not support data with switches") end #TODO check single connected component @@ -79,10 +79,10 @@ end "data should be a PowerModels network data model; only supports networks with exactly one refrence bus" function calc_susceptance_matrix(data::Dict{String,<:Any}) if length(data["dcline"]) > 0 - Memento.error(_LOGGER, "calc_susceptance_matrix does not support data with dclines") + @error(_LOGGER, "calc_susceptance_matrix does not support data with dclines") end if length(data["switch"]) > 0 - Memento.error(_LOGGER, "calc_susceptance_matrix does not support data with switches") + @error(_LOGGER, "calc_susceptance_matrix does not support data with switches") end #TODO check single connected component @@ -157,7 +157,7 @@ function calc_susceptance_matrix_inv(data::Dict{String,<:Any}) ref_bus = reference_bus(data) ref_idx = sm.bus_to_idx[ref_bus["index"]] if !(ref_idx > 0 && ref_idx <= num_buses) - Memento.error(_LOGGER, "invalid ref_idx in calc_susceptance_matrix_inv") + @error(_LOGGER, "invalid ref_idx in calc_susceptance_matrix_inv") end S[ref_idx, :] .= 0.0 S[:, ref_idx] .= 0.0 @@ -165,7 +165,7 @@ function calc_susceptance_matrix_inv(data::Dict{String,<:Any}) F = LinearAlgebra.ldlt(Symmetric(S); check=false) if !LinearAlgebra.issuccess(F) - Memento.error(_LOGGER, "Failed factorization in calc_susceptance_matrix_inv") + @error(_LOGGER, "Failed factorization in calc_susceptance_matrix_inv") end M = F \ Matrix(1.0I, num_buses, num_buses) M[ref_idx, :] .= 0.0 # zero-out the row of the slack bus @@ -178,7 +178,7 @@ function calc_admittance_matrix_inv(am::AdmittanceMatrix, ref_idx::Int) num_buses = length(am.idx_to_bus) if !(ref_idx > 0 && ref_idx <= num_buses) - Memento.error(_LOGGER, "invalid ref_idx in calc_admittance_matrix_inv") + @error(_LOGGER, "invalid ref_idx in calc_admittance_matrix_inv") end M = Matrix(am.matrix) @@ -274,10 +274,10 @@ data should be a PowerModels network data model """ function calc_bus_injection(data::Dict{String,<:Any}) if length(data["dcline"]) > 0 - Memento.error(_LOGGER, "calc_bus_injection does not support data with dclines") + @error(_LOGGER, "calc_bus_injection does not support data with dclines") end if length(data["switch"]) > 0 - Memento.error(_LOGGER, "calc_bus_injection does not support data with switches") + @error(_LOGGER, "calc_bus_injection does not support data with switches") end bus_values = Dict(bus["index"] => Dict{String,Float64}() for (i,bus) in data["bus"]) diff --git a/src/core/base.jl b/src/core/base.jl index 7dcbfdb0..19a3ec7b 100644 --- a/src/core/base.jl +++ b/src/core/base.jl @@ -35,22 +35,22 @@ function solve_model(data::Dict{String,<:Any}, model_type::Type, optimizer, buil if multinetwork != _IM.ismultinetwork(data) model_requirement = multinetwork ? "multi-network" : "single-network" data_type = _IM.ismultinetwork(data) ? "multi-network" : "single-network" - Memento.error(_LOGGER, "attempted to build a $(model_requirement) model with $(data_type) data") + @error(_LOGGER, "attempted to build a $(model_requirement) model with $(data_type) data") end if multiconductor != ismulticonductor(data) model_requirement = multiconductor ? "multi-conductor" : "single-conductor" data_type = ismulticonductor(data) ? "multi-conductor" : "single-conductor" - Memento.error(_LOGGER, "attempted to build a $(model_requirement) model with $(data_type) data") + @error(_LOGGER, "attempted to build a $(model_requirement) model with $(data_type) data") end start_time = time() pm = instantiate_model(data, model_type, build_method; ref_extensions=ref_extensions, kwargs...) - Memento.debug(_LOGGER, "pm model build time: $(time() - start_time)") + @debug(_LOGGER, "pm model build time: $(time() - start_time)") start_time = time() result = optimize_model!(pm, relax_integrality=relax_integrality, optimizer=optimizer, solution_processors=solution_processors) - Memento.debug(_LOGGER, "pm model solve and solution time: $(time() - start_time)") + @debug(_LOGGER, "pm model solve and solution time: $(time() - start_time)") return result end @@ -194,7 +194,7 @@ function ref_add_core!(ref::Dict{Symbol,Any}) nw_ref[:ref_buses] = ref_buses if length(ref_buses) > 1 - Memento.warn(_LOGGER, "multiple reference buses found, $(keys(ref_buses)), this can cause infeasibility if they are in the same connected component") + @warn(_LOGGER, "multiple reference buses found, $(keys(ref_buses)), this can cause infeasibility if they are in the same connected component") end ### aggregate info for pairs of connected buses ### diff --git a/src/core/constraint_template.jl b/src/core/constraint_template.jl index 96c298e9..5c49a58a 100644 --- a/src/core/constraint_template.jl +++ b/src/core/constraint_template.jl @@ -643,7 +643,7 @@ function constraint_thermal_limit_from_on_off(pm::AbstractPowerModel, i::Int; nw f_idx = (i, f_bus, t_bus) if !haskey(branch, "rate_a") - Memento.error(_LOGGER, "constraint_thermal_limit_from_on_off requires a rate_a value on all branches, calc_thermal_limits! can be used to generate reasonable values") + @error(_LOGGER, "constraint_thermal_limit_from_on_off requires a rate_a value on all branches, calc_thermal_limits! can be used to generate reasonable values") end constraint_thermal_limit_from_on_off(pm, nw, i, f_idx, branch["rate_a"]) @@ -658,7 +658,7 @@ function constraint_thermal_limit_to_on_off(pm::AbstractPowerModel, i::Int; nw:: t_idx = (i, t_bus, f_bus) if !haskey(branch, "rate_a") - Memento.error(_LOGGER, "constraint_thermal_limit_to_on_off requires a rate_a value on all branches, calc_thermal_limits! can be used to generate reasonable values") + @error(_LOGGER, "constraint_thermal_limit_to_on_off requires a rate_a value on all branches, calc_thermal_limits! can be used to generate reasonable values") end constraint_thermal_limit_to_on_off(pm, nw, i, t_idx, branch["rate_a"]) @@ -673,7 +673,7 @@ function constraint_ne_thermal_limit_from(pm::AbstractPowerModel, i::Int; nw::In f_idx = (i, f_bus, t_bus) if !haskey(branch, "rate_a") - Memento.error(_LOGGER, "constraint_thermal_limit_from_ne requires a rate_a value on all branches, calc_thermal_limits! can be used to generate reasonable values") + @error(_LOGGER, "constraint_thermal_limit_from_ne requires a rate_a value on all branches, calc_thermal_limits! can be used to generate reasonable values") end constraint_ne_thermal_limit_from(pm, nw, i, f_idx, branch["rate_a"]) @@ -688,7 +688,7 @@ function constraint_ne_thermal_limit_to(pm::AbstractPowerModel, i::Int; nw::Int= t_idx = (i, t_bus, f_bus) if !haskey(branch, "rate_a") - Memento.error(_LOGGER, "constraint_thermal_limit_to_ne requires a rate_a value on all branches, calc_thermal_limits! can be used to generate reasonable values") + @error(_LOGGER, "constraint_thermal_limit_to_ne requires a rate_a value on all branches, calc_thermal_limits! can be used to generate reasonable values") end constraint_ne_thermal_limit_to(pm, nw, i, t_idx, branch["rate_a"]) @@ -895,7 +895,7 @@ function constraint_storage_state(pm::AbstractPowerModel, i::Int; nw::Int=nw_id_ if haskey(ref(pm, nw), :time_elapsed) time_elapsed = ref(pm, nw, :time_elapsed) else - Memento.warn(_LOGGER, "network data should specify time_elapsed, using 1.0 as a default") + @warn(_LOGGER, "network data should specify time_elapsed, using 1.0 as a default") time_elapsed = 1.0 end @@ -909,7 +909,7 @@ function constraint_storage_state(pm::AbstractPowerModel, i::Int, nw_1::Int, nw_ if haskey(ref(pm, nw_2), :time_elapsed) time_elapsed = ref(pm, nw_2, :time_elapsed) else - Memento.warn(_LOGGER, "network $(nw_2) should specify time_elapsed, using 1.0 as a default") + @warn(_LOGGER, "network $(nw_2) should specify time_elapsed, using 1.0 as a default") time_elapsed = 1.0 end @@ -917,7 +917,7 @@ function constraint_storage_state(pm::AbstractPowerModel, i::Int, nw_1::Int, nw_ constraint_storage_state(pm, nw_1, nw_2, i, storage["charge_efficiency"], storage["discharge_efficiency"], time_elapsed) else # if the storage device has status=0 in nw_1, then the stored energy variable will not exist. Initialize storage from data model instead. - Memento.warn(_LOGGER, "storage component $(i) was not found in network $(nw_1) while building constraint_storage_state between networks $(nw_1) and $(nw_2). Using the energy value from the storage component in network $(nw_2) instead") + @warn(_LOGGER, "storage component $(i) was not found in network $(nw_1) while building constraint_storage_state between networks $(nw_1) and $(nw_2). Using the energy value from the storage component in network $(nw_2) instead") constraint_storage_state_initial(pm, nw_2, i, storage["energy"], storage["charge_efficiency"], storage["discharge_efficiency"], time_elapsed) end end diff --git a/src/core/data.jl b/src/core/data.jl index a13998e1..18ecbe50 100644 --- a/src/core/data.jl +++ b/src/core/data.jl @@ -106,7 +106,7 @@ function _calc_max_cost_index(data::Dict{String,<:Any}) max_index = max(max_index, length(gen["cost"])) end else - Memento.warn(_LOGGER, "skipping cost generator $(i) cost model in calc_cost_order, only model 2 is supported.") + @warn(_LOGGER, "skipping cost generator $(i) cost model in calc_cost_order, only model 2 is supported.") end end end @@ -118,7 +118,7 @@ function _calc_max_cost_index(data::Dict{String,<:Any}) max_index = max(max_index, length(dcline["cost"])) end else - Memento.warn(_LOGGER, "skipping cost dcline $(i) cost model in calc_cost_order, only model 2 is supported.") + @warn(_LOGGER, "skipping cost dcline $(i) cost model in calc_cost_order, only model 2 is supported.") end end end @@ -226,11 +226,11 @@ component_table(data::Dict{String,<:Any}, component::String, args...) = _IM.comp function update_data!(data::Dict{String,<:Any}, new_data::Dict{String,<:Any}) if haskey(data, "conductors") && haskey(new_data, "conductors") if data["conductors"] != new_data["conductors"] - Memento.error(_LOGGER, "update_data requires datasets with the same number of conductors") + @error(_LOGGER, "update_data requires datasets with the same number of conductors") end else if (haskey(data, "conductors") && !haskey(new_data, "conductors")) || (!haskey(data, "conductors") && haskey(new_data, "conductors")) - Memento.warn(_LOGGER, "running update_data with missing onductors fields, conductors may be incorrect") + @warn(_LOGGER, "running update_data with missing onductors fields, conductors may be incorrect") end end _IM.update_data!(data, new_data) @@ -570,7 +570,7 @@ function _rescale_cost_model!(comp::Dict{String,<:Any}, scale::Real) comp["cost"][i] = item*(scale^(degree-i)) end else - Memento.warn(_LOGGER, "Skipping cost model of type $(comp["model"]) in per unit transformation") + @warn(_LOGGER, "Skipping cost model of type $(comp["model"]) in per unit transformation") end end end @@ -607,10 +607,10 @@ function _calc_gen_cost(data::Dict{String,<:Any}) elseif gen["model"] == 2 cost += _calc_cost_polynomial(gen, "pg") else - Memento.warn(_LOGGER, "generator $(i) has an unknown cost model $(gen["model"])") + @warn(_LOGGER, "generator $(i) has an unknown cost model $(gen["model"])") end else - Memento.warn(_LOGGER, "generator $(i) does not have a cost model") + @warn(_LOGGER, "generator $(i) does not have a cost model") end end end @@ -648,10 +648,10 @@ function _calc_dcline_cost(data::Dict{String,<:Any}) elseif dcline["model"] == 2 cost += _calc_cost_polynomial(dcline, "pf") else - Memento.warn(_LOGGER, "dcline $(i) has an unknown cost model $(dcline["model"])") + @warn(_LOGGER, "dcline $(i) has an unknown cost model $(dcline["model"])") end else - Memento.warn(_LOGGER, "dcline $(i) does not have a cost model") + @warn(_LOGGER, "dcline $(i) does not have a cost model") end end end @@ -696,7 +696,7 @@ function _calc_comp_lines(component::Dict{String,<:Any}) for i in 2:length(line_data) if line_data[i-1].slope > line_data[i].slope - Memento.error(_LOGGER, "non-convex pwl function found in points $(component["cost"])\nlines: $(line_data)") + @error(_LOGGER, "non-convex pwl function found in points $(component["cost"])\nlines: $(line_data)") end end @@ -1070,7 +1070,7 @@ end "" function _check_conductors(data::Dict{String,<:Any}) if haskey(data, "conductors") && data["conductors"] < 1 - Memento.error(_LOGGER, "conductor values must be positive integers, given $(data["conductors"])") + @error(_LOGGER, "conductor values must be positive integers, given $(data["conductors"])") end end @@ -1082,7 +1082,7 @@ function correct_voltage_angle_differences!(data::Dict{String,<:Any}, default_pa pm_data = get_pm_data(data) if _IM.ismultinetwork(pm_data) - Memento.error(_LOGGER, "correct_voltage_angle_differences! does not yet support multinetwork data") + @error(_LOGGER, "correct_voltage_angle_differences! does not yet support multinetwork data") end @assert("per_unit" in keys(pm_data) && pm_data["per_unit"]) @@ -1095,7 +1095,7 @@ function correct_voltage_angle_differences!(data::Dict{String,<:Any}, default_pa angmax = branch["angmax"][c] if angmin <= -pi/2 - Memento.warn(_LOGGER, "this code only supports angmin values in -90 deg. to 90 deg., tightening the value on branch $i$(cnd_str) from $(rad2deg(angmin)) to -$(default_pad_deg) deg.") + @warn(_LOGGER, "this code only supports angmin values in -90 deg. to 90 deg., tightening the value on branch $i$(cnd_str) from $(rad2deg(angmin)) to -$(default_pad_deg) deg.") if haskey(pm_data, "conductors") branch["angmin"][c] = -default_pad else @@ -1104,7 +1104,7 @@ function correct_voltage_angle_differences!(data::Dict{String,<:Any}, default_pa end if angmax >= pi/2 - Memento.warn(_LOGGER, "this code only supports angmax values in -90 deg. to 90 deg., tightening the value on branch $i$(cnd_str) from $(rad2deg(angmax)) to $(default_pad_deg) deg.") + @warn(_LOGGER, "this code only supports angmax values in -90 deg. to 90 deg., tightening the value on branch $i$(cnd_str) from $(rad2deg(angmax)) to $(default_pad_deg) deg.") if haskey(pm_data, "conductors") branch["angmax"][c] = default_pad else @@ -1113,7 +1113,7 @@ function correct_voltage_angle_differences!(data::Dict{String,<:Any}, default_pa end if angmin == 0.0 && angmax == 0.0 - Memento.warn(_LOGGER, "angmin and angmax values are 0, widening these values on branch $i$(cnd_str) to +/- $(default_pad_deg) deg.") + @warn(_LOGGER, "angmin and angmax values are 0, widening these values on branch $i$(cnd_str) to +/- $(default_pad_deg) deg.") if haskey(pm_data, "conductors") branch["angmin"][c] = -default_pad branch["angmax"][c] = default_pad @@ -1149,12 +1149,12 @@ function _correct_thermal_limits!(pm_data::Dict{String,<:Any}) rate_value = branch[rate_key] for c in conductors if rate_value[c] < 0.0 - Memento.error(_LOGGER, "negative $(rate_key) value on branch $(branch["index"]), this code only supports non-negative $(rate_key) values") + @error(_LOGGER, "negative $(rate_key) value on branch $(branch["index"]), this code only supports non-negative $(rate_key) values") end end if all(isapprox(rate_value[c], 0.0) for c in conductors) delete!(branch, rate_key) - Memento.warn(_LOGGER, "removing zero $(rate_key) limit on branch $(branch["index"])") + @warn(_LOGGER, "removing zero $(rate_key) limit on branch $(branch["index"])") end end end @@ -1214,7 +1214,7 @@ function _calc_thermal_limits!(pm_data::Dict{String,<:Any}) new_rate = min(new_rate, branch["c_rating_a"][c]*m_vmax) end - Memento.warn(_LOGGER, "this code only supports positive rate_a values, changing the value on branch $(branch["index"])$(cnd_str) to $(round(mva_base*new_rate, digits=4))") + @warn(_LOGGER, "this code only supports positive rate_a values, changing the value on branch $(branch["index"])$(cnd_str) to $(round(mva_base*new_rate, digits=4))") if haskey(pm_data, "conductors") branch["rate_a"][c] = new_rate @@ -1250,12 +1250,12 @@ function _correct_current_limits!(pm_data::Dict{String,<:Any}) rate_value = branch[rate_key] for c in conductors if rate_value[c] < 0.0 - Memento.error(_LOGGER, "negative $(rate_key) value on branch $(branch["index"]), this code only supports non-negative $(rate_key) values") + @error(_LOGGER, "negative $(rate_key) value on branch $(branch["index"]), this code only supports non-negative $(rate_key) values") end end if all(isapprox(rate_value[c], 0.0) for c in conductors) delete!(branch, rate_key) - Memento.warn(_LOGGER, "removing zero $(rate_key) limit on branch $(branch["index"])") + @warn(_LOGGER, "removing zero $(rate_key) limit on branch $(branch["index"])") end end end @@ -1315,7 +1315,7 @@ function _calc_current_limits!(pm_data::Dict{String,<:Any}) new_c_rating = min(new_c_rating, branch["rate_a"]/vm_min) end - Memento.warn(_LOGGER, "this code only supports positive c_rating_a values, changing the value on branch $(branch["index"])$(cnd_str) to $(mva_base*new_c_rating)") + @warn(_LOGGER, "this code only supports positive c_rating_a values, changing the value on branch $(branch["index"])$(cnd_str) to $(mva_base*new_c_rating)") if haskey(pm_data, "conductors") branch["c_rating_a"][c] = new_c_rating else @@ -1343,7 +1343,7 @@ function _correct_branch_directions!(pm_data::Dict{String,<:Any}) orientation_rev = (branch["t_bus"], branch["f_bus"]) if in(orientation_rev, orientations) - Memento.warn(_LOGGER, "reversing the orientation of branch $(i) $(orientation) to be consistent with other parallel branches") + @warn(_LOGGER, "reversing the orientation of branch $(i) $(orientation) to be consistent with other parallel branches") branch_orginal = copy(branch) branch["f_bus"] = branch_orginal["t_bus"] branch["t_bus"] = branch_orginal["f_bus"] @@ -1376,7 +1376,7 @@ end function _check_branch_loops(pm_data::Dict{String, <:Any}) for (i, branch) in pm_data["branch"] if branch["f_bus"] == branch["t_bus"] - Memento.error(_LOGGER, "both sides of branch $(i) connect to bus $(branch["f_bus"])") + @error(_LOGGER, "both sides of branch $(i) connect to bus $(branch["f_bus"])") end end end @@ -1395,55 +1395,55 @@ function _check_connectivity(data::Dict{String,<:Any}) for (i, load) in data["load"] if !(load["load_bus"] in bus_ids) - Memento.error(_LOGGER, "bus $(load["load_bus"]) in load $(i) is not defined") + @error(_LOGGER, "bus $(load["load_bus"]) in load $(i) is not defined") end end for (i, shunt) in data["shunt"] if !(shunt["shunt_bus"] in bus_ids) - Memento.error(_LOGGER, "bus $(shunt["shunt_bus"]) in shunt $(i) is not defined") + @error(_LOGGER, "bus $(shunt["shunt_bus"]) in shunt $(i) is not defined") end end for (i, gen) in data["gen"] if !(gen["gen_bus"] in bus_ids) - Memento.error(_LOGGER, "bus $(gen["gen_bus"]) in generator $(i) is not defined") + @error(_LOGGER, "bus $(gen["gen_bus"]) in generator $(i) is not defined") end end for (i, strg) in data["storage"] if !(strg["storage_bus"] in bus_ids) - Memento.error(_LOGGER, "bus $(strg["storage_bus"]) in storage unit $(i) is not defined") + @error(_LOGGER, "bus $(strg["storage_bus"]) in storage unit $(i) is not defined") end end for (i, switch) in data["switch"] if !(switch["f_bus"] in bus_ids) - Memento.error(_LOGGER, "from bus $(switch["f_bus"]) in switch $(i) is not defined") + @error(_LOGGER, "from bus $(switch["f_bus"]) in switch $(i) is not defined") end if !(switch["t_bus"] in bus_ids) - Memento.error(_LOGGER, "to bus $(switch["t_bus"]) in switch $(i) is not defined") + @error(_LOGGER, "to bus $(switch["t_bus"]) in switch $(i) is not defined") end end for (i, branch) in data["branch"] if !(branch["f_bus"] in bus_ids) - Memento.error(_LOGGER, "from bus $(branch["f_bus"]) in branch $(i) is not defined") + @error(_LOGGER, "from bus $(branch["f_bus"]) in branch $(i) is not defined") end if !(branch["t_bus"] in bus_ids) - Memento.error(_LOGGER, "to bus $(branch["t_bus"]) in branch $(i) is not defined") + @error(_LOGGER, "to bus $(branch["t_bus"]) in branch $(i) is not defined") end end for (i, dcline) in data["dcline"] if !(dcline["f_bus"] in bus_ids) - Memento.error(_LOGGER, "from bus $(dcline["f_bus"]) in dcline $(i) is not defined") + @error(_LOGGER, "from bus $(dcline["f_bus"]) in dcline $(i) is not defined") end if !(dcline["t_bus"] in bus_ids) - Memento.error(_LOGGER, "to bus $(dcline["t_bus"]) in dcline $(i) is not defined") + @error(_LOGGER, "to bus $(dcline["t_bus"]) in dcline $(i) is not defined") end end end @@ -1460,45 +1460,45 @@ function _check_status(data::Dict{String,<:Any}) for (i, load) in data["load"] if load["status"] != 0 && !(load["load_bus"] in active_bus_ids) - Memento.warn(_LOGGER, "active load $(i) is connected to inactive bus $(load["load_bus"])") + @warn(_LOGGER, "active load $(i) is connected to inactive bus $(load["load_bus"])") end end for (i, shunt) in data["shunt"] if shunt["status"] != 0 && !(shunt["shunt_bus"] in active_bus_ids) - Memento.warn(_LOGGER, "active shunt $(i) is connected to inactive bus $(shunt["shunt_bus"])") + @warn(_LOGGER, "active shunt $(i) is connected to inactive bus $(shunt["shunt_bus"])") end end for (i, gen) in data["gen"] if gen["gen_status"] != 0 && !(gen["gen_bus"] in active_bus_ids) - Memento.warn(_LOGGER, "active generator $(i) is connected to inactive bus $(gen["gen_bus"])") + @warn(_LOGGER, "active generator $(i) is connected to inactive bus $(gen["gen_bus"])") end end for (i, strg) in data["storage"] if strg["status"] != 0 && !(strg["storage_bus"] in active_bus_ids) - Memento.warn(_LOGGER, "active storage unit $(i) is connected to inactive bus $(strg["storage_bus"])") + @warn(_LOGGER, "active storage unit $(i) is connected to inactive bus $(strg["storage_bus"])") end end for (i, branch) in data["branch"] if branch["br_status"] != 0 && !(branch["f_bus"] in active_bus_ids) - Memento.warn(_LOGGER, "active branch $(i) is connected to inactive bus $(branch["f_bus"])") + @warn(_LOGGER, "active branch $(i) is connected to inactive bus $(branch["f_bus"])") end if branch["br_status"] != 0 && !(branch["t_bus"] in active_bus_ids) - Memento.warn(_LOGGER, "active branch $(i) is connected to inactive bus $(branch["t_bus"])") + @warn(_LOGGER, "active branch $(i) is connected to inactive bus $(branch["t_bus"])") end end for (i, dcline) in data["dcline"] if dcline["br_status"] != 0 && !(dcline["f_bus"] in active_bus_ids) - Memento.warn(_LOGGER, "active dcline $(i) is connected to inactive bus $(dcline["f_bus"])") + @warn(_LOGGER, "active dcline $(i) is connected to inactive bus $(dcline["f_bus"])") end if dcline["br_status"] != 0 && !(dcline["t_bus"] in active_bus_ids) - Memento.warn(_LOGGER, "active dcline $(i) is connected to inactive bus $(dcline["t_bus"])") + @warn(_LOGGER, "active dcline $(i) is connected to inactive bus $(dcline["t_bus"])") end end end @@ -1509,13 +1509,13 @@ function reference_bus(data::Dict{String,<:Any}) pm_data = get_pm_data(data) if _IM.ismultinetwork(pm_data) - Memento.error(_LOGGER, "check_reference_bus does not yet support multinetwork data") + @error(_LOGGER, "check_reference_bus does not yet support multinetwork data") end ref_buses = [bus for (i,bus) in pm_data["bus"] if bus["bus_type"] == 3] if length(ref_buses) != 1 - Memento.error(_LOGGER, "exactly one refrence bus in data is required when calling reference_bus, given $(length(ref_buses))") + @error(_LOGGER, "exactly one refrence bus in data is required when calling reference_bus, given $(length(ref_buses))") end ref_buses = ref_buses[1] @@ -1539,7 +1539,7 @@ function _check_reference_bus(data::Dict{String,<:Any}) end if length(ref_buses) == 0 - Memento.warn(_LOGGER, "no reference bus found") + @warn(_LOGGER, "no reference bus found") end end @@ -1563,7 +1563,7 @@ function _correct_transformer_parameters!(pm_data::Dict{String,<:Any}) for (i, branch) in pm_data["branch"] if !haskey(branch, "tap") - Memento.warn(_LOGGER, "branch found without tap value, setting a tap to 1.0") + @warn(_LOGGER, "branch found without tap value, setting a tap to 1.0") if haskey(pm_data, "conductors") branch["tap"] = [1.0 for i in 1:pm_data["conductors"]] else @@ -1573,7 +1573,7 @@ function _correct_transformer_parameters!(pm_data::Dict{String,<:Any}) for c in 1:get(pm_data, "conductors", 1) cnd_str = haskey(pm_data, "conductors") ? " on conductor $(c)" : "" if branch["tap"][c] <= 0.0 - Memento.warn(_LOGGER, "branch found with non-positive tap value of $(branch["tap"][c]), setting a tap to 1.0$(cnd_str)") + @warn(_LOGGER, "branch found with non-positive tap value of $(branch["tap"][c]), setting a tap to 1.0$(cnd_str)") if haskey(pm_data, "conductors") branch["tap"][c] = 1.0 else @@ -1583,7 +1583,7 @@ function _correct_transformer_parameters!(pm_data::Dict{String,<:Any}) end end if !haskey(branch, "shift") - Memento.warn(_LOGGER, "branch found without shift value, setting a shift to 0.0") + @warn(_LOGGER, "branch found without shift value, setting a shift to 0.0") if haskey(pm_data, "conductors") branch["shift"] = [0.0 for i in 1:pm_data["conductors"]] else @@ -1605,51 +1605,51 @@ end function _check_storage_parameters(data::Dict{String,<:Any}) for (i, strg) in data["storage"] if strg["energy"] < 0.0 - Memento.error(_LOGGER, "storage unit $(strg["index"]) has a non-positive energy level $(strg["energy"])") + @error(_LOGGER, "storage unit $(strg["index"]) has a non-positive energy level $(strg["energy"])") end if strg["energy_rating"] < 0.0 - Memento.error(_LOGGER, "storage unit $(strg["index"]) has a non-positive energy rating $(strg["energy_rating"])") + @error(_LOGGER, "storage unit $(strg["index"]) has a non-positive energy rating $(strg["energy_rating"])") end if strg["charge_rating"] < 0.0 - Memento.error(_LOGGER, "storage unit $(strg["index"]) has a non-positive charge rating $(strg["energy_rating"])") + @error(_LOGGER, "storage unit $(strg["index"]) has a non-positive charge rating $(strg["energy_rating"])") end if strg["discharge_rating"] < 0.0 - Memento.error(_LOGGER, "storage unit $(strg["index"]) has a non-positive discharge rating $(strg["energy_rating"])") + @error(_LOGGER, "storage unit $(strg["index"]) has a non-positive discharge rating $(strg["energy_rating"])") end for c in 1:get(data, "conductors", 1) if strg["r"][c] < 0.0 - Memento.error(_LOGGER, "storage unit $(strg["index"]) has a non-positive resistance $(strg["r"][c])") + @error(_LOGGER, "storage unit $(strg["index"]) has a non-positive resistance $(strg["r"][c])") end if strg["x"][c] < 0.0 - Memento.error(_LOGGER, "storage unit $(strg["index"]) has a non-positive reactance $(strg["x"][c])") + @error(_LOGGER, "storage unit $(strg["index"]) has a non-positive reactance $(strg["x"][c])") end if haskey(strg, "thermal_rating") && strg["thermal_rating"][c] < 0.0 - Memento.error(_LOGGER, "storage unit $(strg["index"]) has a non-positive thermal rating $(strg["thermal_rating"][c])") + @error(_LOGGER, "storage unit $(strg["index"]) has a non-positive thermal rating $(strg["thermal_rating"][c])") end if haskey(strg, "current_rating") && strg["current_rating"][c] < 0.0 - Memento.error(_LOGGER, "storage unit $(strg["index"]) has a non-positive current rating $(strg["thermal_rating"][c])") + @error(_LOGGER, "storage unit $(strg["index"]) has a non-positive current rating $(strg["thermal_rating"][c])") end end if strg["charge_efficiency"] < 0.0 - Memento.error(_LOGGER, "storage unit $(strg["index"]) has a non-positive charge efficiency of $(strg["charge_efficiency"])") + @error(_LOGGER, "storage unit $(strg["index"]) has a non-positive charge efficiency of $(strg["charge_efficiency"])") end if strg["charge_efficiency"] <= 0.0 || strg["charge_efficiency"] > 1.0 - Memento.warn(_LOGGER, "storage unit $(strg["index"]) charge efficiency of $(strg["charge_efficiency"]) is out of the valid range (0.0. 1.0]") + @warn(_LOGGER, "storage unit $(strg["index"]) charge efficiency of $(strg["charge_efficiency"]) is out of the valid range (0.0. 1.0]") end if strg["discharge_efficiency"] < 0.0 - Memento.error(_LOGGER, "storage unit $(strg["index"]) has a non-positive discharge efficiency of $(strg["discharge_efficiency"])") + @error(_LOGGER, "storage unit $(strg["index"]) has a non-positive discharge efficiency of $(strg["discharge_efficiency"])") end if strg["discharge_efficiency"] <= 0.0 || strg["discharge_efficiency"] > 1.0 - Memento.warn(_LOGGER, "storage unit $(strg["index"]) discharge efficiency of $(strg["discharge_efficiency"]) is out of the valid range (0.0. 1.0]") + @warn(_LOGGER, "storage unit $(strg["index"]) discharge efficiency of $(strg["discharge_efficiency"]) is out of the valid range (0.0. 1.0]") end if strg["p_loss"] > 0.0 && strg["energy"] <= 0.0 - Memento.warn(_LOGGER, "storage unit $(strg["index"]) has positive active power losses but zero initial energy. This can lead to model infeasiblity.") + @warn(_LOGGER, "storage unit $(strg["index"]) has positive active power losses but zero initial energy. This can lead to model infeasiblity.") end if strg["q_loss"] > 0.0 && strg["energy"] <= 0.0 - Memento.warn(_LOGGER, "storage unit $(strg["index"]) has positive reactive power losses but zero initial energy. This can lead to model infeasiblity.") + @warn(_LOGGER, "storage unit $(strg["index"]) has positive reactive power losses but zero initial energy. This can lead to model infeasiblity.") end end @@ -1667,15 +1667,15 @@ end function _check_switch_parameters(data::Dict{String,<:Any}) for (i, switch) in data["switch"] if switch["state"] <= 0.0 && (!isapprox(switch["psw"], 0.0) || !isapprox(switch["qsw"], 0.0)) - Memento.warn(_LOGGER, "switch $(switch["index"]) is open with non-zero power values $(switch["psw"]), $(switch["qsw"])") + @warn(_LOGGER, "switch $(switch["index"]) is open with non-zero power values $(switch["psw"]), $(switch["qsw"])") end if haskey(switch, "thermal_rating") && switch["thermal_rating"] < 0.0 - Memento.error(_LOGGER, "switch $(switch["index"]) has a non-positive thermal_rating $(switch["thermal_rating"])") + @error(_LOGGER, "switch $(switch["index"]) has a non-positive thermal_rating $(switch["thermal_rating"])") end if haskey(switch, "current_rating") && switch["current_rating"] < 0.0 - Memento.error(_LOGGER, "switch $(switch["index"]) has a non-positive current_rating $(switch["current_rating"])") + @error(_LOGGER, "switch $(switch["index"]) has a non-positive current_rating $(switch["current_rating"])") end end end @@ -1709,19 +1709,19 @@ function _correct_bus_types!(pm_data::Dict{String,<:Any}) idx = bus["index"] if bus["bus_type"] == 1 if length(bus_gens[idx]) != 0 # PQ - Memento.warn(_LOGGER, "active generators found at bus $(bus["bus_i"]), updating to bus type from $(bus["bus_type"]) to 2") + @warn(_LOGGER, "active generators found at bus $(bus["bus_i"]), updating to bus type from $(bus["bus_type"]) to 2") bus["bus_type"] = 2 end elseif bus["bus_type"] == 2 # PV if length(bus_gens[idx]) == 0 - Memento.warn(_LOGGER, "no active generators found at bus $(bus["bus_i"]), updating to bus type from $(bus["bus_type"]) to 1") + @warn(_LOGGER, "no active generators found at bus $(bus["bus_i"]), updating to bus type from $(bus["bus_type"]) to 1") bus["bus_type"] = 1 end elseif bus["bus_type"] == 3 # Slack if length(bus_gens[idx]) != 0 slack_found = true else - Memento.warn(_LOGGER, "no active generators found at bus $(bus["bus_i"]), updating to bus type from $(bus["bus_type"]) to 1") + @warn(_LOGGER, "no active generators found at bus $(bus["bus_i"]), updating to bus type from $(bus["bus_type"]) to 1") bus["bus_type"] = 1 end elseif bus["bus_type"] == 4 # inactive bus @@ -1731,7 +1731,7 @@ function _correct_bus_types!(pm_data::Dict{String,<:Any}) if length(bus_gens[idx]) != 0 new_bus_type = 2 end - Memento.warn(_LOGGER, "bus $(bus["bus_i"]) has an unrecongized bus_type $(bus["bus_type"]), updating to bus_type $(new_bus_type)") + @warn(_LOGGER, "bus $(bus["bus_i"]) has an unrecongized bus_type $(bus["bus_type"]), updating to bus_type $(new_bus_type)") bus["bus_type"] = new_bus_type end end @@ -1742,9 +1742,9 @@ function _correct_bus_types!(pm_data::Dict{String,<:Any}) gen_bus = gen["gen_bus"] ref_bus = pm_data["bus"]["$(gen_bus)"] ref_bus["bus_type"] = 3 - Memento.warn(_LOGGER, "no reference bus found, setting bus $(gen_bus) as reference based on generator $(gen["index"])") + @warn(_LOGGER, "no reference bus found, setting bus $(gen_bus) as reference based on generator $(gen["index"])") else - Memento.error(_LOGGER, "no generators found in the given network data, correct_bus_types! requires at least one generator at the reference bus") + @error(_LOGGER, "no generators found in the given network data, correct_bus_types! requires at least one generator at the reference bus") end end @@ -1754,7 +1754,7 @@ end "find the largest active generator in a collection of generators" function _biggest_generator(gens::Dict)::Dict if length(gens) == 0 - Memento.error(_LOGGER, "generator list passed to _biggest_generator was empty. please report this bug.") + @error(_LOGGER, "generator list passed to _biggest_generator was empty. please report this bug.") end biggest_gen = Dict{String,Any}() @@ -1792,7 +1792,7 @@ function _correct_dcline_limits!(pm_data::Dict{String,<:Any}) for (i, dcline) in pm_data["dcline"] if dcline["loss0"][c] < 0.0 new_rate = 0.0 - Memento.warn(_LOGGER, "this code only supports positive loss0 values, changing the value on dcline $(dcline["index"])$(cnd_str) from $(mva_base*dcline["loss0"][c]) to $(mva_base*new_rate)") + @warn(_LOGGER, "this code only supports positive loss0 values, changing the value on dcline $(dcline["index"])$(cnd_str) from $(mva_base*dcline["loss0"][c]) to $(mva_base*new_rate)") if haskey(pm_data, "conductors") dcline["loss0"][c] = new_rate else @@ -1802,7 +1802,7 @@ function _correct_dcline_limits!(pm_data::Dict{String,<:Any}) if dcline["loss0"][c] >= dcline["pmaxf"][c]*(1-dcline["loss1"][c] )+ dcline["pmaxt"][c] new_rate = 0.0 - Memento.warn(_LOGGER, "this code only supports loss0 values which are consistent with the line flow bounds, changing the value on dcline $(dcline["index"])$(cnd_str) from $(mva_base*dcline["loss0"][c]) to $(mva_base*new_rate)") + @warn(_LOGGER, "this code only supports loss0 values which are consistent with the line flow bounds, changing the value on dcline $(dcline["index"])$(cnd_str) from $(mva_base*dcline["loss0"][c]) to $(mva_base*new_rate)") if haskey(pm_data, "conductors") dcline["loss0"][c] = new_rate else @@ -1812,7 +1812,7 @@ function _correct_dcline_limits!(pm_data::Dict{String,<:Any}) if dcline["loss1"][c] < 0.0 new_rate = 0.0 - Memento.warn(_LOGGER, "this code only supports positive loss1 values, changing the value on dcline $(dcline["index"])$(cnd_str) from $(dcline["loss1"][c]) to $(new_rate)") + @warn(_LOGGER, "this code only supports positive loss1 values, changing the value on dcline $(dcline["index"])$(cnd_str) from $(dcline["loss1"][c]) to $(new_rate)") if haskey(pm_data, "conductors") dcline["loss1"][c] = new_rate else @@ -1822,7 +1822,7 @@ function _correct_dcline_limits!(pm_data::Dict{String,<:Any}) if dcline["loss1"][c] >= 1.0 new_rate = 0.0 - Memento.warn(_LOGGER, "this code only supports loss1 values < 1, changing the value on dcline $(dcline["index"])$(cnd_str) from $(dcline["loss1"][c]) to $(new_rate)") + @warn(_LOGGER, "this code only supports loss1 values < 1, changing the value on dcline $(dcline["index"])$(cnd_str) from $(dcline["loss1"][c]) to $(new_rate)") if haskey(pm_data, "conductors") dcline["loss1"][c] = new_rate else @@ -1832,7 +1832,7 @@ function _correct_dcline_limits!(pm_data::Dict{String,<:Any}) if dcline["pmint"][c] <0.0 && dcline["loss1"][c] > 0.0 #new_rate = 0.0 - Memento.warn(_LOGGER, "the dc line model is not meant to be used bi-directionally when loss1 > 0, be careful interpreting the results as the dc line losses can now be negative. change loss1 to 0 to avoid this warning") + @warn(_LOGGER, "the dc line model is not meant to be used bi-directionally when loss1 > 0, be careful interpreting the results as the dc line losses can now be negative. change loss1 to 0 to avoid this warning") #dcline["loss0"] = new_rate end end @@ -1855,7 +1855,7 @@ function _check_voltage_setpoints(data::Dict{String,<:Any}) bus_id = gen["gen_bus"] bus = data["bus"]["$(bus_id)"] if gen["vg"][c] != bus["vm"][c] - Memento.warn(_LOGGER, "the $(cnd_str)voltage setpoint on generator $(i) does not match the value at bus $(bus_id)") + @warn(_LOGGER, "the $(cnd_str)voltage setpoint on generator $(i) does not match the value at bus $(bus_id)") end end @@ -1867,11 +1867,11 @@ function _check_voltage_setpoints(data::Dict{String,<:Any}) bus_to = data["bus"]["$(bus_to_id)"] if dcline["vf"][c] != bus_fr["vm"][c] - Memento.warn(_LOGGER, "the $(cnd_str)from bus voltage setpoint on dc line $(i) does not match the value at bus $(bus_fr_id)") + @warn(_LOGGER, "the $(cnd_str)from bus voltage setpoint on dc line $(i) does not match the value at bus $(bus_fr_id)") end if dcline["vt"][c] != bus_to["vm"][c] - Memento.warn(_LOGGER, "the $(cnd_str)to bus voltage setpoint on dc line $(i) does not match the value at bus $(bus_to_id)") + @warn(_LOGGER, "the $(cnd_str)to bus voltage setpoint on dc line $(i) does not match the value at bus $(bus_to_id)") end end end @@ -1901,17 +1901,17 @@ function _correct_cost_function!(id, comp, type_name, pmin_key, pmax_key) if "model" in keys(comp) && "cost" in keys(comp) if comp["model"] == 1 if length(comp["cost"]) != 2*comp["ncost"] - Memento.error(_LOGGER, "ncost of $(comp["ncost"]) not consistent with $(length(comp["cost"])) cost values on $(type_name) $(id)") + @error(_LOGGER, "ncost of $(comp["ncost"]) not consistent with $(length(comp["cost"])) cost values on $(type_name) $(id)") end if length(comp["cost"]) < 4 - Memento.error(_LOGGER, "cost includes $(comp["ncost"]) points, but at least two points are required on $(type_name) $(id)") + @error(_LOGGER, "cost includes $(comp["ncost"]) points, but at least two points are required on $(type_name) $(id)") end _remove_pwl_cost_duplicates!(id, comp, type_name) for i in 3:2:length(comp["cost"]) if comp["cost"][i-2] > comp["cost"][i] - Memento.error(_LOGGER, "non-increasing x values in pwl cost model on $(type_name) $(id)") + @error(_LOGGER, "non-increasing x values in pwl cost model on $(type_name) $(id)") end end @@ -1919,10 +1919,10 @@ function _correct_cost_function!(id, comp, type_name, pmin_key, pmax_key) elseif comp["model"] == 2 if length(comp["cost"]) != comp["ncost"] - Memento.error(_LOGGER, "ncost of $(comp["ncost"]) not consistent with $(length(comp["cost"])) cost values on $(type_name) $(id)") + @error(_LOGGER, "ncost of $(comp["ncost"]) not consistent with $(length(comp["cost"])) cost values on $(type_name) $(id)") end else - Memento.warn(_LOGGER, "Unknown cost model of type $(comp["model"]) on $(type_name) $(id)") + @warn(_LOGGER, "Unknown cost model of type $(comp["model"]) on $(type_name) $(id)") end end @@ -1953,7 +1953,7 @@ function _remove_pwl_cost_duplicates!(id, comp, type_name; tolerance=1e-2) end if length(unique_costs) < length(comp["cost"]) - Memento.warn(_LOGGER, "removing duplicate points from pwl cost on $(type_name) $(id), $(comp["cost"]) -> $(unique_costs)") + @warn(_LOGGER, "removing duplicate points from pwl cost on $(type_name) $(id), $(comp["cost"]) -> $(unique_costs)") comp["cost"] = unique_costs comp["ncost"] = div(length(unique_costs), 2) return true @@ -1994,7 +1994,7 @@ function _simplify_pwl_cost!(id, comp, type_name; tolerance=1e-2) push!(smpl_cost, y2) if length(smpl_cost) < length(comp["cost"]) - Memento.warn(_LOGGER, "simplifying pwl cost on $(type_name) $(id), $(comp["cost"]) -> $(smpl_cost)") + @warn(_LOGGER, "simplifying pwl cost on $(type_name) $(id), $(comp["cost"]) -> $(smpl_cost)") comp["cost"] = smpl_cost comp["ncost"] = div(length(smpl_cost), 2) return true @@ -2024,7 +2024,7 @@ function _simplify_cost_terms!(pm_data::Dict{String,<:Any}) end if length(gen["cost"]) != ncost gen["ncost"] = length(gen["cost"]) - Memento.info(_LOGGER, "removing $(ncost - gen["ncost"]) cost terms from generator $(i): $(gen["cost"])") + @info(_LOGGER, "removing $(ncost - gen["ncost"]) cost terms from generator $(i): $(gen["cost"])") end end end @@ -2043,7 +2043,7 @@ function _simplify_cost_terms!(pm_data::Dict{String,<:Any}) end if length(dcline["cost"]) != ncost dcline["ncost"] = length(dcline["cost"]) - Memento.info(_LOGGER, "removing $(ncost - dcline["ncost"]) cost terms from dcline $(i): $(dcline["cost"])") + @info(_LOGGER, "removing $(ncost - dcline["ncost"]) cost terms from dcline $(i): $(dcline["cost"])") end end end @@ -2107,7 +2107,7 @@ function standardize_cost_terms!(data::Dict{String,<:Any}; order=-1) comp_max_order = order+1 else if order != -1 # if not the default - Memento.warn(_LOGGER, "a standard cost order of $(order) was requested but the given data requires an order of at least $(comp_max_order-1)") + @warn(_LOGGER, "a standard cost order of $(order) was requested but the given data requires an order of at least $(comp_max_order-1)") end end @@ -2138,7 +2138,7 @@ function _standardize_cost_terms!(components::Dict{String,<:Any}, comp_order::In comp["ncost"] = comp_order #println("std gen cost: $(comp["cost"])") - Memento.info(_LOGGER, "updated $(cost_comp_name) $(comp["index"]) cost function with order $(length(current_cost)) to a function of order $(comp_order): $(comp["cost"])") + @info(_LOGGER, "updated $(cost_comp_name) $(comp["index"]) cost function with order $(length(current_cost)) to a function of order $(comp_order): $(comp["cost"])") push!(modified, comp["index"]) end end @@ -2227,7 +2227,7 @@ function _propagate_topology_status!(data::Dict{String,<:Any}) t_bus = buses[branch["t_bus"]] if f_bus["bus_type"] == 4 || t_bus["bus_type"] == 4 - Memento.info(_LOGGER, "deactivating branch $(i):($(branch["f_bus"]),$(branch["t_bus"])) due to connecting bus status") + @info(_LOGGER, "deactivating branch $(i):($(branch["f_bus"]),$(branch["t_bus"])) due to connecting bus status") branch["br_status"] = 0 revised = true end @@ -2240,7 +2240,7 @@ function _propagate_topology_status!(data::Dict{String,<:Any}) t_bus = buses[dcline["t_bus"]] if f_bus["bus_type"] == 4 || t_bus["bus_type"] == 4 - Memento.info(_LOGGER, "deactivating dcline $(i):($(dcline["f_bus"]),$(dcline["t_bus"])) due to connecting bus status") + @info(_LOGGER, "deactivating dcline $(i):($(dcline["f_bus"]),$(dcline["t_bus"])) due to connecting bus status") dcline["br_status"] = 0 revised = true end @@ -2253,7 +2253,7 @@ function _propagate_topology_status!(data::Dict{String,<:Any}) t_bus = buses[switch["t_bus"]] if f_bus["bus_type"] == 4 || t_bus["bus_type"] == 4 - Memento.info(_LOGGER, "deactivating switch $(i):($(switch["f_bus"]),$(switch["t_bus"])) due to connecting bus status") + @info(_LOGGER, "deactivating switch $(i):($(switch["f_bus"]),$(switch["t_bus"])) due to connecting bus status") switch["status"] = 0 revised = true end @@ -2264,7 +2264,7 @@ function _propagate_topology_status!(data::Dict{String,<:Any}) if bus["bus_type"] == 4 for load in incident_active_load[i] if load["status"] != 0 - Memento.info(_LOGGER, "deactivating load $(load["index"]) due to inactive bus $(i)") + @info(_LOGGER, "deactivating load $(load["index"]) due to inactive bus $(i)") load["status"] = 0 revised = true end @@ -2272,7 +2272,7 @@ function _propagate_topology_status!(data::Dict{String,<:Any}) for shunt in incident_active_shunt[i] if shunt["status"] != 0 - Memento.info(_LOGGER, "deactivating shunt $(shunt["index"]) due to inactive bus $(i)") + @info(_LOGGER, "deactivating shunt $(shunt["index"]) due to inactive bus $(i)") shunt["status"] = 0 revised = true end @@ -2280,7 +2280,7 @@ function _propagate_topology_status!(data::Dict{String,<:Any}) for gen in incident_active_gen[i] if gen["gen_status"] != 0 - Memento.info(_LOGGER, "deactivating generator $(gen["index"]) due to inactive bus $(i)") + @info(_LOGGER, "deactivating generator $(gen["index"]) due to inactive bus $(i)") gen["gen_status"] = 0 revised = true end @@ -2288,7 +2288,7 @@ function _propagate_topology_status!(data::Dict{String,<:Any}) for strg in incident_active_strg[i] if strg["status"] != 0 - Memento.info(_LOGGER, "deactivating storage $(strg["index"]) due to inactive bus $(i)") + @info(_LOGGER, "deactivating storage $(strg["index"]) due to inactive bus $(i)") strg["status"] = 0 revised = true end @@ -2332,7 +2332,7 @@ function _deactivate_isolated_components!(data::Dict{String,<:Any}) for (i,load) in data["load"] if load["status"] != 0 && all(load["pd"] .== 0.0) && all(load["qd"] .== 0.0) - Memento.info(_LOGGER, "deactivating load $(load["index"]) due to zero pd and qd") + @info(_LOGGER, "deactivating load $(load["index"]) due to zero pd and qd") load["status"] = 0 revised = true end @@ -2340,7 +2340,7 @@ function _deactivate_isolated_components!(data::Dict{String,<:Any}) for (i,shunt) in data["shunt"] if shunt["status"] != 0 && all(shunt["gs"] .== 0.0) && all(shunt["bs"] .== 0.0) - Memento.info(_LOGGER, "deactivating shunt $(shunt["index"]) due to zero gs and bs") + @info(_LOGGER, "deactivating shunt $(shunt["index"]) due to zero gs and bs") shunt["status"] = 0 revised = true end @@ -2407,7 +2407,7 @@ function _deactivate_isolated_components!(data::Dict{String,<:Any}) end if incident_active_edge == 1 && length(incident_active_gen[i]) == 0 && length(incident_active_load[i]) == 0 && length(incident_active_shunt[i]) == 0 && length(incident_active_strg[i]) == 0 - Memento.info(_LOGGER, "deactivating bus $(i) due to dangling bus without generation, load or storage") + @info(_LOGGER, "deactivating bus $(i) due to dangling bus without generation, load or storage") bus["bus_type"] = 4 revised = true changed = true @@ -2422,7 +2422,7 @@ function _deactivate_isolated_components!(data::Dict{String,<:Any}) t_bus = buses[branch["t_bus"]] if f_bus["bus_type"] == 4 || t_bus["bus_type"] == 4 - Memento.info(_LOGGER, "deactivating branch $(i):($(branch["f_bus"]),$(branch["t_bus"])) due to connecting bus status") + @info(_LOGGER, "deactivating branch $(i):($(branch["f_bus"]),$(branch["t_bus"])) due to connecting bus status") branch["br_status"] = 0 end end @@ -2434,7 +2434,7 @@ function _deactivate_isolated_components!(data::Dict{String,<:Any}) t_bus = buses[dcline["t_bus"]] if f_bus["bus_type"] == 4 || t_bus["bus_type"] == 4 - Memento.info(_LOGGER, "deactivating dcline $(i):($(dcline["f_bus"]),$(dcline["t_bus"])) due to connecting bus status") + @info(_LOGGER, "deactivating dcline $(i):($(dcline["f_bus"]),$(dcline["t_bus"])) due to connecting bus status") dcline["br_status"] = 0 end end @@ -2446,7 +2446,7 @@ function _deactivate_isolated_components!(data::Dict{String,<:Any}) t_bus = buses[switch["t_bus"]] if f_bus["bus_type"] == 4 || t_bus["bus_type"] == 4 - Memento.info(_LOGGER, "deactivating switch $(i):($(switch["f_bus"]),$(switch["t_bus"])) due to connecting bus status") + @info(_LOGGER, "deactivating switch $(i):($(switch["f_bus"]),$(switch["t_bus"])) due to connecting bus status") switch["status"] = 0 end end @@ -2477,7 +2477,7 @@ function _deactivate_isolated_components!(data::Dict{String,<:Any}) active_strg_count = sum(cc_active_strg) if (active_load_count == 0 && active_shunt_count == 0 && active_strg_count == 0) || active_gen_count == 0 - Memento.info(_LOGGER, "deactivating connected component $(cc) due to isolation without generation, load or storage") + @info(_LOGGER, "deactivating connected component $(cc) due to isolation without generation, load or storage") for i in cc buses[i]["bus_type"] = 4 end @@ -2506,7 +2506,7 @@ function simplify_network!(data::Dict{String,<:Any}) revised |= deactivate_isolated_components!(data) end - Memento.info(_LOGGER, "network simplification fixpoint reached in $(iteration) rounds") + @info(_LOGGER, "network simplification fixpoint reached in $(iteration) rounds") return revised end @@ -2523,17 +2523,17 @@ function _select_largest_component!(data::Dict{String,<:Any}) ccs = calc_connected_components(data) if length(ccs) > 1 - Memento.info(_LOGGER, "found $(length(ccs)) components") + @info(_LOGGER, "found $(length(ccs)) components") ccs_order = sort(collect(ccs); by=length) largest_cc = ccs_order[end] - Memento.info(_LOGGER, "largest component has $(length(largest_cc)) buses") + @info(_LOGGER, "largest component has $(length(largest_cc)) buses") for (i,bus) in data["bus"] if bus["bus_type"] != 4 && !(bus["index"] in largest_cc) bus["bus_type"] = 4 - Memento.info(_LOGGER, "deactivating bus $(i) due to small connected component") + @info(_LOGGER, "deactivating bus $(i) due to small connected component") end end @@ -2592,7 +2592,7 @@ function correct_component_refrence_bus!(component_bus_ids, bus_lookup, componen end if length(refrence_buses) == 0 - Memento.warn(_LOGGER, "no reference bus found in connected component $(component_bus_ids)") + @warn(_LOGGER, "no reference bus found in connected component $(component_bus_ids)") component_gens_active = Dict(k => v for (k,v) in component_gens if v["gen_status"] != 0) @@ -2600,9 +2600,9 @@ function correct_component_refrence_bus!(component_bus_ids, bus_lookup, componen big_gen = _biggest_generator(component_gens_active) gen_bus = bus_lookup[big_gen["gen_bus"]] gen_bus["bus_type"] = 3 - Memento.warn(_LOGGER, "setting bus $(gen_bus["index"]) as reference bus in connected component $(component_bus_ids), based on generator $(big_gen["index"])") + @warn(_LOGGER, "setting bus $(gen_bus["index"]) as reference bus in connected component $(component_bus_ids), based on generator $(big_gen["index"])") else - Memento.warn(_LOGGER, "no active generators found in connected component $(component_bus_ids), try running propagate_topology_status!") + @warn(_LOGGER, "no active generators found in connected component $(component_bus_ids), try running propagate_topology_status!") end end end @@ -2656,7 +2656,7 @@ function calc_connected_components(data::Dict{String,<:Any}; edges=["branch", "d pm_data = get_pm_data(data) if _IM.ismultinetwork(pm_data) - Memento.error(_LOGGER, "connected_components does not yet support multinetwork data") + @error(_LOGGER, "connected_components does not yet support multinetwork data") end active_bus = Dict(x for x in pm_data["bus"] if x.second["bus_type"] != 4) @@ -2735,7 +2735,7 @@ function _update_bus_ids!(data::Dict{String,<:Any}, bus_id_map::Dict{Int,Int}; i if !(new_id in new_bus_ids) push!(new_bus_ids, new_id) else - Memento.error(_LOGGER, "bus id mapping given to update_bus_ids has an id clash on new bus id $(new_id)") + @error(_LOGGER, "bus id mapping given to update_bus_ids has an id clash on new bus id $(new_id)") end end end @@ -2836,7 +2836,7 @@ function _resolve_swithces!(data::Dict{String,<:Any}) bus_id_map = Dict{Int,Int}() for bus_set in Set(values(bus_sets)) bus_min = minimum(bus_set) - Memento.info(_LOGGER, "merged buses $(join(bus_set, ",")) in to bus $(bus_min) based on switch status") + @info(_LOGGER, "merged buses $(join(bus_set, ",")) in to bus $(bus_min) based on switch status") for i in bus_set if i != bus_min bus_id_map[i] = bus_min @@ -2848,18 +2848,18 @@ function _resolve_swithces!(data::Dict{String,<:Any}) for (i, branch) in data["branch"] if branch["f_bus"] == branch["t_bus"] - Memento.warn(_LOGGER, "switch removal resulted in both sides of branch $(i) connect to bus $(branch["f_bus"]), deactivating branch") + @warn(_LOGGER, "switch removal resulted in both sides of branch $(i) connect to bus $(branch["f_bus"]), deactivating branch") branch[pm_component_status["branch"]] = pm_component_status_inactive["branch"] end end for (i, dcline) in data["dcline"] if dcline["f_bus"] == dcline["t_bus"] - Memento.warn(_LOGGER, "switch removal resulted in both sides of dcline $(i) connect to bus $(branch["f_bus"]), deactivating dcline") + @warn(_LOGGER, "switch removal resulted in both sides of dcline $(i) connect to bus $(branch["f_bus"]), deactivating dcline") branch[pm_component_status["dcline"]] = pm_component_status_inactive["dcline"] end end - Memento.info(_LOGGER, "removed $(length(data["switch"])) switch components") + @info(_LOGGER, "removed $(length(data["switch"])) switch components") data["switch"] = Dict{String,Any}() end diff --git a/src/core/data_basic.jl b/src/core/data_basic.jl index e3e8f777..4b6a22f3 100644 --- a/src/core/data_basic.jl +++ b/src/core/data_basic.jl @@ -18,11 +18,11 @@ the non-basic PowerModels routines. """ function make_basic_network(data::Dict{String,<:Any}) if _IM.ismultiinfrastructure(data) - Memento.error(_LOGGER, "make_basic_network does not support multiinfrastructure data") + @error(_LOGGER, "make_basic_network does not support multiinfrastructure data") end if _IM.ismultinetwork(data) - Memento.error(_LOGGER, "make_basic_network does not support multinetwork data") + @error(_LOGGER, "make_basic_network does not support multinetwork data") end # make a copy of data so that modifications do not change the input data @@ -31,7 +31,7 @@ function make_basic_network(data::Dict{String,<:Any}) # TODO transform PWL costs into linear costs for (i,gen) in data["gen"] if get(gen, "cost_model", 2) != 2 - Memento.error(_LOGGER, "make_basic_network only supports network data with polynomial cost functions, generator $(i) has a piecewise linear cost function") + @error(_LOGGER, "make_basic_network only supports network data with polynomial cost functions, generator $(i) has a piecewise linear cost function") end end standardize_cost_terms!(data, order=2) @@ -39,7 +39,7 @@ function make_basic_network(data::Dict{String,<:Any}) # set conductance to zero on all shunts for (i,shunt) in data["shunt"] if !isapprox(shunt["gs"], 0.0) - Memento.warn(_LOGGER, "setting conductance on shunt $(i) from $(shunt["gs"]) to 0.0") + @warn(_LOGGER, "setting conductance on shunt $(i) from $(shunt["gs"]) to 0.0") shunt["gs"] = 0.0 end end @@ -50,7 +50,7 @@ function make_basic_network(data::Dict{String,<:Any}) # set phase shift to zero on all branches for (i,branch) in data["branch"] if !isapprox(branch["shift"], 0.0) - Memento.warn(_LOGGER, "setting phase shift on branch $(i) from $(branch["shift"]) to 0.0") + @warn(_LOGGER, "setting phase shift on branch $(i) from $(branch["shift"]) to 0.0") branch["shift"] = 0.0 end end @@ -69,7 +69,7 @@ function make_basic_network(data::Dict{String,<:Any}) end end if length(ref_buses) > 1 - Memento.warn(_LOGGER, "network data specifies $(length(ref_buses)) reference buses") + @warn(_LOGGER, "network data specifies $(length(ref_buses)) reference buses") for ref_bus_id in ref_buses data["bus"]["$(ref_bus_id)"]["bus_type"] = 2 end @@ -81,7 +81,7 @@ function make_basic_network(data::Dict{String,<:Any}) gen_bus = gen["gen_bus"] ref_bus = data["bus"]["$(gen_bus)"] ref_bus["bus_type"] = 3 - Memento.warn(_LOGGER, "setting bus $(gen_bus) as reference based on generator $(gen["index"])") + @warn(_LOGGER, "setting bus $(gen_bus) as reference based on generator $(gen["index"])") end # remove switches by merging buses @@ -103,7 +103,7 @@ function make_basic_network(data::Dict{String,<:Any}) status_inactive = pm_component_status_inactive[comp_key] data[comp_key] = _filter_inactive_components(data[comp_key], status_key=status_key, status_inactive_value=status_inactive) if length(data[comp_key]) < comp_count - Memento.info(_LOGGER, "removed $(comp_count - length(data[comp_key])) inactive $(comp_key) components") + @info(_LOGGER, "removed $(comp_count - length(data[comp_key])) inactive $(comp_key) components") end end @@ -170,7 +170,7 @@ values in rectangular coordinates as they appear in the network data. """ function calc_basic_bus_voltage(data::Dict{String,<:Any}) if !get(data, "basic_network", false) - Memento.warn(_LOGGER, "calc_basic_bus_voltage requires basic network data and given data may be incompatible. make_basic_network can be used to transform data into the appropriate form.") + @warn(_LOGGER, "calc_basic_bus_voltage requires basic network data and given data may be incompatible. make_basic_network can be used to transform data into the appropriate form.") end b = [bus for (i,bus) in data["bus"] if bus["bus_type"] != 4] @@ -185,7 +185,7 @@ injections as they appear in the network data. """ function calc_basic_bus_injection(data::Dict{String,<:Any}) if !get(data, "basic_network", false) - Memento.warn(_LOGGER, "calc_basic_bus_injection requires basic network data and given data may be incompatible. make_basic_network can be used to transform data into the appropriate form.") + @warn(_LOGGER, "calc_basic_bus_injection requires basic network data and given data may be incompatible. make_basic_network can be used to transform data into the appropriate form.") end bi_dict = calc_bus_injection(data) @@ -200,7 +200,7 @@ series impedances. """ function calc_basic_branch_series_impedance(data::Dict{String,<:Any}) if !get(data, "basic_network", false) - Memento.warn(_LOGGER, "calc_basic_branch_series_impedance requires basic network data and given data may be incompatible. make_basic_network can be used to transform data into the appropriate form.") + @warn(_LOGGER, "calc_basic_branch_series_impedance requires basic network data and given data may be incompatible. make_basic_network can be used to transform data into the appropriate form.") end b = [branch for (i,branch) in data["branch"] if branch["br_status"] != 0] @@ -218,7 +218,7 @@ indicate _to_ bus. """ function calc_basic_incidence_matrix(data::Dict{String,<:Any}) if !get(data, "basic_network", false) - 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.") + @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 = Int[] @@ -241,7 +241,7 @@ matrix with one row and column for each bus in the network. """ function calc_basic_admittance_matrix(data::Dict{String,<:Any}) if !get(data, "basic_network", false) - Memento.warn(_LOGGER, "calc_basic_admittance_matrix requires basic network data and given data may be incompatible. make_basic_network can be used to transform data into the appropriate form.") + @warn(_LOGGER, "calc_basic_admittance_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 return calc_admittance_matrix(data).matrix @@ -256,7 +256,7 @@ matrix that only considers the branch series impedance. """ function calc_basic_susceptance_matrix(data::Dict{String,<:Any}) if !get(data, "basic_network", false) - Memento.warn(_LOGGER, "calc_basic_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.") + @warn(_LOGGER, "calc_basic_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 return calc_susceptance_matrix(data).matrix @@ -271,7 +271,7 @@ active power flow values for each branch. """ function calc_basic_branch_susceptance_matrix(data::Dict{String,<:Any}) if !get(data, "basic_network", false) - 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.") + @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 = Int[] @@ -295,7 +295,7 @@ phase angles by solving a dc power flow. """ function compute_basic_dc_pf(data::Dict{String,<:Any}) if !get(data, "basic_network", false) - Memento.warn(_LOGGER, "compute_basic_dc_pf requires basic network data and given data may be incompatible. make_basic_network can be used to transform data into the appropriate form.") + @warn(_LOGGER, "compute_basic_dc_pf requires basic network data and given data may be incompatible. make_basic_network can be used to transform data into the appropriate form.") end num_bus = length(data["bus"]) @@ -330,7 +330,7 @@ active power flow values on each branch. """ function calc_basic_ptdf_matrix(data::Dict{String,<:Any}) if !get(data, "basic_network", false) - Memento.warn(_LOGGER, "calc_basic_ptdf_matrix requires basic network data and given data may be incompatible. make_basic_network can be used to transform data into the appropriate form.") + @warn(_LOGGER, "calc_basic_ptdf_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 b_inv = calc_susceptance_matrix_inv(data).matrix @@ -348,11 +348,11 @@ matrix reflecting that branch. """ function calc_basic_ptdf_row(data::Dict{String,<:Any}, branch_index::Int) if !get(data, "basic_network", false) - Memento.warn(_LOGGER, "calc_basic_ptdf_row requires basic network data and given data may be incompatible. make_basic_network can be used to transform data into the appropriate form.") + @warn(_LOGGER, "calc_basic_ptdf_row requires basic network data and given data may be incompatible. make_basic_network can be used to transform data into the appropriate form.") end if branch_index < 1 || branch_index > length(data["branch"]) - Memento.error(_LOGGER, "branch index of $(branch_index) is out of bounds, valid values are $(1)-$(length(data["branch"]))") + @error(_LOGGER, "branch index of $(branch_index) is out of bounds, valid values are $(1)-$(length(data["branch"]))") end branch = data["branch"]["$(branch_index)"] g,b = calc_branch_y(branch) @@ -381,7 +381,7 @@ while voltage values are ordered by voltage angle and then voltage magnitude. """ function calc_basic_jacobian_matrix(data::Dict{String,<:Any}) if !get(data, "basic_network", false) - Memento.warn(_LOGGER, "calc_basic_jacobian_matrix requires basic network data and given data may be incompatible. make_basic_network can be used to transform data into the appropriate form.") + @warn(_LOGGER, "calc_basic_jacobian_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 num_bus = length(data["bus"]) diff --git a/src/core/objective.jl b/src/core/objective.jl index 77aedf1a..b6a505a5 100644 --- a/src/core/objective.jl +++ b/src/core/objective.jl @@ -23,7 +23,7 @@ function check_cost_models(pm::AbstractPowerModel) end if gen_model != dcline_model - Memento.error(_LOGGER, "generator and dcline cost models are inconsistent, the generator model is $(gen_model) however dcline model $(dcline_model)") + @error(_LOGGER, "generator and dcline cost models are inconsistent, the generator model is $(gen_model) however dcline model $(dcline_model)") end return gen_model @@ -43,11 +43,11 @@ function check_gen_cost_models(pm::AbstractPowerModel) model = gen["model"] else if gen["model"] != model - Memento.error(_LOGGER, "cost models are inconsistent, the typical model is $(model) however model $(gen["model"]) is given on generator $(i)") + @error(_LOGGER, "cost models are inconsistent, the typical model is $(model) however model $(gen["model"]) is given on generator $(i)") end end else - Memento.error(_LOGGER, "no cost given for generator $(i)") + @error(_LOGGER, "no cost given for generator $(i)") end end end @@ -69,11 +69,11 @@ function check_dcline_cost_models(pm::AbstractPowerModel) model = dcline["model"] else if dcline["model"] != model - Memento.error(_LOGGER, "cost models are inconsistent, the typical model is $(model) however model $(dcline["model"]) is given on dcline $(i)") + @error(_LOGGER, "cost models are inconsistent, the typical model is $(model) however model $(dcline["model"]) is given on dcline $(i)") end end else - Memento.error(_LOGGER, "no cost given for dcline $(i)") + @error(_LOGGER, "no cost given for dcline $(i)") end end end @@ -91,7 +91,7 @@ function objective_min_fuel_and_flow_cost(pm::AbstractPowerModel; kwargs...) elseif model == 2 return objective_min_fuel_and_flow_cost_polynomial(pm; kwargs...) else - Memento.error(_LOGGER, "Only cost models of types 1 and 2 are supported at this time, given cost model type of $(model)") + @error(_LOGGER, "Only cost models of types 1 and 2 are supported at this time, given cost model type of $(model)") end end @@ -106,7 +106,7 @@ function objective_min_fuel_cost(pm::AbstractPowerModel; kwargs...) elseif model == 2 return objective_min_fuel_cost_polynomial(pm; kwargs...) else - Memento.error(_LOGGER, "Only cost models of types 1 and 2 are supported at this time, given cost model type of $(model)") + @error(_LOGGER, "Only cost models of types 1 and 2 are supported at this time, given cost model type of $(model)") end end @@ -401,7 +401,7 @@ function calc_pwl_points(ncost::Int, cost::Vector{<:Real}, pmin::Real, pmax::Rea @assert pmin <= pmax if isinf(pmin) || isinf(pmax) - Memento.error(_LOGGER, "a bounded operating range is required for modeling pwl costs. Given active power range in $(pmin) - $(pmax)") + @error(_LOGGER, "a bounded operating range is required for modeling pwl costs. Given active power range in $(pmin) - $(pmax)") end points = [] diff --git a/src/core/solution.jl b/src/core/solution.jl index e67add96..d4926516 100644 --- a/src/core/solution.jl +++ b/src/core/solution.jl @@ -20,7 +20,7 @@ end "converts the solution data into the data model's standard space, polar voltages and rectangular power" function sol_data_model!(pm::AbstractPowerModel, solution::Dict) - Memento.warn(_LOGGER, "sol_data_model! not defined for power model of type $(typeof(pm))") + @warn(_LOGGER, "sol_data_model! not defined for power model of type $(typeof(pm))") end diff --git a/src/form/wr.jl b/src/form/wr.jl index ced4bf4d..57ba8c58 100644 --- a/src/form/wr.jl +++ b/src/form/wr.jl @@ -539,7 +539,7 @@ end "" function variable_ne_branch_voltage(pm::AbstractQCWRModel; kwargs...) - Memento.error(_LOGGER, "variable_ne_branch_voltage is not yet supported for QC formulations, open an issue if you would like this feature.") + @error(_LOGGER, "variable_ne_branch_voltage is not yet supported for QC formulations, open an issue if you would like this feature.") end "" diff --git a/src/io/common.jl b/src/io/common.jl index a2ca2123..05ce9856 100644 --- a/src/io/common.jl +++ b/src/io/common.jl @@ -22,7 +22,7 @@ function parse_file(io::IO; import_all=false, validate=true, filetype="json") elseif filetype == "json" pm_data = PowerModels.parse_json(io; validate=validate) else - Memento.error(_LOGGER, "Unrecognized filetype: \".$filetype\", Supported extensions are \".raw\", \".m\" and \".json\"") + @error(_LOGGER, "Unrecognized filetype: \".$filetype\", Supported extensions are \".raw\", \".m\" and \".json\"") end return pm_data @@ -71,7 +71,7 @@ function export_file(file::AbstractString, data::Dict{String, Any}) export_file(io, data, filetype=split(lowercase(file), '.')[end]) end else - Memento.error(_LOGGER, "The file must have an extension") + @error(_LOGGER, "The file must have an extension") end end @@ -85,7 +85,7 @@ function export_file(io::IO, data::Dict{String, Any}; filetype="json") stringdata = JSON.json(data) write(io, stringdata) else - Memento.error(_LOGGER, "Unrecognized filetype: \".$filetype\", Supported extensions are \".raw\", \".m\" and \".json\"") + @error(_LOGGER, "Unrecognized filetype: \".$filetype\", Supported extensions are \".raw\", \".m\" and \".json\"") end end diff --git a/src/io/json.jl b/src/io/json.jl index 432d3236..007d402c 100644 --- a/src/io/json.jl +++ b/src/io/json.jl @@ -14,7 +14,7 @@ function parse_json(io::Union{IO,String}; kwargs...)::Dict{String,Any} _jsonver2juliaver!(pm_data) if haskey(pm_data, "conductors") - Memento.warn(_LOGGER, "The JSON data contains the conductor parameter, but only single conductors are supported. Consider using PowerModelsDistribution.") + @warn(_LOGGER, "The JSON data contains the conductor parameter, but only single conductors are supported. Consider using PowerModelsDistribution.") end if get(kwargs, :validate, true) diff --git a/src/io/matpower.jl b/src/io/matpower.jl index a0777a45..3822afb8 100644 --- a/src/io/matpower.jl +++ b/src/io/matpower.jl @@ -132,7 +132,7 @@ function _parse_matpower_string(data_string::String) if func_name != nothing case["name"] = func_name else - Memento.warn(_LOGGER, string("no case name found in matpower file. The file seems to be missing \"function mpc = ...\"")) + @warn(_LOGGER, string("no case name found in matpower file. The file seems to be missing \"function mpc = ...\"")) case["name"] = "no_name_found" end @@ -140,14 +140,14 @@ function _parse_matpower_string(data_string::String) if haskey(matlab_data, "mpc.version") case["source_version"] = matlab_data["mpc.version"] else - Memento.warn(_LOGGER, string("no case version found in matpower file. The file seems to be missing \"mpc.version = ...\"")) + @warn(_LOGGER, string("no case version found in matpower file. The file seems to be missing \"mpc.version = ...\"")) case["source_version"] = "0.0.0+" end if haskey(matlab_data, "mpc.baseMVA") case["baseMVA"] = matlab_data["mpc.baseMVA"] else - Memento.warn(_LOGGER, string("no baseMVA found in matpower file. The file seems to be missing \"mpc.baseMVA = ...\"")) + @warn(_LOGGER, string("no baseMVA found in matpower file. The file seems to be missing \"mpc.baseMVA = ...\"")) case["baseMVA"] = 1.0 end @@ -162,7 +162,7 @@ function _parse_matpower_string(data_string::String) end case["bus"] = buses else - Memento.error(string("no bus table found in matpower file. The file seems to be missing \"mpc.bus = [...];\"")) + @error(string("no bus table found in matpower file. The file seems to be missing \"mpc.bus = [...];\"")) end if haskey(matlab_data, "mpc.gen") @@ -175,7 +175,7 @@ function _parse_matpower_string(data_string::String) end case["gen"] = gens else - Memento.error(string("no gen table found in matpower file. The file seems to be missing \"mpc.gen = [...];\"")) + @error(string("no gen table found in matpower file. The file seems to be missing \"mpc.gen = [...];\"")) end if haskey(matlab_data, "mpc.branch") @@ -188,7 +188,7 @@ function _parse_matpower_string(data_string::String) end case["branch"] = branches else - Memento.error(string("no branch table found in matpower file. The file seems to be missing \"mpc.branch = [...];\"")) + @error(string("no branch table found in matpower file. The file seems to be missing \"mpc.branch = [...];\"")) end if haskey(matlab_data, "mpc.dcline") @@ -235,7 +235,7 @@ function _parse_matpower_string(data_string::String) case["bus_name"] = bus_names if length(case["bus_name"]) != length(case["bus"]) - Memento.error(_LOGGER, "incorrect Matpower file, the number of bus names ($(length(case["bus_name"]))) is inconsistent with the number of buses ($(length(case["bus"]))).\n") + @error(_LOGGER, "incorrect Matpower file, the number of bus names ($(length(case["bus_name"]))) is inconsistent with the number of buses ($(length(case["bus"]))).\n") end end @@ -250,7 +250,7 @@ function _parse_matpower_string(data_string::String) case["gencost"] = gencost if length(case["gencost"]) != length(case["gen"]) && length(case["gencost"]) != 2*length(case["gen"]) - Memento.error(_LOGGER, "incorrect Matpower file, the number of generator cost functions ($(length(case["gencost"]))) is inconsistent with the number of generators ($(length(case["gen"]))).\n") + @error(_LOGGER, "incorrect Matpower file, the number of generator cost functions ($(length(case["gencost"]))) is inconsistent with the number of generators ($(length(case["gen"]))).\n") end end @@ -265,7 +265,7 @@ function _parse_matpower_string(data_string::String) case["dclinecost"] = dclinecosts if length(case["dclinecost"]) != length(case["dcline"]) - Memento.error(_LOGGER, "incorrect Matpower file, the number of dcline cost functions ($(length(case["dclinecost"]))) is inconsistent with the number of dclines ($(length(case["dcline"]))).\n") + @error(_LOGGER, "incorrect Matpower file, the number of dcline cost functions ($(length(case["dclinecost"]))) is inconsistent with the number of dclines ($(length(case["dcline"]))).\n") end end @@ -287,10 +287,10 @@ function _parse_matpower_string(data_string::String) push!(tbl, row_data) end case[case_name] = tbl - Memento.info(_LOGGER, "extending matpower format with data: $(case_name) $(length(tbl))x$(length(tbl[1])-1)") + @info(_LOGGER, "extending matpower format with data: $(case_name) $(length(tbl))x$(length(tbl[1])-1)") else case[case_name] = value - Memento.info(_LOGGER, "extending matpower format with constant data: $(case_name)") + @info(_LOGGER, "extending matpower format with constant data: $(case_name)") end end end @@ -323,7 +323,7 @@ function _mp_cost_data(cost_row) cost_values = [_IM.check_type(Float64, x) for x in cost_row[5:length(cost_row)]] if cost_data["model"] == 1: if length(cost_values)%2 != 0 - Memento.error(_LOGGER, "incorrect matpower file, odd number of pwl cost function values") + @error(_LOGGER, "incorrect matpower file, odd number of pwl cost function values") end for i in 0:(length(cost_values)/2-1) p_idx = 1+2*i @@ -529,7 +529,7 @@ end "adds dcline costs, if gen costs exist" function _add_dcline_costs!(data::Dict{String,Any}) if length(data["gencost"]) > 0 && length(data["dclinecost"]) <= 0 && length(data["dcline"]) > 0 - Memento.warn(_LOGGER, "added zero cost function data for dclines") + @warn(_LOGGER, "added zero cost function data for dclines") model = data["gencost"][1]["model"] if model == 1 for (i, dcline) in enumerate(data["dcline"]) @@ -568,10 +568,10 @@ function _merge_cost_data!(data::Dict{String,Any}) if length(gen) != length(gencost) if length(gencost) > length(gen) - Memento.warn(_LOGGER, "The last $(length(gencost) - length(gen)) generator cost records will be ignored due to too few generator records.") + @warn(_LOGGER, "The last $(length(gencost) - length(gen)) generator cost records will be ignored due to too few generator records.") gencost = gencost[1:length(gen)] else - Memento.warn(_LOGGER, "The number of generators ($(length(gen))) does not match the number of generator cost records ($(length(gencost))).") + @warn(_LOGGER, "The number of generators ($(length(gen))) does not match the number of generator cost records ($(length(gencost))).") end end @@ -594,7 +594,7 @@ function _merge_cost_data!(data::Dict{String,Any}) dclinecost = data["dclinecost"] if length(dcline) != length(dclinecost) - Memento.warn(_LOGGER, "The number of dclines ($(length(dcline))) does not match the number of dcline cost records ($(length(dclinecost))).") + @warn(_LOGGER, "The number of dclines ($(length(dcline))) does not match the number of dcline cost records ($(length(dclinecost))).") end for (i, dclc) in enumerate(dclinecost) @@ -642,10 +642,10 @@ function _merge_generic_data!(data::Dict{String,Any}) push!(key_to_delete, k) if length(mp_matrix) != length(v) - Memento.error(_LOGGER, "failed to extend the matpower matrix \"$(mp_name)\" with the matrix \"$(k)\" because they do not have the same number of rows, $(length(mp_matrix)) and $(length(v)) respectively.") + @error(_LOGGER, "failed to extend the matpower matrix \"$(mp_name)\" with the matrix \"$(k)\" because they do not have the same number of rows, $(length(mp_matrix)) and $(length(v)) respectively.") end - Memento.info(_LOGGER, "extending matpower format by appending matrix \"$(k)\" in to \"$(mp_name)\"") + @info(_LOGGER, "extending matpower format by appending matrix \"$(k)\" in to \"$(mp_name)\"") for (i, row) in enumerate(mp_matrix) merge_row = v[i] @@ -654,7 +654,7 @@ function _merge_generic_data!(data::Dict{String,Any}) delete!(merge_row, "source_id") for key in keys(merge_row) if haskey(row, key) - Memento.error(_LOGGER, "failed to extend the matpower matrix \"$(mp_name)\" with the matrix \"$(k)\" because they both share \"$(key)\" as a column name.") + @error(_LOGGER, "failed to extend the matpower matrix \"$(mp_name)\" with the matrix \"$(k)\" because they both share \"$(key)\" as a column name.") end row[key] = merge_row[key] end @@ -691,7 +691,7 @@ end function _check_keys(data, keys) for key in keys if haskey(data, key) - Memento.error(_LOGGER, "attempting to overwrite value of $(key) in PowerModels data,\n$(data)") + @error(_LOGGER, "attempting to overwrite value of $(key) in PowerModels data,\n$(data)") end end end @@ -708,7 +708,7 @@ end "Export power network data in the matpower format" function export_matpower(io::IO, data::Dict{String,Any}) if _IM.ismultinetwork(data) - Memento.error(_LOGGER, "export_matpower does not yet support multinetwork data") + @error(_LOGGER, "export_matpower does not yet support multinetwork data") end data = deepcopy(data) @@ -837,7 +837,7 @@ function export_matpower(io::IO, data::Dict{String,Any}) i = 1 for (idx,gen) in sort(collect(generators), by=(x) -> x.first) if idx != gen["index"] - Memento.warn(_LOGGER, "The index of the generator does not match the matpower assigned index. Any data that uses generator indexes for reference is corrupted."); + @warn(_LOGGER, "The index of the generator does not match the matpower assigned index. Any data that uses generator indexes for reference is corrupted."); end println(io, "\t", gen["gen_bus"], @@ -880,7 +880,7 @@ function export_matpower(io::IO, data::Dict{String,Any}) i = 1 for (idx,strg) in sort(collect(storage), by=(x) -> x.first) if idx != strg["index"] - Memento.warn(_LOGGER, "The index of the storage does not match the matpower assigned index. Any data that uses storage indexes for reference is corrupted."); + @warn(_LOGGER, "The index of the storage does not match the matpower assigned index. Any data that uses storage indexes for reference is corrupted."); end println(io, "\t", strg["storage_bus"], "\t", _get_default(strg, "ps"), @@ -914,7 +914,7 @@ function export_matpower(io::IO, data::Dict{String,Any}) i = 1 for (idx,branch) in sort(collect(branches), by=(x) -> x.first) if idx != branch["index"] - Memento.warn(_LOGGER, "The index of the branch does not match the matpower assigned index. Any data that uses branch indexes for reference is corrupted."); + @warn(_LOGGER, "The index of the branch does not match the matpower assigned index. Any data that uses branch indexes for reference is corrupted."); end println(io, "\t", _get_default(branch, "f_bus"), @@ -1017,7 +1017,7 @@ function export_matpower(io::IO, data::Dict{String,Any}) i = 1 for (idx,branch) in sort(collect(ne_branches), by=(x) -> x.first) if idx != branch["index"] - Memento.warn(_LOGGER, "The index of the ne_branch does not match the matpower assigned index. Any data that uses branch indexes for reference is corrupted."); + @warn(_LOGGER, "The index of the ne_branch does not match the matpower assigned index. Any data that uses branch indexes for reference is corrupted."); end println(io, "\t", branch["f_bus"], @@ -1121,7 +1121,7 @@ function _export_extra_data(io::IO, data::Dict{String,<:Any}, component, exclude # check if dict of dicts for (key, value) in data[component] if !isa(value, Dict) - Memento.warn(_LOGGER, "skipping export $(component), does not appear to be a component Dict") + @warn(_LOGGER, "skipping export $(component), does not appear to be a component Dict") return end end @@ -1163,7 +1163,7 @@ function _export_extra_data(io::IO, data::Dict{String,<:Any}, component, exclude for idx in key_order c = comp_dict[idx] if haskey(c, "index") && i != c["index"] - Memento.warn(_LOGGER, "The index of a component does not match the implicit matpower index. Any data that uses component indexes for reference is corrupted.") + @warn(_LOGGER, "The index of a component does not match the implicit matpower index. Any data that uses component indexes for reference is corrupted.") end for field in included_fields @@ -1182,7 +1182,7 @@ function _export_extra_data(io::IO, data::Dict{String,<:Any}, component, exclude elseif typeof(value) <: Real print(io, "$(value)") else - Memento.warn(_LOGGER, "unable to export $(typeof(value)) value for '$(field)' in component list $(component), not a string or numeric value") + @warn(_LOGGER, "unable to export $(typeof(value)) value for '$(field)' in component list $(component), not a string or numeric value") print(io, "NaN") end else @@ -1209,7 +1209,7 @@ function _export_cost_data(io::IO, components::Dict{Int,Dict}, prefix::String) for (i,comp) in components if length(comp["cost"]) != ncost || comp["model"] != model - Memento.warn(_LOGGER, "heterogeneous cost functions will be ommited in Matpower data") + @warn(_LOGGER, "heterogeneous cost functions will be ommited in Matpower data") return end end diff --git a/src/io/psse.jl b/src/io/psse.jl index 9e96053f..0d122895 100644 --- a/src/io/psse.jl +++ b/src/io/psse.jl @@ -43,7 +43,7 @@ function _get_bus_value(bus_i, field, pm_data) end end - Memento.warn(_LOGGER, "Could not find bus $bus_i, returning 0 for field $field") + @warn(_LOGGER, "Could not find bus $bus_i, returning 0 for field $field") return 0 end @@ -339,7 +339,7 @@ function _psse2pm_shunt!(pm_data::Dict, pti_data::Dict, import_all::Bool) end if haskey(pti_data, "SWITCHED SHUNT") - Memento.info(_LOGGER, "Switched shunt converted to fixed shunt, with default value gs=0.0") + @info(_LOGGER, "Switched shunt converted to fixed shunt, with default value gs=0.0") for shunt in pti_data["SWITCHED SHUNT"] sub_data = Dict{String,Any}() @@ -381,17 +381,17 @@ function _psse2pm_transformer!(pm_data::Dict, pti_data::Dict, import_all::Bool) for transformer in pti_data["TRANSFORMER"] if !(transformer["CZ"] in [1,2,3]) - Memento.warn(_LOGGER, "transformer CZ value outside of valid bounds assuming the default value of 1. Given $(transformer["CZ"]), should be 1, 2 or 3") + @warn(_LOGGER, "transformer CZ value outside of valid bounds assuming the default value of 1. Given $(transformer["CZ"]), should be 1, 2 or 3") transformer["CZ"] = 1 end if !(transformer["CW"] in [1,2,3]) - Memento.warn(_LOGGER, "transformer CW value outside of valid bounds assuming the default value of 1. Given $(transformer["CW"]), should be 1, 2 or 3") + @warn(_LOGGER, "transformer CW value outside of valid bounds assuming the default value of 1. Given $(transformer["CW"]), should be 1, 2 or 3") transformer["CW"] = 1 end if !(transformer["CM"] in [1,2]) - Memento.warn(_LOGGER, "transformer CM value outside of valid bounds assuming the default value of 1. Given $(transformer["CM"]), should be 1 or 2") + @warn(_LOGGER, "transformer CM value outside of valid bounds assuming the default value of 1. Given $(transformer["CM"]), should be 1 or 2") transformer["CM"] = 1 end @@ -645,7 +645,7 @@ function _psse2pm_dcline!(pm_data::Dict, pti_data::Dict, import_all::Bool) if haskey(pti_data, "TWO-TERMINAL DC") for dcline in pti_data["TWO-TERMINAL DC"] - Memento.info(_LOGGER, "Two-Terminal DC lines are supported via a simple *lossless* dc line model approximated by two generators.") + @info(_LOGGER, "Two-Terminal DC lines are supported via a simple *lossless* dc line model approximated by two generators.") sub_data = Dict{String,Any}() # Unit conversions? @@ -672,7 +672,7 @@ function _psse2pm_dcline!(pm_data::Dict, pti_data::Dict, import_all::Bool) push!(anmn, dcline[key]) else push!(anmn, 0) - Memento.warn(_LOGGER, "$key outside reasonable limits, setting to 0 degress") + @warn(_LOGGER, "$key outside reasonable limits, setting to 0 degress") end end @@ -704,7 +704,7 @@ function _psse2pm_dcline!(pm_data::Dict, pti_data::Dict, import_all::Bool) end if haskey(pti_data, "VOLTAGE SOURCE CONVERTER") - Memento.info(_LOGGER, "VSC-HVDC lines are supported via a dc line model approximated by two generators and an associated loss.") + @info(_LOGGER, "VSC-HVDC lines are supported via a dc line model approximated by two generators and an associated loss.") for dcline in pti_data["VOLTAGE SOURCE CONVERTER"] # Converter buses : is the distinction between ac and dc side meaningful? dcside, acside = dcline["CONVERTER BUSES"] @@ -861,7 +861,7 @@ end Parses directly from iostream """ function parse_psse(io::IO; kwargs...)::Dict - Memento.info(_LOGGER, "The PSS(R)E parser currently supports buses, loads, shunts, generators, branches, transformers, and dc lines") + @info(_LOGGER, "The PSS(R)E parser currently supports buses, loads, shunts, generators, branches, transformers, and dc lines") pti_data = parse_pti(io) pm = _pti_to_powermodels!(pti_data; kwargs...) return pm diff --git a/src/io/pti.jl b/src/io/pti.jl index 908a1f7f..f4bb2fe7 100644 --- a/src/io/pti.jl +++ b/src/io/pti.jl @@ -487,7 +487,7 @@ function _parse_elements(elements::Array, dtypes::Array, defaults::Dict, section data = Dict{String,Any}() if length(elements) > length(dtypes) - Memento.warn(_LOGGER, "ignoring $(length(elements) - length(dtypes)) extra values in section $section, only $(length(dtypes)) items are defined") + @warn(_LOGGER, "ignoring $(length(elements) - length(dtypes)) extra values in section $section, only $(length(dtypes)) items are defined") elements = elements[1:length(dtypes)] end @@ -513,7 +513,7 @@ function _parse_elements(elements::Array, dtypes::Array, defaults::Dict, section if isa(message, Meta.ParseError) data[field] = element else - Memento.error(_LOGGER, "value '$element' for $field in section $section is not of type $dtype.") + @error(_LOGGER, "value '$element' for $field in section $section is not of type $dtype.") end end end @@ -532,7 +532,7 @@ function _parse_elements(elements::Array, dtypes::Array, defaults::Dict, section if !(section == "SWITCHED SHUNT" && startswith(missing_str, "N")) && !(section == "MULTI-SECTION LINE" && startswith(missing_str, "DUM")) && !(section == "IMPEDANCE CORRECTION" && startswith(missing_str, "T")) - Memento.warn(_LOGGER, "The following fields in $section are missing: $missing_str") + @warn(_LOGGER, "The following fields in $section are missing: $missing_str") end end =# @@ -554,7 +554,7 @@ function _parse_line_element!(data::Dict, elements::Array, section::AbstractStri missing_fields = [] for (i, (field, dtype)) in enumerate(_pti_dtypes[section]) if i > length(elements) - Memento.debug(_LOGGER, "Have run out of elements in $section at $field") + @debug(_LOGGER, "Have run out of elements in $section at $field") push!(missing_fields, field) continue else @@ -575,7 +575,7 @@ function _parse_line_element!(data::Dict, elements::Array, section::AbstractStri if isa(message, Meta.ParseError) data[field] = element else - Memento.error(_LOGGER, "value '$element' for $field in section $section is not of type $dtype.") + @error(_LOGGER, "value '$element' for $field in section $section is not of type $dtype.") end end end @@ -588,7 +588,7 @@ function _parse_line_element!(data::Dict, elements::Array, section::AbstractStri if !(section == "SWITCHED SHUNT" && startswith(missing_str, "N")) && !(section == "MULTI-SECTION LINE" && startswith(missing_str, "DUM")) && !(section == "IMPEDANCE CORRECTION" && startswith(missing_str, "T")) - Memento.warn(_LOGGER, "The following fields in $section are missing: $missing_str") + @warn(_LOGGER, "The following fields in $section are missing: $missing_str") end end end @@ -608,7 +608,7 @@ are also extracted separately, and `Array{Array{String}, String}` is returned. """ function _get_line_elements(line::AbstractString) if count(i->(i=="'"), line) % 2 == 1 - throw(Memento.error(_LOGGER, "There are an uneven number of single-quotes in \"{line}\", the line cannot be parsed.")) + throw(@error(_LOGGER, "There are an uneven number of single-quotes in \"{line}\", the line cannot be parsed.")) end line_comment = split(line, _comment_split, limit=2) @@ -652,9 +652,9 @@ function _parse_pti_data(data_io::IO) end if length(elements) > 1 - Memento.warn(_LOGGER, "At line $line_number, new section started with '0', but additional non-comment data is present. Pattern '^\\s*0\\s*[/]*.*' is reserved for section start/end.") + @warn(_LOGGER, "At line $line_number, new section started with '0', but additional non-comment data is present. Pattern '^\\s*0\\s*[/]*.*' is reserved for section start/end.") elseif length(comment) > 0 - Memento.debug(_LOGGER, "At line $line_number, switched to $section") + @debug(_LOGGER, "At line $line_number, switched to $section") end if !isempty(sections) @@ -673,14 +673,14 @@ function _parse_pti_data(data_io::IO) continue end - Memento.debug(_LOGGER, join(["Section:", section], " ")) + @debug(_LOGGER, join(["Section:", section], " ")) if !(section in ["CASE IDENTIFICATION","TRANSFORMER","VOLTAGE SOURCE CONVERTER","MULTI-TERMINAL DC","TWO-TERMINAL DC","GNE DEVICE"]) section_data = Dict{String,Any}() try _parse_line_element!(section_data, elements, section) catch message - throw(Memento.error(_LOGGER, "Parsing failed at line $line_number: $(sprint(showerror, message))")) + throw(@error(_LOGGER, "Parsing failed at line $line_number: $(sprint(showerror, message))")) end elseif section == "CASE IDENTIFICATION" @@ -688,11 +688,11 @@ function _parse_pti_data(data_io::IO) try _parse_line_element!(section_data, elements, section) catch message - throw(Memento.error(_LOGGER, "Parsing failed at line $line_number: $(sprint(showerror, message))")) + throw(@error(_LOGGER, "Parsing failed at line $line_number: $(sprint(showerror, message))")) end if section_data["REV"] != "" && section_data["REV"] < 33 - Memento.warn(_LOGGER, "Version $(section_data["REV"]) of PTI format is unsupported, parser may not function correctly.") + @warn(_LOGGER, "Version $(section_data["REV"]) of PTI format is unsupported, parser may not function correctly.") end else section_data["Comment_Line_$(line_number - 1)"] = line @@ -711,7 +711,7 @@ function _parse_pti_data(data_io::IO) winding = "THREE-WINDING" skip_lines = 4 else - Memento.error(_LOGGER, "Cannot detect type of Transformer") + @error(_LOGGER, "Cannot detect type of Transformer") end try @@ -730,7 +730,7 @@ function _parse_pti_data(data_io::IO) end end catch message - throw(Memento.error(_LOGGER, "Parsing failed at line $line_number: $(sprint(showerror, message))")) + throw(@error(_LOGGER, "Parsing failed at line $line_number: $(sprint(showerror, message))")) end elseif section == "VOLTAGE SOURCE CONVERTER" @@ -739,7 +739,7 @@ function _parse_pti_data(data_io::IO) try _parse_line_element!(section_data, elements, section) catch message - throw(Memento.error(_LOGGER, "Parsing failed at line $line_number: $(sprint(showerror, message))")) + throw(@error(_LOGGER, "Parsing failed at line $line_number: $(sprint(showerror, message))")) end skip_sublines = 2 continue @@ -775,7 +775,7 @@ function _parse_pti_data(data_io::IO) try _parse_line_element!(section_data, elements, section) catch message - throw(Memento.error(_LOGGER, "Parsing failed at line $line_number: $(sprint(showerror, message))")) + throw(@error(_LOGGER, "Parsing failed at line $line_number: $(sprint(showerror, message))")) end elseif section == "MULTI-TERMINAL DC" @@ -784,7 +784,7 @@ function _parse_pti_data(data_io::IO) try _parse_line_element!(section_data, elements, section) catch message - throw(Memento.error(_LOGGER, "Parsing failed at line $line_number: $(sprint(showerror, message))")) + throw(@error(_LOGGER, "Parsing failed at line $line_number: $(sprint(showerror, message))")) end if section_data["NCONV"] > 0 @@ -809,7 +809,7 @@ function _parse_pti_data(data_io::IO) try _parse_line_element!(subsection_data, elements, "$section $subsection") catch message - throw(Memento.error(_LOGGER, "Parsing failed at line $line_number: $(sprint(showerror, message))")) + throw(@error(_LOGGER, "Parsing failed at line $line_number: $(sprint(showerror, message))")) end if haskey(section_data, "$(subsection[2:end])") @@ -843,11 +843,11 @@ function _parse_pti_data(data_io::IO) elseif section == "GNE DEVICE" # TODO: handle multiple lines of GNE Device - Memento.warn(_LOGGER, "GNE DEVICE parsing is not supported.") + @warn(_LOGGER, "GNE DEVICE parsing is not supported.") end end if subsection != "" - Memento.debug(_LOGGER, "appending data") + @debug(_LOGGER, "appending data") end if haskey(pti_data, section) @@ -890,7 +890,7 @@ function parse_pti(io::IO)::Dict try pti_data["CASE IDENTIFICATION"][1]["NAME"] = match(r"^\$", lowercase(io.name)).captures[1] catch - Memento.info(_LOGGER, "unable to recover case name from io file name in parse_pti") + @info(_LOGGER, "unable to recover case name from io file name in parse_pti") end return pti_data @@ -918,7 +918,7 @@ function _populate_defaults!(data::Dict) sub_component[sub_field] = sub_component_defaults[sub_field] catch msg if isa(msg, KeyError) - Memento.warn(_LOGGER, "'$sub_field' in '$field' in '$section' has no default value") + @warn(_LOGGER, "'$sub_field' in '$field' in '$section' has no default value") else rethrow(msg) end @@ -931,7 +931,7 @@ function _populate_defaults!(data::Dict) component[field] = component_defaults[field] catch msg if isa(msg, KeyError) - Memento.warn(_LOGGER, "'$field' in '$section' has no default value") + @warn(_LOGGER, "'$field' in '$section' has no default value") else rethrow(msg) end @@ -999,7 +999,7 @@ Things that are not exported if you use `import_all = true` to make the PowerMod """ function export_pti(io::IO, data::Dict{String,Any}) if _IM.ismultinetwork(data) - Memento.error(_LOGGER, "export_pti does not yet support multinetwork data") + @error(_LOGGER, "export_pti does not yet support multinetwork data") end # Info for items that will be exported @@ -1011,7 +1011,7 @@ function export_pti(io::IO, data::Dict{String,Any}) for item in incompatible_items if haskey(data, item) && length(data[item]) > 0 components = length(data[item]) - Memento.warn(_LOGGER, string("Skipping export of the $(components) $(item) items because it is not suported in the PSSE 33 .raw file")) + @warn(_LOGGER, string("Skipping export of the $(components) $(item) items because it is not suported in the PSSE 33 .raw file")) end end @@ -1024,7 +1024,7 @@ function export_pti(io::IO, data::Dict{String,Any}) if haskey(data, item) components = length(data[item]) if components > 0 - Memento.warn(_LOGGER, string("Skipping export of the $(components) $(item) data because is not yet implemented")) + @warn(_LOGGER, string("Skipping export of the $(components) $(item) data because is not yet implemented")) end end end diff --git a/src/prob/opf.jl b/src/prob/opf.jl index 72d46216..8b1ac761 100644 --- a/src/prob/opf.jl +++ b/src/prob/opf.jl @@ -172,7 +172,7 @@ end "" function build_opf_ptdf(pm::AbstractPowerModel) - Memento.error(_LOGGER, "build_opf_ptdf is only valid for DCPPowerModels") + @error(_LOGGER, "build_opf_ptdf is only valid for DCPPowerModels") end "" diff --git a/src/prob/pf.jl b/src/prob/pf.jl index 4b94d92f..63676c64 100644 --- a/src/prob/pf.jl +++ b/src/prob/pf.jl @@ -300,7 +300,7 @@ function compute_ac_pf(pf_data::PowerFlowData; kwargs...) converged = pf_result.x_converged || pf_result.f_converged if !converged - Memento.warn(_LOGGER, "ac power flow solver convergence failed! use `show_trace = true` for more details") + @warn(_LOGGER, "ac power flow solver convergence failed! use `show_trace = true` for more details") else data = pf_data.data bus_gens = pf_data.bus_gens @@ -403,7 +403,7 @@ function compute_ac_pf!(pf_data::PowerFlowData; kwargs...) pf_result = _compute_ac_pf(pf_data; kwargs...) if !(pf_result.x_converged || pf_result.f_converged) - Memento.warn(_LOGGER, "ac power flow solver convergence failed! use `show_trace = true` for more details") + @warn(_LOGGER, "ac power flow solver convergence failed! use `show_trace = true` for more details") end data = pf_data.data diff --git a/src/util/flow_limit_cuts.jl b/src/util/flow_limit_cuts.jl index 1c8c3f27..1e50dbe2 100644 --- a/src/util/flow_limit_cuts.jl +++ b/src/util/flow_limit_cuts.jl @@ -15,7 +15,7 @@ function solve_opf_branch_power_cuts(file::String, model_type::Type, optimizer; end function solve_opf_branch_power_cuts!(data::Dict{String,<:Any}, model_type::Type, optimizer; solution_processors=[], max_iter::Int=100, time_limit::Float64=3600.0) - Memento.info(_LOGGER, "maximum cut iterations set to value of $max_iter") + @info(_LOGGER, "maximum cut iterations set to value of $max_iter") for (i,branch) in data["branch"] if haskey(branch, "rate_a") @@ -52,7 +52,7 @@ function solve_opf_branch_power_cuts!(data::Dict{String,<:Any}, model_type::Type #println(branch["index"], rate_a, mva_fr, mva_to) if mva_fr > rate_a || mva_to > rate_a - Memento.info(_LOGGER, "activate rate_a on branch $(branch["index"])") + @info(_LOGGER, "activate rate_a on branch $(branch["index"])") branch["rate_a"] = branch["rate_a_inactive"] delete!(branch, "rate_a_inactive") @@ -73,7 +73,7 @@ function solve_opf_branch_power_cuts!(data::Dict{String,<:Any}, model_type::Type #print_summary(result["solution"]) else - Memento.info(_LOGGER, "flow cuts converged in $iteration iterations") + @info(_LOGGER, "flow cuts converged in $iteration iterations") end end @@ -102,7 +102,7 @@ function solve_opf_ptdf_branch_power_cuts(file::String, optimizer; kwargs...) end function solve_opf_ptdf_branch_power_cuts!(data::Dict{String,<:Any}, optimizer; max_iter::Int=100, time_limit::Float64=3600.0, full_inverse=false) - Memento.info(_LOGGER, "maximum cut iterations set to value of $max_iter") + @info(_LOGGER, "maximum cut iterations set to value of $max_iter") for (i,branch) in data["branch"] if haskey(branch, "rate_a") @@ -150,7 +150,7 @@ function solve_opf_ptdf_branch_power_cuts!(data::Dict{String,<:Any}, optimizer; end if mva_fr > rate_a || mva_to > rate_a - Memento.info(_LOGGER, "activate rate_a on branch $(branch["index"])") + @info(_LOGGER, "activate rate_a on branch $(branch["index"])") # update data model branch["rate_a"] = branch["rate_a_inactive"] @@ -183,7 +183,7 @@ function solve_opf_ptdf_branch_power_cuts!(data::Dict{String,<:Any}, optimizer; #print_summary(result["solution"]) else - Memento.info(_LOGGER, "flow cuts converged in $iteration iterations") + @info(_LOGGER, "flow cuts converged in $iteration iterations") end end diff --git a/src/util/obbt.jl b/src/util/obbt.jl index 0b2e4741..577bfe36 100644 --- a/src/util/obbt.jl +++ b/src/util/obbt.jl @@ -80,12 +80,12 @@ function solve_obbt_opf!(data::Dict{String,<:Any}, optimizer; termination::Symbol = :avg, kwargs...) - Memento.info(_LOGGER, "maximum OBBT iterations set to default value of $max_iter") - Memento.info(_LOGGER, "maximum time limit for OBBT set to default value of $time_limit seconds") + @info(_LOGGER, "maximum OBBT iterations set to default value of $max_iter") + @info(_LOGGER, "maximum time limit for OBBT set to default value of $time_limit seconds") model_relaxation = instantiate_model(data, model_type, PowerModels.build_opf) - (_IM.ismultinetwork(model_relaxation, pm_it_sym)) && (Memento.error(_LOGGER, "OBBT is not supported for multi-networks")) - (ismulticonductor(model_relaxation)) && (Memento.error(_LOGGER, "OBBT is not supported for multi-conductor networks")) + (_IM.ismultinetwork(model_relaxation, pm_it_sym)) && (@error(_LOGGER, "OBBT is not supported for multi-networks")) + (ismulticonductor(model_relaxation)) && (@error(_LOGGER, "OBBT is not supported for multi-conductor networks")) # check for model_type compatability with OBBT _check_variables(model_relaxation) @@ -94,7 +94,7 @@ function solve_obbt_opf!(data::Dict{String,<:Any}, optimizer; _check_obbt_options(upper_bound, rel_gap_tol, upper_bound_constraint) # check termination norm criteria for obbt - (termination != :avg && termination != :max) && (Memento.error(_LOGGER, "OBBT termination criteria can only be :max or :avg")) + (termination != :avg && termination != :max) && (@error(_LOGGER, "OBBT termination criteria can only be :max or :avg")) # pass status status_pass = [JuMP.LOCALLY_SOLVED, JuMP.OPTIMAL] @@ -103,18 +103,18 @@ function solve_obbt_opf!(data::Dict{String,<:Any}, optimizer; result_relaxation = optimize_model!(model_relaxation, optimizer=optimizer) current_relaxation_objective = result_relaxation["objective"] if upper_bound < current_relaxation_objective - Memento.error(_LOGGER, "the upper bound provided to OBBT is not a valid ACOPF upper bound") + @error(_LOGGER, "the upper bound provided to OBBT is not a valid ACOPF upper bound") end if !(result_relaxation["termination_status"] in status_pass) - Memento.warn(_LOGGER, "initial relaxation solve status is $(result_relaxation["termination_status"])") + @warn(_LOGGER, "initial relaxation solve status is $(result_relaxation["termination_status"])") if result_relaxation["termination_status"] == :SubOptimal - Memento.warn(_LOGGER, "continuing with the bound-tightening algorithm") + @warn(_LOGGER, "continuing with the bound-tightening algorithm") end end current_rel_gap = Inf if !isinf(upper_bound) current_rel_gap = (upper_bound - current_relaxation_objective)/upper_bound - Memento.info(_LOGGER, "Initial relaxation gap = $current_rel_gap") + @info(_LOGGER, "Initial relaxation gap = $current_rel_gap") end @@ -190,7 +190,7 @@ function solve_obbt_opf!(data::Dict{String,<:Any}, optimizer; nlb = floor(10.0^precision * JuMP.objective_value(model_bt.model))/(10.0^precision) (nlb > vm_lb[bus]) && (lb = nlb) else - Memento.warn(_LOGGER, "BT minimization problem for vm[$bus] errored - change tolerances.") + @warn(_LOGGER, "BT minimization problem for vm[$bus] errored - change tolerances.") continue end @@ -202,14 +202,14 @@ function solve_obbt_opf!(data::Dict{String,<:Any}, optimizer; nub = ceil(10.0^precision * JuMP.objective_value(model_bt.model))/(10.0^precision) (nub < vm_ub[bus]) && (ub = nub) else - Memento.warn(_LOGGER, "BT maximization problem for vm[$bus] errored - change tolerances.") + @warn(_LOGGER, "BT maximization problem for vm[$bus] errored - change tolerances.") continue end end_time = time() - start_time max_vm_iteration_time = max(end_time, max_vm_iteration_time) # sanity checks - (lb > ub) && (Memento.warn(_LOGGER, "bt lb > ub - adjust tolerances in optimizer to avoid issue"); continue) + (lb > ub) && (@warn(_LOGGER, "bt lb > ub - adjust tolerances in optimizer to avoid issue"); continue) (!isnan(lb) && lb > vm_ub[bus]) && (lb = vm_lb[bus]) (!isnan(ub) && ub < vm_lb[bus]) && (ub = vm_ub[bus]) isnan(lb) && (lb = vm_lb[bus]) @@ -258,7 +258,7 @@ function solve_obbt_opf!(data::Dict{String,<:Any}, optimizer; nlb = floor(10.0^precision * JuMP.objective_value(model_bt.model))/(10.0^precision) (nlb > td_lb[bp]) && (lb = nlb) else - Memento.warn(_LOGGER, "BT minimization problem for td[$bp] errored - change tolerances") + @warn(_LOGGER, "BT minimization problem for td[$bp] errored - change tolerances") continue end @@ -270,14 +270,14 @@ function solve_obbt_opf!(data::Dict{String,<:Any}, optimizer; nub = ceil(10.0^precision * JuMP.objective_value(model_bt.model))/(10.0^precision) (nub < td_ub[bp]) && (ub = nub) else - Memento.warn(_LOGGER, "BT maximization problem for td[$bp] errored - change tolerances.") + @warn(_LOGGER, "BT maximization problem for td[$bp] errored - change tolerances.") continue end end_time = time() - start_time max_td_iteration_time = max(end_time, max_td_iteration_time) # sanity checks - (lb > ub) && (Memento.warn(_LOGGER, "bt lb > ub - adjust tolerances in optimizer to avoid issue"); continue) + (lb > ub) && (@warn(_LOGGER, "bt lb > ub - adjust tolerances in optimizer to avoid issue"); continue) (!isnan(lb) && lb > td_ub[bp]) && (lb = td_lb[bp]) (!isnan(ub) && ub < td_lb[bp]) && (ub = td_ub[bp]) isnan(lb) && (lb = td_lb[bp]) @@ -333,11 +333,11 @@ function solve_obbt_opf!(data::Dict{String,<:Any}, optimizer; current_rel_gap = (upper_bound - result_relaxation["objective"])/upper_bound final_relaxation_objective = result_relaxation["objective"] else - Memento.warn(_LOGGER, "relaxation solve failed in iteration $(current_iteration+1)") - Memento.warn(_LOGGER, "using the previous iteration's gap to check relative gap stopping criteria") + @warn(_LOGGER, "relaxation solve failed in iteration $(current_iteration+1)") + @warn(_LOGGER, "using the previous iteration's gap to check relative gap stopping criteria") end - Memento.info(_LOGGER, "iteration $(current_iteration+1), vm range: $vm_range_final, td range: $td_range_final, relaxation obj: $final_relaxation_objective") + @info(_LOGGER, "iteration $(current_iteration+1), vm range: $vm_range_final, td range: $td_range_final, relaxation obj: $final_relaxation_objective") # termination criteria update (termination == :avg) && (check_termination = (avg_vm_reduction > improvement_tol || avg_td_reduction > improvement_tol)) @@ -345,10 +345,10 @@ function solve_obbt_opf!(data::Dict{String,<:Any}, optimizer; # interation counter update current_iteration += 1 # check all the stopping criteria - (current_iteration >= max_iter) && (Memento.info(_LOGGER, "maximum iteration limit reached"); break) - (time_elapsed > time_limit) && (Memento.info(_LOGGER, "maximum time limit reached"); break) + (current_iteration >= max_iter) && (@info(_LOGGER, "maximum iteration limit reached"); break) + (time_elapsed > time_limit) && (@info(_LOGGER, "maximum time limit reached"); break) if (!isinf(rel_gap_tol)) && (current_rel_gap < rel_gap_tol) - Memento.info(_LOGGER, "relative optimality gap < $rel_gap_tol") + @info(_LOGGER, "relative optimality gap < $rel_gap_tol") break end @@ -383,24 +383,24 @@ function _check_variables(pm::AbstractPowerModel) try vm = var(pm, :vm) catch err - (isa(error, KeyError)) && (Memento.error(_LOGGER, "OBBT is not supported for models without explicit voltage magnitude variables")) + (isa(error, KeyError)) && (@error(_LOGGER, "OBBT is not supported for models without explicit voltage magnitude variables")) end try td = var(pm, :td) catch err - (isa(error, KeyError)) && (Memento.error(_LOGGER, "OBBT is not supported for models without explicit voltage angle difference variables")) + (isa(error, KeyError)) && (@error(_LOGGER, "OBBT is not supported for models without explicit voltage angle difference variables")) end end function _check_obbt_options(ub::Float64, rel_gap::Float64, ub_constraint::Bool) if ub_constraint && isinf(ub) - Memento.error(_LOGGER, "the option upper_bound_constraint cannot be set to true without specifying an upper bound") + @error(_LOGGER, "the option upper_bound_constraint cannot be set to true without specifying an upper bound") end if !isinf(rel_gap) && isinf(ub) - Memento.error(_LOGGER, "rel_gap_tol is specified without providing an upper bound") + @error(_LOGGER, "rel_gap_tol is specified without providing an upper bound") end end @@ -408,12 +408,12 @@ end function _constraint_obj_bound(pm::AbstractPowerModel, bound) model = PowerModels.check_cost_models(pm) if model != 2 - Memento.error(_LOGGER, "Only cost models of type 2 is supported at this time, given cost model type $(model)") + @error(_LOGGER, "Only cost models of type 2 is supported at this time, given cost model type $(model)") end cost_index = PowerModels.calc_max_cost_index(pm.data) if cost_index > 3 - Memento.error(_LOGGER, "Only quadratic generator cost models are supported at this time, given cost model of order $(cost_index-1)") + @error(_LOGGER, "Only quadratic generator cost models are supported at this time, given cost model of order $(cost_index-1)") end PowerModels.standardize_cost_terms!(pm.data, order=2)