diff --git a/CHANGELOG.md b/CHANGELOG.md index bc1258a8..5123afcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ PowerModels.jl Change Log - Clean up package imports (#961) - Refactor `test/runtests.jl` (#962) (#965) - Remove empty docstrings (#963) (#966) +- Add PrecompileTools (#967) ### v0.21.3 - Fix no-buses bug in `calc_connected_components` (#933) diff --git a/Project.toml b/Project.toml index 4ba743d0..47046038 100644 --- a/Project.toml +++ b/Project.toml @@ -11,6 +11,7 @@ JuMP = "4076af6c-e467-56ae-b986-b466b2749572" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9" NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56" +PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [compat] @@ -22,6 +23,7 @@ JuMP = "1.15" Juniper = "~0.9" Memento = "~1.0, ~1.1, ~1.2, ~1.3, ~1.4" NLsolve = "4.0" +PrecompileTools = "1" SCS = "~0.9, ~1.0, ~2.0" julia = "1.6" diff --git a/src/PowerModels.jl b/src/PowerModels.jl index 652f7271..0790e8f1 100644 --- a/src/PowerModels.jl +++ b/src/PowerModels.jl @@ -7,6 +7,7 @@ import JuMP import LinearAlgebra import Memento import NLsolve +import PrecompileTools import SparseArrays # Create our module level logger (this will get precompiled) @@ -84,6 +85,22 @@ include("util/flow_limit_cuts.jl") # this must come last to support automated export include("core/export.jl") +PrecompileTools.@setup_workload begin + case3 = joinpath(dirname(@__DIR__), "test/data/matpower/case3.m") + case9 = joinpath(dirname(@__DIR__), "test/data/matpower/case9.m") + PrecompileTools.@compile_workload begin + for case in [case3, case9] + data = parse_file(case) + _ = instantiate_model(data, ACPPowerModel, build_opf) + _ = instantiate_model(data, ACPPowerModel, build_pf) + _ = instantiate_model(data, DCPPowerModel, build_opf) + _ = instantiate_model(data, DCPPowerModel, build_pf) + end + _ = compute_ac_pf(case9) + _ = compute_dc_pf(case9) + end +end + # Deprecations to be removed in the next breaking release @deprecate resolve_swithces! resolve_switches!