Skip to content

Commit 24f48b7

Browse files
frapacamontoison
authored andcommitted
add script to benchmark MadQP on Netlib
1 parent 79dae7e commit 24f48b7

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

scripts/benchmark_netlib.jl

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
using DelimitedFiles
3+
using MadNLP
4+
using MadQP
5+
using MadNLPHSL
6+
using QPSReader
7+
using QuadraticModels
8+
using NLPModels
9+
10+
function NLPModels.cons!(qp::QuadraticModel{T}, x::Vector{T}, c::Vector{T}) where T
11+
return NLPModels.cons_lin!(qp, x, c)
12+
end
13+
14+
function run_benchmark(src, probs)
15+
nprobs = length(probs)
16+
results = zeros(nprobs, 5)
17+
for (k, prob) in enumerate(probs)
18+
@info prob
19+
try
20+
qpdat = readqps(joinpath(src, prob))
21+
catch
22+
continue
23+
end
24+
qpdat = readqps(joinpath(src, prob))
25+
qp = QuadraticModel(qpdat)
26+
27+
try
28+
solver = MadQP.MPCSolver(
29+
qp;
30+
max_iter=300,
31+
linear_solver=Ma27Solver,
32+
print_level=MadNLP.INFO,
33+
max_ncorr=3,
34+
bound_push=1.0,
35+
)
36+
res = MadQP.solve!(solver)
37+
results[k, 1] = Int(res.status)
38+
results[k, 2] = res.iter
39+
results[k, 3] = res.objective
40+
results[k, 4] = res.counters.total_time
41+
results[k, 5] = res.counters.linear_solver_time
42+
catch ex
43+
results[k, 4] = -1
44+
end
45+
end
46+
return results
47+
end
48+
49+
src = fetch_netlib()
50+
sif_files = filter(x -> endswith(x, ".SIF"), readdir(src))
51+
results = run_benchmark(src, sif_files)
52+
writedlm("benchmark-netlib.txt", [sif_files results])
53+

0 commit comments

Comments
 (0)