Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/Benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ jobs:
julia-version: '1'
mode: 'time,memory'
script: benchmark/benchmarks.jl
extra-pkgs: PowerModels
33 changes: 9 additions & 24 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -1,43 +1,28 @@
using BenchmarkTools
using PowerDiff
import PowerModels

const PM = PowerModels
const SUITE = BenchmarkGroup()
const CASE_NAME = "pglib_opf_case300_ieee.m"
const CASE_PATH = joinpath(PowerDiff.get_path(:pglib), CASE_NAME)

PM.silence()
PowerDiff.silence()

function _parse_benchmark_case(case_path)
if isdefined(PowerDiff, :parse_file)
return PowerDiff.parse_file(case_path)
end
return PM.make_basic_network(PM.parse_file(case_path))
return PowerDiff.parse_file(case_path)
end

function _load_benchmark_case()
pm_dir = joinpath(dirname(pathof(PM)), "..", "test", "data", "matpower")
for case_name in ("case30.m", "case24.m", "case14.m", "case9.m", "case5.m")
case_path = joinpath(pm_dir, case_name)
isfile(case_path) || continue
net_data = _parse_benchmark_case(case_path)
return case_name, case_path, net_data
end
error("No bundled PowerModels MATPOWER benchmark case found")
end

case_name, case_path, net_data = _load_benchmark_case()
net_data = _parse_benchmark_case(CASE_PATH)
prob = DCOPFProblem(net_data)
sol = solve!(prob)
ac_prob = ACOPFProblem(deepcopy(net_data); silent=true)
ac_sol = solve!(ac_prob)

SUITE["parser"] = BenchmarkGroup()
SUITE["parser"][case_name] = @benchmarkable _parse_benchmark_case($case_path)
SUITE["parser"][CASE_NAME] = @benchmarkable _parse_benchmark_case($CASE_PATH)

SUITE["dc_opf"] = BenchmarkGroup()
SUITE["dc_opf"]["kkt_jacobian"] = BenchmarkGroup()
kkt_suite = SUITE["dc_opf"]["kkt_jacobian"][case_name] = BenchmarkGroup()
kkt_suite = SUITE["dc_opf"]["kkt_jacobian"][CASE_NAME] = BenchmarkGroup()
kkt_suite["full"] = @benchmarkable PowerDiff.calc_kkt_jacobian($prob; sol=$sol)
kkt_suite["demand"] = @benchmarkable PowerDiff.calc_kkt_jacobian_demand($(prob.network), $(prob.d), $sol)
kkt_suite["flowlimit"] = @benchmarkable PowerDiff.calc_kkt_jacobian_flowlimit($prob, $sol)
Expand All @@ -47,9 +32,9 @@ kkt_suite["susceptance"] = @benchmarkable PowerDiff.calc_kkt_jacobian_susceptanc

SUITE["ac_opf"] = BenchmarkGroup()
SUITE["ac_opf"]["kkt_jacobian"] = BenchmarkGroup()
SUITE["ac_opf"]["kkt_jacobian"][case_name] =
SUITE["ac_opf"]["kkt_jacobian"][CASE_NAME] =
@benchmarkable PowerDiff.calc_kkt_jacobian($ac_prob; sol=$ac_sol)
SUITE["ac_opf"]["kkt_param"] = BenchmarkGroup()
SUITE["ac_opf"]["kkt_param"][case_name] = BenchmarkGroup()
SUITE["ac_opf"]["kkt_param"][case_name]["switching"] =
SUITE["ac_opf"]["kkt_param"][CASE_NAME] = BenchmarkGroup()
SUITE["ac_opf"]["kkt_param"][CASE_NAME]["switching"] =
@benchmarkable PowerDiff.calc_kkt_jacobian_param($ac_prob, $ac_sol, :sw)
Loading