-
Notifications
You must be signed in to change notification settings - Fork 3
/
run_benchmark_problems.py
executable file
·101 lines (86 loc) · 3.01 KB
/
run_benchmark_problems.py
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
'''
Run all benchmarks for the PROXQP paper
This code tests the solvers:
- PROXQP (with dense backend)
- OSQP
- GUROBI
- MOSEK
- qpOASES
- quadprog
'''
from benchmark_problems.example import Example
import solvers.solvers as s
from utils.general import gen_int_log_space
from utils.benchmark import compute_stats_info,compute_time_series_plot
import argparse
parser = argparse.ArgumentParser(description='Benchmark Problems Runner')
parser.add_argument('--high_accuracy', help='Test with high accuracy', default=True,
action='store_true')
parser.add_argument('--verbose', help='Verbose solvers', default=False,
action='store_true')
parser.add_argument('--parallel', help='Parallel solution', default=False,
action='store_true')
args = parser.parse_args()
high_accuracy = args.high_accuracy
verbose = args.verbose
parallel = args.parallel
print('high_accuracy', high_accuracy)
print('verbose', verbose)
print('parallel', parallel)
# Add high accuracy solvers when accuracy
if high_accuracy:
solvers = [s.MOSEK,s.qpOASES,s.GUROBI,s.quadprog,s.OSQP,s.PROXQP]
OUTPUT_FOLDER ='benchmark_problems_high_accuracy'
for key in s.settings:
s.settings[key]['high_accuracy'] = True
else:
solvers = []
OUTPUT_FOLDER = 'benchmark_problems'
if verbose:
for key in s.settings:
s.settings[key]['verbose'] = True
# Number of instances per different dimension
n_instances = 5
n_dim = 10
n_average = 100
sparsity = 1 # control problem sparsity
accuracies = [1.e-3] # control accuracy asked
# Run benchmark problems
problems = [
'Random Mixed QP'
#'Random Not Strongly Convex QP',
#'Random Degenerate QP'
]
problem_dimensions = {
'Random Mixed QP': gen_int_log_space(10, 1000, n_dim),
'Random Degenerate QP': gen_int_log_space(10, 1000, n_dim),
'Random Not Strongly Convex QP': gen_int_log_space(10, 1000, n_dim)
}
# Some problems become too big to be executed in parallel and we solve them
# serially
problem_parallel = {
'Random Mixed QP': parallel,
'Random Degenerate QP': parallel,
'Random Not Strongly Convex QP': parallel
}
# Run all examples
for problem in problems:
example = Example(problem,
problem_dimensions[problem],
accuracies,
solvers,
s.settings,
OUTPUT_FOLDER,
n_instances,
n_average,
sparsity
)
example.solve(parallel=problem_parallel[problem])
# Compute results statistics
compute_stats_info(solvers, OUTPUT_FOLDER,
problems=problems,
high_accuracy=high_accuracy)
# plots
suffix = ''
for problem in problems:
compute_time_series_plot(solvers, problem, suffix)