|
8 | 8 |
|
9 | 9 | #include "cecxx/benchmark/evaluator.hpp"
|
10 | 10 |
|
11 |
| -constexpr auto DIMENSION{10}; |
12 |
| -constexpr auto CEC_STORAGE{"/home/ewarchul/open-source/optim/cec/data"}; |
| 11 | +constexpr auto DIMENSION{10u}; |
| 12 | +constexpr auto CEC_STORAGE{"/home/ewarchul/open-source/optim/cecxx/data"}; |
13 | 13 |
|
14 | 14 | namespace rv = ranges::views;
|
| 15 | +using namespace cecxx; |
15 | 16 |
|
16 | 17 | auto main() -> int {
|
17 | 18 | try {
|
18 | 19 | // Create an evaluator object for the CEC2017 benchmark
|
19 |
| - auto cec2017_eval = cecxx::benchmark::evaluator(cecxx::benchmark::cec_edition_t::cec2017, DIMENSION, CEC_STORAGE); |
| 20 | + auto cec2017_eval = benchmark::evaluator( |
| 21 | + cecxx::benchmark::cec_edition_t::cec2017, DIMENSION, CEC_STORAGE); |
20 | 22 |
|
21 | 23 | // Prepare input which resembles multidimensional array
|
22 |
| - const auto input = std::vector<std::vector<double>>{rv::repeat(10.0) | rv::take(DIMENSION) | ranges::to_vector}; |
| 24 | + const auto input = std::vector<std::vector<f64>>{ |
| 25 | + rv::repeat(10.0) | rv::take(DIMENSION) | ranges::to_vector}; |
| 26 | + |
| 27 | + |
23 | 28 |
|
24 | 29 | // Evaluate given input on each optimization problem from CEC2017
|
25 | 30 | const auto start = std::chrono::system_clock::now();
|
26 |
| - for (const auto& fn : rv::closed_iota(1, 30)) { |
| 31 | + for (const auto &fn : rv::closed_iota(11, 11)) { |
27 | 32 | auto output = cec2017_eval(fn, input);
|
28 | 33 | fmt::println("fn = {}, output = {:}", fn, output);
|
29 | 34 | }
|
30 | 35 | fmt::println("Elapsed time: {}",
|
31 |
| - std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now() - start)); |
| 36 | + std::chrono::duration_cast<std::chrono::microseconds>( |
| 37 | + std::chrono::system_clock::now() - start)); |
32 | 38 |
|
33 | 39 | return EXIT_SUCCESS;
|
34 | 40 | // Create a closure for 1st optimizaiton problem from CEC2017
|
35 |
| - const auto first_fn = [&eval = cec2017_eval](const auto& xs) { return eval(11, xs); }; |
| 41 | + const auto first_fn = [&eval = cec2017_eval](const auto &xs) { |
| 42 | + return eval(11, xs); |
| 43 | + }; |
36 | 44 | auto output = first_fn(input);
|
37 | 45 | // fmt::println("fn = 11, output = {}", output);
|
38 | 46 |
|
39 |
| - } catch (std::exception& e) { |
| 47 | + } catch (std::exception &e) { |
40 | 48 | fmt::println("Error: {}", e.what());
|
41 | 49 | }
|
42 | 50 |
|
|
0 commit comments