Skip to content

Commit 8c74211

Browse files
authored
Rename run_* to solve_* (#807)
* rename "run" functions to "solve" functions * add function deprecation warnings
1 parent 383c456 commit 8c74211

25 files changed

+305
-189
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ PowerModels.jl Change Log
22
=========================
33

44
### Staged
5+
- Rename `run_*` methods to `solve_*` and add depreciation warnings (#649)
56
- Made case name recovery optional in PTI parsing
67
- Fixed Julia deprecation warning when calling sort on Dict
78
- Change `Int64` types to `Int`
@@ -45,6 +46,7 @@ PowerModels.jl Change Log
4546
- Removed ref bus index from AdmittanceMatrix (#760) (breaking)
4647
- Removed data change tracking from `correct_network_data!` (breaking)
4748
- Removed `_extend_pwl_cost!` function (#716)
49+
>>>>>>> master
4850
4951
### v0.17.4
5052
- Added support for matrix-based analysis of basic network data (#728)

docs/src/experiment-results.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ All models were solved using [IPOPT](https://link.springer.com/article/10.1007/s
1111
This experiment consists of running the following PowerModels commands,
1212
```
1313
solver = optimizer_with_attributes(Ipopt.Optimizer, "tol" => 1e-6)
14-
result_ac = run_opf(case, ACPPowerModel, solver)
15-
result_soc = run_opf(case, SOCWRPowerModel, solver)
16-
result_qc = run_opf(case, QCRMPowerModel, solver)
14+
result_ac = solve_opf(case, ACPPowerModel, solver)
15+
result_soc = solve_opf(case, SOCWRPowerModel, solver)
16+
result_qc = solve_opf(case, QCRMPowerModel, solver)
1717
```
1818
for each case in the PGLib-OPF archive.
1919
If the value of `result["termination_status"]` is `LOCALLY_SOLVED` then the

docs/src/multi-networks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ PowerModels.ismultinetwork(pm3)
4141
```
4242
will result in an error. Moreover, `instantiate_model()` (see )
4343

44-
Because this is a common pattern of usage, we provide corresponding calls to `run_mn_opf` (which behaves analogously to `run_opf`, but for multinetwork data).
44+
Because this is a common pattern of usage, we provide corresponding calls to `solve_mn_opf` (which behaves analogously to `solve_opf`, but for multinetwork data).
4545

4646
!!! note
4747

docs/src/network-data.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,19 @@ PowerModels.print_summary(network_data) # mixed units form
160160
Another useful helper function is `update_data`, which takes two network data dictionaries and updates the values in the first dictionary with the values from the second dictionary. This is particularly helpful when applying sparse updates to network data. A good example is using the solution of one computation to update the data in preparation for a second computation, like so,
161161
```
162162
data = PowerModels.parse_file("matpower/case3.m")
163-
opf_result = run_ac_opf(data, Ipopt.Optimizer)
163+
opf_result = solve_ac_opf(data, Ipopt.Optimizer)
164164
PowerModels.print_summary(opf_result["solution"])
165165
166166
PowerModels.update_data!(data, opf_result["solution"])
167-
pf_result = run_ac_pf(data, Ipopt.Optimizer)
167+
pf_result = solve_ac_pf(data, Ipopt.Optimizer)
168168
PowerModels.print_summary(pf_result["solution"])
169169
```
170170

171171
A variety of helper functions are available for processing the topology of the network. For example, `connected_components` will compute the collections of buses that are connected by branches (i.e. the network's islands). By default PowerModels will attempt to solve all of the network components simultaneously. The `select_largest_component` function can be used to only consider the largest component in the network. Finally the `propagate_topology_status!` can be used to explicitly deactivate components that are implicitly inactive due to the status of other components (e.g. deactivating branches based on the status of their connecting buses), like so,
172172
```
173173
data = PowerModels.parse_file("matpower/case3.m")
174174
PowerModels.propagate_topology_status!(data)
175-
opf_result = run_ac_opf(data, Ipopt.Optimizer)
175+
opf_result = solve_ac_opf(data, Ipopt.Optimizer)
176176
```
177177
The `test/data/matpower/case7_tplgy.m` case provides an example of the kind of component status deductions that can be made. The `simplify_network!`, `propagate_topology_status!` and `deactivate_isolated_components!` functions can be helpful in diagnosing network models that do not converge or have an infeasible solution.
178178

docs/src/power-flow.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ available in PowerModels and under what circumstances they may be beneficial.
1818
The general purpose power flow solver in PowerModels is,
1919

2020
```@docs
21-
run_pf
21+
solve_pf
2222
```
2323

2424
This function builds a JuMP model for a wide variety of the power flow formulations
@@ -28,15 +28,15 @@ supported by PowerModels. For example it supports,
2828
* `SOCWRPowerModel` - a convex quadratic relaxation of the power flow problem
2929
* `DCPPowerModel` - a linear DC approximation of the power flow problem
3030
The typical `ACPPowerModel` and `DCPPowerModel` formulations are available via
31-
the shorthand form `run_ac_pf` and `run_dc_pf` respectively.
31+
the shorthand form `solve_ac_pf` and `solve_dc_pf` respectively.
3232

33-
The `run_pf` solution method is both formulation and solver agnostic and
33+
The `solve_pf` solution method is both formulation and solver agnostic and
3434
can leverage the wide range of solvers that are available in the JuMP
3535
ecosystem. Many of these solvers are commercial-grade, which in turn makes
36-
`run_pf` the most reliable power flow solution method in PowerModels.
36+
`solve_pf` the most reliable power flow solution method in PowerModels.
3737

3838
!!! note
39-
Use of `run_pf` is highly recommended over the other solution methods for
39+
Use of `solve_pf` is highly recommended over the other solution methods for
4040
increased robustness. Applications that benefit from the Julia native
4141
solution methods are an exception to this general rule.
4242

@@ -61,7 +61,7 @@ For each bus,
6161
* `vi_start` - imaginary voltage starting point for the `ACRPowerModel` model
6262

6363
The following helper function can be used to use the solution point in the
64-
network data as the starting point for `run_ac_pf`.
64+
network data as the starting point for `solve_ac_pf`.
6565
```@docs
6666
set_ac_pf_start_values!
6767
```
@@ -84,10 +84,10 @@ with voltages in polar coordinates with NLsolve.
8484
```@docs
8585
compute_ac_pf
8686
```
87-
`compute_ac_pf` will typically provide an identical result to `run_ac_pf`.
87+
`compute_ac_pf` will typically provide an identical result to `solve_ac_pf`.
8888
However, the existence of solution degeneracy around generator injection
8989
assignments and multiple power flow solutions can yield different results.
90-
The primary advantage of `compute_ac_pf` over `run_ac_pf` is that it does not
90+
The primary advantage of `compute_ac_pf` over `solve_ac_pf` is that it does not
9191
require building a JuMP model. If the initial point for the AC Power Flow
9292
solution is near-feasible then `compute_ac_pf` can result in a significant
9393
runtime saving by converging quickly and reducing data-wrangling and memory
@@ -96,7 +96,7 @@ allocation overheads. This initial guess is provided using the standard
9696
way of setting a suitable starting point.
9797

9898
!!! tip
99-
If `compute_ac_pf` fails to converge try `run_ac_pf` instead.
99+
If `compute_ac_pf` fails to converge try `solve_ac_pf` instead.
100100

101101

102102
## Native DC Power Flow
@@ -108,15 +108,14 @@ built-in linear systems solvers.
108108
```@docs
109109
compute_dc_pf
110110
```
111-
The `compute_dc_pf` method should provide identical results to `run_dc_pf`.
112-
The primary advantage of `compute_dc_pf` over `run_dc_pf` is that it does not
111+
The `compute_dc_pf` method should provide identical results to `solve_dc_pf`.
112+
The primary advantage of `compute_dc_pf` over `solve_dc_pf` is that it does not
113113
require building a JuMP model. This results in significant memory saving and
114114
marginal performance saving due to reduced data-wrangling overhead. The
115115
primary use-case of this model is to compute the voltage angle values from
116116
a collection of bus injections when working with a formulation that does not
117117
explicitly model these values, such as a PTDF or LODF formulation.
118-
The [`run_opf_ptdf_branch_power_cuts`](@ref) utility function provides an example of
119-
how `compute_dc_pf` is typically used.
118+
The [`solve_opf_ptdf_branch_power_cuts`](@ref) utility function provides an example of how `compute_dc_pf` is typically used.
120119

121120
This solver does not support warm starting.
122121

@@ -133,7 +132,7 @@ Both of these methods require a complete network data with a valid voltage solut
133132
for computing the branch flows. For example, one common work flow to recover
134133
branch flow values is,
135134
```julia
136-
result = run_ac_pf(network, ...)
135+
result = solve_ac_pf(network, ...)
137136
# check that the solver converged
138137
update_data!(network, result["solution"])
139138
flows = calc_branch_flow_ac(network)

docs/src/quickguide.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ Once PowerModels is installed, Ipopt is installed, and a network data file (e.g.
66
using PowerModels
77
using Ipopt
88

9-
run_ac_opf("matpower/case3.m", Ipopt.Optimizer)
9+
solve_ac_opf("matpower/case3.m", Ipopt.Optimizer)
1010
```
1111

1212
Similarly, a DC Optimal Power Flow can be executed with
1313

1414
```julia
15-
run_dc_opf("matpower/case3.m", Ipopt.Optimizer)
15+
solve_dc_opf("matpower/case3.m", Ipopt.Optimizer)
1616
```
1717

1818
PTI `.raw` files in the PSS(R)E v33 specification can be run similarly, e.g. in the case of an AC Optimal Power Flow
1919

2020
```julia
21-
run_ac_opf("case3.raw", Ipopt.Optimizer)
21+
solve_ac_opf("case3.raw", Ipopt.Optimizer)
2222
```
2323

2424

@@ -27,7 +27,7 @@ run_ac_opf("case3.raw", Ipopt.Optimizer)
2727
The run commands in PowerModels return detailed results data in the form of a dictionary. Results dictionaries from either Matpower `.m` or PTI `.raw` files will be identical in format. This dictionary can be saved for further processing as follows,
2828

2929
```julia
30-
result = run_ac_opf("matpower/case3.m", Ipopt.Optimizer)
30+
result = solve_ac_opf("matpower/case3.m", Ipopt.Optimizer)
3131
```
3232

3333
For example, the algorithm's runtime and final objective value can be accessed with,
@@ -49,17 +49,17 @@ The `print_summary(result["solution"])` function can be used show an table-like
4949

5050
## Accessing Different Formulations
5151

52-
The function `run_ac_opf` and `run_dc_opf` are shorthands for a more general formulation-independent OPF execution, `run_opf`.
53-
For example, `run_ac_opf` is equivalent to,
52+
The function `solve_ac_opf` and `solve_dc_opf` are shorthands for a more general formulation-independent OPF execution, `solve_opf`.
53+
For example, `solve_ac_opf` is equivalent to,
5454

5555
```julia
56-
run_opf("matpower/case3.m", ACPPowerModel, Ipopt.Optimizer)
56+
solve_opf("matpower/case3.m", ACPPowerModel, Ipopt.Optimizer)
5757
```
5858

59-
where "ACPPowerModel" indicates an AC formulation in polar coordinates. This more generic `run_opf()` allows one to solve an OPF problem with any power network formulation implemented in PowerModels. For example, an SOC Optimal Power Flow can be run with,
59+
where "ACPPowerModel" indicates an AC formulation in polar coordinates. This more generic `solve_opf()` allows one to solve an OPF problem with any power network formulation implemented in PowerModels. For example, an SOC Optimal Power Flow can be run with,
6060

6161
```julia
62-
run_opf("matpower/case3.m", SOCWRPowerModel, Ipopt.Optimizer)
62+
solve_opf("matpower/case3.m", SOCWRPowerModel, Ipopt.Optimizer)
6363
```
6464

6565
[Formulation Details](@ref) provides a list of available formulations.
@@ -72,12 +72,12 @@ The following example demonstrates one way to perform multiple PowerModels solve
7272
```julia
7373
network_data = PowerModels.parse_file("matpower/case3.m")
7474

75-
run_opf(network_data, ACPPowerModel, Ipopt.Optimizer)
75+
solve_opf(network_data, ACPPowerModel, Ipopt.Optimizer)
7676

7777
network_data["load"]["3"]["pd"] = 0.0
7878
network_data["load"]["3"]["qd"] = 0.0
7979

80-
run_opf(network_data, ACPPowerModel, Ipopt.Optimizer)
80+
solve_opf(network_data, ACPPowerModel, Ipopt.Optimizer)
8181
```
8282

8383
Network data parsed from PTI `.raw` files supports data extensions, i.e. data fields that are within the PSS(R)E specification, but not used by PowerModels for calculation. This can be achieved by
@@ -93,7 +93,7 @@ This network data can be modified in the same way as the previous Matpower `.m`
9393

9494
The flow AC and DC branch results are written to the result by default. The following can be used to inspect the flow results:
9595
```julia
96-
result = run_opf("matpower/case3_dc.m", ACPPowerModel, Ipopt.Optimizer)
96+
result = solve_opf("matpower/case3_dc.m", ACPPowerModel, Ipopt.Optimizer)
9797
result["solution"]["dcline"]["1"]
9898
result["solution"]["branch"]["2"]
9999
```
@@ -106,7 +106,7 @@ loss_dc = Dict(name => data["pt"]+data["pf"] for (name, data) in result["soluti
106106

107107

108108
## Building PowerModels from Network Data Dictionaries
109-
The following example demonstrates how to break a `run_opf` call into separate model building and solving steps. This allows inspection of the JuMP model created by PowerModels for the AC-OPF problem,
109+
The following example demonstrates how to break a `solve_opf` call into separate model building and solving steps. This allows inspection of the JuMP model created by PowerModels for the AC-OPF problem,
110110

111111
```julia
112112
pm = instantiate_model("matpower/case3.m", ACPPowerModel, PowerModels.build_opf)

docs/src/utilities.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This section provides an overview of the some of the utility functions that are
77
To improve the quality of the convex relaxations available in PowerModels and also to obtain tightened bounds on the voltage-magnitude and phase-angle difference variables, an optimization-based bound-tightening algorithm is made available as a function in PowerModels.
88

99
```@docs
10-
run_obbt_opf!
10+
solve_obbt_opf!
1111
```
1212

1313

@@ -16,6 +16,6 @@ run_obbt_opf!
1616
The following functions are meta-algorithms for solving OPF problems where line flow limit constraints are added iteratively to exploit the property that the majority of line flows constraints will be inactive in the optimal solution.
1717

1818
```@docs
19-
run_opf_branch_power_cuts
20-
run_opf_ptdf_branch_power_cuts
19+
solve_opf_branch_power_cuts
20+
solve_opf_ptdf_branch_power_cuts
2121
```

src/PowerModels.jl

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,114 @@ include("util/obbt.jl")
8686
include("util/flow_limit_cuts.jl")
8787

8888

89+
# function deprecation warnings
90+
# can be removed in a breaking release after 09/01/2022
91+
function run_model(args...; kwargs...)
92+
@warn("the function run_model has been replaced with solve_model", maxlog=1)
93+
solve_model(args...; kwargs...)
94+
end
95+
96+
function run_pf(args...; kwargs...)
97+
@warn("the function run_pf has been replaced with solve_pf", maxlog=1)
98+
solve_pf(args...; kwargs...)
99+
end
100+
function run_ac_pf(args...; kwargs...)
101+
@warn("the function run_ac_pf has been replaced with solve_ac_pf", maxlog=1)
102+
solve_ac_pf(args...; kwargs...)
103+
end
104+
function run_dc_pf(args...; kwargs...)
105+
@warn("the function run_dc_pf has been replaced with solve_dc_pf", maxlog=1)
106+
solve_dc_pf(args...; kwargs...)
107+
end
108+
function run_pf_bf(args...; kwargs...)
109+
@warn("the function run_pf_bf has been replaced with solve_pf_bf", maxlog=1)
110+
solve_pf_bf(args...; kwargs...)
111+
end
112+
function run_pf_iv(args...; kwargs...)
113+
@warn("the function run_pf_iv has been replaced with solve_pf_iv", maxlog=1)
114+
solve_pf_iv(args...; kwargs...)
115+
end
116+
117+
118+
function run_opf(args...; kwargs...)
119+
@warn("the function run_opf has been replaced with solve_opf", maxlog=1)
120+
solve_opf(args...; kwargs...)
121+
end
122+
function run_ac_opf(args...; kwargs...)
123+
@warn("the function run_ac_opf has been replaced with solve_ac_opf", maxlog=1)
124+
solve_ac_opf(args...; kwargs...)
125+
end
126+
function run_dc_opf(args...; kwargs...)
127+
@warn("the function run_dc_opf has been replaced with solve_dc_opf", maxlog=1)
128+
solve_dc_opf(args...; kwargs...)
129+
end
130+
131+
function run_mn_opf(args...; kwargs...)
132+
@warn("the function run_mn_opf has been replaced with solve_mn_opf", maxlog=1)
133+
solve_mn_opf(args...; kwargs...)
134+
end
135+
function run_mn_opf_strg(args...; kwargs...)
136+
@warn("the function run_mn_opf_strg has been replaced with solve_mn_opf_strg", maxlog=1)
137+
solve_mn_opf_strg(args...; kwargs...)
138+
end
139+
function run_opf_ptdf(args...; kwargs...)
140+
@warn("the function run_opf_ptdf has been replaced with solve_opf_ptdf", maxlog=1)
141+
solve_opf_ptdf(args...; kwargs...)
142+
end
143+
144+
function run_opf_bf(args...; kwargs...)
145+
@warn("the function run_opf_bf has been replaced with solve_opf_bf", maxlog=1)
146+
solve_opf_bf(args...; kwargs...)
147+
end
148+
function run_mn_opf_bf_strg(args...; kwargs...)
149+
@warn("the function run_mn_opf_bf_strg has been replaced with solve_mn_opf_bf_strg", maxlog=1)
150+
solve_mn_opf_bf_strg(args...; kwargs...)
151+
end
152+
function run_opf_iv(args...; kwargs...)
153+
@warn("the function run_opf_iv has been replaced with solve_opf_iv", maxlog=1)
154+
solve_opf_iv(args...; kwargs...)
155+
end
156+
157+
function run_opb(args...; kwargs...)
158+
@warn("the function run_opb has been replaced with solve_opb", maxlog=1)
159+
solve_opb(args...; kwargs...)
160+
end
161+
function run_nfa_opb(args...; kwargs...)
162+
@warn("the function run_nfa_opb has been replaced with solve_nfa_opb", maxlog=1)
163+
solve_nfa_opb(args...; kwargs...)
164+
end
165+
166+
function run_ots(args...; kwargs...)
167+
@warn("the function run_ots has been replaced with solve_ots", maxlog=1)
168+
solve_ots(args...; kwargs...)
169+
end
170+
function run_tnep(args...; kwargs...)
171+
@warn("the function run_tnep has been replaced with solve_tnep", maxlog=1)
172+
solve_tnep(args...; kwargs...)
173+
end
174+
175+
function run_opf_branch_power_cuts(args...; kwargs...)
176+
@warn("the function run_opf_branch_power_cuts has been replaced with solve_opf_branch_power_cuts", maxlog=1)
177+
solve_opf_branch_power_cuts(args...; kwargs...)
178+
end
179+
function run_opf_branch_power_cuts!(args...; kwargs...)
180+
@warn("the function run_opf_branch_power_cuts! has been replaced with solve_opf_branch_power_cuts!", maxlog=1)
181+
solve_opf_branch_power_cuts!(args...; kwargs...)
182+
end
183+
function run_opf_ptdf_branch_power_cuts(args...; kwargs...)
184+
@warn("the function run_opf_ptdf_branch_power_cuts has been replaced with solve_opf_ptdf_branch_power_cuts", maxlog=1)
185+
solve_opf_ptdf_branch_power_cuts(args...; kwargs...)
186+
end
187+
function run_opf_ptdf_branch_power_cuts!(args...; kwargs...)
188+
@warn("the function run_opf_ptdf_branch_power_cuts! has been replaced with solve_opf_ptdf_branch_power_cuts!", maxlog=1)
189+
solve_opf_ptdf_branch_power_cuts!(args...; kwargs...)
190+
end
191+
function run_obbt_opf!(args...; kwargs...)
192+
@warn("the function run_obbt_opf! has been replaced with solve_obbt_opf!", maxlog=1)
193+
solve_obbt_opf!(args...; kwargs...)
194+
end
195+
196+
89197
# this must come last to support automated export
90198
include("core/export.jl")
91199

src/core/base.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ conductor_ids(pm::AbstractPowerModel; nw::Int=nw_id_default) = pm.ref[:it][pm_it
2222

2323

2424
""
25-
function run_model(file::String, model_type::Type, optimizer, build_method; kwargs...)
25+
function solve_model(file::String, model_type::Type, optimizer, build_method; kwargs...)
2626
data = PowerModels.parse_file(file)
27-
return run_model(data, model_type, optimizer, build_method; kwargs...)
27+
return solve_model(data, model_type, optimizer, build_method; kwargs...)
2828
end
2929

3030
""
31-
function run_model(data::Dict{String,<:Any}, model_type::Type, optimizer, build_method;
31+
function solve_model(data::Dict{String,<:Any}, model_type::Type, optimizer, build_method;
3232
ref_extensions=[], solution_processors=[], relax_integrality=false,
3333
multinetwork=false, multiconductor=false, kwargs...)
3434

0 commit comments

Comments
 (0)