Skip to content

Commit

Permalink
Update to PowerModels v0.18 (#79)
Browse files Browse the repository at this point in the history
* updates for multi-infrastructure changes
* prep for v0.7 release
  • Loading branch information
ccoffrin authored Mar 2, 2021
1 parent f1fbedd commit f303f3c
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 23 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ PowerModelsAnnex.jl Change Log
### Staged
- nothing

### v0.7.0
- Update to InfrastructureModels v0.6 and PowerModels v0.18

### v0.6.1
- Add variants of piecewise linear cost model formulations
- Update to DataFrames v0.21
Expand Down
12 changes: 6 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "PowerModelsAnnex"
uuid = "6e471128-d39d-5672-b02b-a742bd1b77ed"
authors = ["Carleton Coffrin, et. al."]
repo = "https://github.com/lanl-ansi/PowerModelsAnnex.jl"
version = "0.6.1"
version = "0.7.0"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand All @@ -17,12 +17,12 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[compat]
DataFrames = "~0.19, ~0.20, ~0.21, ~0.22"
InfrastructureModels = "~0.5"
JuMP = "~0.19.1, ~0.20, ~0.21"
MathOptInterface = "~0.7, ~0.8, ~0.9"
Memento = "~0.10, ~0.11, ~0.12, ~0.13, ~1.0, ~1.1"
InfrastructureModels = "~0.6"
JuMP = "~0.21"
MathOptInterface = "~0.9"
Memento = "~1.0, ~1.1"
Missings = "~0.3, ~0.4"
PowerModels = "~0.17.1"
PowerModels = "~0.18.0"
PowerSystemsUnits = "~0.2"
Unitful = "~0.7, ~0.8, ~0.10, ~0.11, ~0.12, ~0.13, ~0.14, ~0.15, ~0.16, ~0.17, ~0.18"
julia = "^1"
Expand Down
2 changes: 1 addition & 1 deletion src/PowerModelsAnnex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import JuMP: @variable, @constraint, @NLexpression, @NLconstraint, @objective, @
import InfrastructureModels; const _IM = InfrastructureModels

import PowerModels; const _PM = PowerModels
import PowerModels: ids, ref, var, con, sol
import PowerModels: ids, ref, var, con, sol, nw_id_default

import Memento

Expand Down
2 changes: 1 addition & 1 deletion src/model/ac-opf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ PowerModels.standardize_cost_terms!(data, order=2)
PowerModels.calc_thermal_limits!(data)

# use build_ref to filter out inactive components
ref = PowerModels.build_ref(data)[:nw][0]
ref = PowerModels.build_ref(data)[:it][:pm][:nw][0]
# note: ref contains all the relevant system parameters needed to build the OPF model
# When we introduce constraints and variable bounds below, we use the parameters in ref.

Expand Down
2 changes: 1 addition & 1 deletion src/model/dc-opf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ PowerModels.standardize_cost_terms!(data, order=2)
PowerModels.calc_thermal_limits!(data)

# use build_ref to filter out inactive components
ref = PowerModels.build_ref(data)[:nw][0]
ref = PowerModels.build_ref(data)[:it][:pm][:nw][0]
# Note: ref contains all the relevant system parameters needed to build the OPF model
# When we introduce constraints and variable bounds below, we use the parameters in ref.

Expand Down
8 changes: 4 additions & 4 deletions src/model/opf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function build_ac_opf(data::Dict{String,Any}, model=Model())
@assert !haskey(data, "conductors")

PowerModels.standardize_cost_terms!(data, order=2)
ref = PowerModels.build_ref(data)[:nw][0]
ref = PowerModels.build_ref(data)[:it][_PM.pm_it_sym][:nw][nw_id_default]

@variable(model, va[i in keys(ref[:bus])])
@variable(model, ref[:bus][i]["vmin"] <= vm[i in keys(ref[:bus])] <= ref[:bus][i]["vmax"], start=1.0)
Expand Down Expand Up @@ -143,7 +143,7 @@ function build_soc_opf(data::Dict{String,Any}, model=Model())
@assert !haskey(data, "conductors")

PowerModels.standardize_cost_terms!(data, order=2)
ref = PowerModels.build_ref(data)[:nw][0]
ref = PowerModels.build_ref(data)[:it][_PM.pm_it_sym][:nw][nw_id_default]

@variable(model, ref[:bus][i]["vmin"]^2 <= w[i in keys(ref[:bus])] <= ref[:bus][i]["vmax"]^2, start=1.001)

Expand Down Expand Up @@ -302,7 +302,7 @@ function build_qc_opf(data::Dict{String,Any}, model=Model())
@assert !haskey(data, "conductors")

PowerModels.standardize_cost_terms!(data, order=2)
ref = PowerModels.build_ref(data)[:nw][0]
ref = PowerModels.build_ref(data)[:it][_PM.pm_it_sym][:nw][nw_id_default]

# voltage angle and magnitude
@variable(model, va[i in keys(ref[:bus])])
Expand Down Expand Up @@ -639,7 +639,7 @@ function build_dc_opf(data::Dict{String,Any}, model=Model())
@assert !haskey(data, "conductors")

PowerModels.standardize_cost_terms!(data, order=2)
ref = PowerModels.build_ref(data)[:nw][0]
ref = PowerModels.build_ref(data)[:it][_PM.pm_it_sym][:nw][nw_id_default]

@variable(model, va[i in keys(ref[:bus])])

Expand Down
6 changes: 3 additions & 3 deletions src/model/pf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function build_ac_pf(data::Dict{String,Any}, model=Model())
@assert !_IM.ismultinetwork(data)
@assert !haskey(data, "conductors")

ref = PowerModels.build_ref(data)[:nw][0]
ref = PowerModels.build_ref(data)[:it][_PM.pm_it_sym][:nw][nw_id_default]

@variable(model, va[i in keys(ref[:bus])])
@variable(model, vm[i in keys(ref[:bus])], start=1.0)
Expand Down Expand Up @@ -121,7 +121,7 @@ function build_soc_pf(data::Dict{String,Any}, model=Model())
@assert !_IM.ismultinetwork(data)
@assert !haskey(data, "conductors")

ref = PowerModels.build_ref(data)[:nw][0]
ref = PowerModels.build_ref(data)[:it][_PM.pm_it_sym][:nw][nw_id_default]

@variable(model, w[i in keys(ref[:bus])] >= 0, start=1.001)
@variable(model, wr[bp in keys(ref[:buspairs])], start=1.0)
Expand Down Expand Up @@ -238,7 +238,7 @@ function build_dc_pf(data::Dict{String,Any}, model=Model())
@assert !_IM.ismultinetwork(data)
@assert !haskey(data, "conductors")

ref = PowerModels.build_ref(data)[:nw][0]
ref = PowerModels.build_ref(data)[:it][_PM.pm_it_sym][:nw][nw_id_default]

@variable(model, va[i in keys(ref[:bus])])

Expand Down
2 changes: 1 addition & 1 deletion src/pglib/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,5 @@ function constraint_power_balance_shunt_scaled(pm::_PM.AbstractACPModel, n::Int,

@constraint(pm.model, sum(q[a] for a in bus_arcs) == sum(qg[g] for g in bus_gens) - qd + bs*vm^2)
end
constraint_power_balance_shunt_scaled(pm::_PM.AbstractPowerModel, i::Int) = constraint_power_balance_shunt_scaled(pm, pm.cnw, i)
constraint_power_balance_shunt_scaled(pm::_PM.AbstractPowerModel, i::Int) = constraint_power_balance_shunt_scaled(pm, nw_id_default, i)

4 changes: 2 additions & 2 deletions src/pglib/shared.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function constraint_thermal_limit_from(pm::_PM.AbstractPowerModel, n::Int, i::In
_PM.constraint_thermal_limit_from(pm, n, f_idx, branch["rate_a"]*scale)
end
end
constraint_thermal_limit_from(pm::_PM.AbstractPowerModel, i::Int; scale = 1.0) = constraint_thermal_limit_from(pm, pm.cnw, i; scale=scale)
constraint_thermal_limit_from(pm::_PM.AbstractPowerModel, i::Int; scale = 1.0) = constraint_thermal_limit_from(pm, nw_id_default, i; scale=scale)

""
function constraint_thermal_limit_to(pm::_PM.AbstractPowerModel, n::Int, i::Int; scale = 1.0)
Expand All @@ -24,6 +24,6 @@ function constraint_thermal_limit_to(pm::_PM.AbstractPowerModel, n::Int, i::Int;
_PM.constraint_thermal_limit_to(pm, n, t_idx, branch["rate_a"]*scale)
end
end
constraint_thermal_limit_to(pm::_PM.AbstractPowerModel, i::Int; scale = 1.0) = constraint_thermal_limit_to(pm, pm.cnw, i; scale=scale)
constraint_thermal_limit_to(pm::_PM.AbstractPowerModel, i::Int; scale = 1.0) = constraint_thermal_limit_to(pm, nw_id_default, i; scale=scale)


2 changes: 1 addition & 1 deletion src/piecewise-linear/delta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ function objective_variable_pg_cost_delta(pm::_PM.AbstractPowerModel, report::Bo
pg_cost[i] = points[1].cost + sum(cost_per_mw[i]*pg_cost_mw[i] for i in 2:length(points))
end

report && _IM.sol_component_value(pm, n, :gen, :pg_cost, ids(pm, n, :gen), pg_cost)
report && _PM.sol_component_value(pm, n, :gen, :pg_cost, ids(pm, n, :gen), pg_cost)
end
end
2 changes: 1 addition & 1 deletion src/piecewise-linear/lambda.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function objective_variable_pg_cost_lambda(pm::_PM.AbstractPowerModel, report::B
pg_cost[i] = pg_cost_expr
end

report && _IM.sol_component_value(pm, n, :gen, :pg_cost, ids(pm, n, :gen), pg_cost)
report && _PM.sol_component_value(pm, n, :gen, :pg_cost, ids(pm, n, :gen), pg_cost)
end
end

2 changes: 1 addition & 1 deletion src/piecewise-linear/phi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ function objective_variable_pg_cost_phi(pm::_PM.AbstractPowerModel, report::Bool
end
end

report && _IM.sol_component_value(pm, n, :gen, :pg_cost, ids(pm, n, :gen), pg_cost)
report && _PM.sol_component_value(pm, n, :gen, :pg_cost, ids(pm, n, :gen), pg_cost)
end
end
2 changes: 1 addition & 1 deletion src/piecewise-linear/psi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function objective_variable_pg_cost_psi(pm::_PM.AbstractPowerModel, report::Bool
lower_bound = pg_cost_min[i],
upper_bound = pg_cost_max[i]
)
report && _IM.sol_component_value(pm, n, :gen, :pg_cost, ids(pm, n, :gen), pg_cost)
report && _PM.sol_component_value(pm, n, :gen, :pg_cost, ids(pm, n, :gen), pg_cost)

# gen pwl cost
for (i, gen) in nw_ref[:gen]
Expand Down

0 comments on commit f303f3c

Please sign in to comment.