-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.jl
126 lines (118 loc) · 3.58 KB
/
main.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using DelimitedFiles, ExaModelsPower, CUSOLVERRF, MadNLP, MadNLPGPU, CUDA, NLPModelsIpopt, HSL_jll, JLD2
tol = 1e-4
DATA = [
(
"case30",
"data/case30/pglib_opf_case30_ieee.m",
"data/case30/case30.bus",
"data/case30/halfhour_30.Pd",
"data/case30/halfhour_30.Qd"
),
(
"case30",
"data/case30/pglib_opf_case30_ieee.m",
"data/case30/case30.bus",
"data/case30/halfhour_30.Pd",
"data/case30/halfhour_30.Qd"
),
(
"case118",
"data/case118/pglib_opf_case118_ieee.m",
"data/case118/case118.bus",
"data/case118/case118_onehour_168.Pd",
"data/case118/case118_onehour_168.Qd"
),
( # out of memoery
"case118",
"data/case118/pglib_opf_case118_ieee.m",
"data/case118/case118.bus",
"data/case118/case118_oneminute_10080.Pd",
"data/case118/case118_oneminute_10080.Qd"
),
(
"case1354",
"data/case1354/pglib_opf_case1354_pegase.m",
"data/case1354/case1354pegase.bus",
"data/case1354/halfhour_30.Pd",
"data/case1354/halfhour_30.Qd"
),
(
"case9241",
"data/case9241/pglib_opf_case9241_pegase.m",
"data/case9241/case9241pegase.bus",
"data/case9241/halfhour_30.Pd",
"data/case9241/halfhour_30.Qd"
),
(
"case9241",
"data/case9241/pglib_opf_case9241_pegase.m",
"data/case9241/case9241pegase.bus",
"data/case9241/halfhour_180.Pd",
"data/case9241/halfhour_180.Qd"
),
]
results_file = "results/results_$(gethostname()).jld2"
results = isfile(results_file) ? load(results_file) : Dict{String,Any}()
if isinteractive()
(caseid, cpu, gpu) = (2,false, true)
elseif length(ARGS) == 3
caseid = parse(Int, ARGS[1])
cpu = parse(Bool, ARGS[2])
gpu = parse(Bool, ARGS[3])
else
error("Invalid number of arguments")
end
println("caseid=$caseid, cpu=$cpu, gpu=$gpu")
function run_case(caseid::Int, cpu, gpu)
(name, net, bus, Pd, Qd) = DATA[caseid]
periods = size(readdlm(Qd),2)
println("Running case ($name, $net, $bus, $Pd, $Qd)")
(tcpu, tgpu, cpuiter, gpuiter, statuscpu, statusgpu) = (
0.0, 0.0, 0, 0, 0, 0
)
if cpu
model, vars = mpopf_model(net, bus, Pd, Qd)
tcpu = @elapsed rcpu = ipopt(
model;
linear_solver="ma27",
tol = tol,
bound_relax_factor = tol,
dual_inf_tol = 10000.0,
constr_viol_tol = 10000.0,
compl_inf_tol = 10000.0,
honor_original_bounds = "no",
max_wall_time = 600.
# output_file = "jump_output",
# print_timing_statistics = "yes"
)
cpuiter = rcpu.iter
statuscpu = rcpu.status
end
if gpu
model, vars = mpopf_model(net, bus, Pd, Qd; backend = CUDABackend())
tgpu = @elapsed rgpu = madnlp(
model;
tol = tol,
max_wall_time = 600.
)
gpuiter = rgpu.iter
statusgpu = rgpu.status
end
if caseid != 1 # first case is for JIT compilation
results["$caseid"] = (
name = name,
nvar = model.meta.nvar,
ncon = model.meta.ncon,
tcpu = tcpu,
tgpu = tgpu,
statuscpu = statuscpu == :first_order,
statusgpu = statusgpu == MadNLP.SOLVE_SUCCEEDED,
itercpu = cpuiter,
itergpu = gpuiter
)
save(results_file, results)
end
end
# precompilation
run_case(1, cpu, gpu)
run_case(caseid, cpu, gpu)