Skip to content

Commit fd40fa1

Browse files
committed
Add PrecompileTools to speed up time-to-first-solve
1 parent 685fbb2 commit fd40fa1

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ PowerModels.jl Change Log
1212
- Clean up package imports (#961)
1313
- Refactor `test/runtests.jl` (#962) (#965)
1414
- Remove empty docstrings (#963) (#966)
15+
- Add PrecompileTools (#967)
1516

1617
### v0.21.3
1718
- Fix no-buses bug in `calc_connected_components` (#933)

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
1111
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1212
Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9"
1313
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
14+
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
1415
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1516

1617
[compat]
@@ -22,6 +23,7 @@ JuMP = "1.15"
2223
Juniper = "~0.9"
2324
Memento = "~1.0, ~1.1, ~1.2, ~1.3, ~1.4"
2425
NLsolve = "4.0"
26+
PrecompileTools = "1"
2527
SCS = "~0.9, ~1.0, ~2.0"
2628
julia = "1.6"
2729

src/PowerModels.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import JuMP
77
import LinearAlgebra
88
import Memento
99
import NLsolve
10+
import PrecompileTools
1011
import SparseArrays
1112

1213
# Create our module level logger (this will get precompiled)
@@ -84,6 +85,22 @@ include("util/flow_limit_cuts.jl")
8485
# this must come last to support automated export
8586
include("core/export.jl")
8687

88+
PrecompileTools.@setup_workload begin
89+
case3 = joinpath(dirname(@__DIR__), "test/data/matpower/case3.m")
90+
case9 = joinpath(dirname(@__DIR__), "test/data/matpower/case9.m")
91+
PrecompileTools.@compile_workload begin
92+
for case in [case3, case9]
93+
data = parse_file(case3)
94+
_ = instantiate_model(data, ACPPowerModel, build_opf)
95+
_ = instantiate_model(data, ACPPowerModel, build_pf)
96+
_ = instantiate_model(data, DCPPowerModel, build_opf)
97+
_ = instantiate_model(data, DCPPowerModel, build_pf)
98+
end
99+
_ = compute_ac_pf(case9)
100+
_ = compute_dc_pf(case9)
101+
end
102+
end
103+
87104
# Deprecations to be removed in the next breaking release
88105

89106
@deprecate resolve_swithces! resolve_switches!

0 commit comments

Comments
 (0)