-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark_common.py
More file actions
31 lines (23 loc) · 1.38 KB
/
benchmark_common.py
File metadata and controls
31 lines (23 loc) · 1.38 KB
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
from opticomp import BenchmarkSuite, objective_zoo, wrapper_zoo
# Get common objective from objective_zoo
objective, search_space = objective_zoo.fetch_ackley_function()
search_space = {'param1': (-32.768, 32.768),
'param2': (-32.768, 32.768)}
# Create an instance of the benchmark suite
benchmark_suite = BenchmarkSuite(objective, search_space)
# Add wrappers directly from wrapper_zoo to the benchmark_suite
# benchmark_suite.add_wrapper(wrapper_zoo.fetch_optuna_random())
benchmark_suite.add_wrapper(wrapper_zoo.fetch_optuna_tpe())
benchmark_suite.add_wrapper(wrapper_zoo.fetch_deap_ea())
benchmark_suite.add_wrapper(wrapper_zoo.fetch_hyperopt_tpe())
# Compare and optimize using the added wrappers
results = benchmark_suite.benchmark(direction="minimize", n_runs=3, max_steps=60, target_score=None, verbose=True, progress_bar=True)
# results.plot_boxplot(show=True)
result = results.fetch_wrapper_result("hyperopt_tpe")
print(result.best_params)
result.plot_objective_landscape(["param1", "param2"], resolution=100, show=True)
# result.plot_objective_landscape(["param1", "param2"], show_path=True, resolution=100, show=True)
print(result.best_params)
# result = results.fetch_wrapper_result("optuna_tpe")
# result.plot_objective_landscape(["param1", "param2"], resolution=100, show=True)
# result.plot_objective_landscape(["param1", "param2"], show_path=True, resolution=100, show=True)