-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
314 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 3 additions & 71 deletions
74
include/cecxx/benchmark/cec_2017/problem_evaluation_mappings.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,10 @@ | ||
#pragma once | ||
|
||
#include "cecxx/benchmark/cec_2017/basic_problems.hpp" | ||
#include "cecxx/benchmark/cec_2017/complex_problems.hpp" | ||
#include "cecxx/benchmark/cec_2017/hybrid_problems.hpp" | ||
#include "cecxx/benchmark/detail/context.hpp" | ||
#include "cecxx/benchmark/types.hpp" | ||
#include <cecxx/benchmark/detail/context.hpp> | ||
#include <cecxx/benchmark/types.hpp> | ||
|
||
namespace cecxx::benchmark::cec_2017 { | ||
|
||
inline auto evaluate(detail::problem_context_view_t ctx, const problem_number_t fn, std::span<const double> input) { | ||
switch (fn) { | ||
case 1: | ||
return bent_cigar(input, ctx); | ||
case 2: | ||
return sum_diff_pow(input, ctx); | ||
case 3: | ||
return zakharov(input, ctx); | ||
case 4: | ||
return rosenbrock(input, ctx); | ||
case 5: | ||
return rastrigin(input, ctx); | ||
case 6: | ||
return schaffer(input, ctx); | ||
case 7: | ||
return bi_rastrigin(input, ctx); | ||
case 8: | ||
return step_rastrigin(input, ctx); | ||
case 9: | ||
return levy(input, ctx); | ||
case 10: | ||
return schwefel(input, ctx); | ||
case 11: | ||
return hybrid_1(input, ctx); | ||
case 12: | ||
return hybrid_2(input, ctx); | ||
case 13: | ||
return hybrid_3(input, ctx); | ||
case 14: | ||
return hybrid_4(input, ctx); | ||
case 15: | ||
return hybrid_5(input, ctx); | ||
case 16: | ||
return hybrid_6(input, ctx); | ||
case 17: | ||
return hybrid_7(input, ctx); | ||
case 18: | ||
return hybrid_8(input, ctx); | ||
case 19: | ||
return hybrid_9(input, ctx); | ||
case 20: | ||
return hybrid_10(input, ctx); | ||
case 21: | ||
return complex_1(input, ctx); | ||
case 22: | ||
return complex_2(input, ctx); | ||
case 23: | ||
return complex_3(input, ctx); | ||
case 24: | ||
return complex_4(input, ctx); | ||
case 25: | ||
return complex_5(input, ctx); | ||
case 26: | ||
return complex_6(input, ctx); | ||
case 27: | ||
return complex_7(input, ctx); | ||
case 28: | ||
return complex_8(input, ctx); | ||
case 29: | ||
return complex_9(input, ctx); | ||
case 30: | ||
return complex_10(input, ctx); | ||
} | ||
|
||
throw std::runtime_error{"Unknown CEC problem"}; | ||
} | ||
auto evaluate(detail::problem_context_view_t ctx, const problem_number_t fn, std::span<const double> input) -> double; | ||
|
||
} // namespace cecxx::benchmark::cec_2017 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
include/cecxx/benchmark/detail/legacy/affine_transformation.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 2 additions & 79 deletions
81
include/cecxx/benchmark/detail/legacy/functions/multimodal/bi_rastrigin.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,12 @@ | ||
#pragma once | ||
|
||
#include <cmath> | ||
#include <vector> | ||
|
||
#include "cecxx/benchmark/detail/context.hpp" | ||
#include "cecxx/benchmark/detail/legacy/affine_transformation.hpp" | ||
#include "cecxx/enum.hpp" | ||
|
||
namespace cecxx::functions::multimodal::legacy { | ||
|
||
inline auto bi_rastrigin(std::span<const double> input, benchmark::detail::problem_context_view_t ctx, | ||
benchmark::affine_mask_t mask) -> double { | ||
using namespace cecxx::benchmark; | ||
const auto nrow = input.size(); | ||
auto y = std::vector<double>(nrow); | ||
auto z = std::vector<double>(nrow); | ||
auto tmpx = std::vector<double>(nrow); | ||
|
||
if (to_underlying(mask.shift) == 1) { | ||
detail::shiftfunc(input, y, ctx.shift); | ||
} else { | ||
// shrink to the orginal search range | ||
for (auto i = 0u; i < nrow; i++) { | ||
y[i] = input[i]; | ||
} | ||
} | ||
|
||
// shrink to the orginal search range | ||
for (auto i = 0u; i < nrow; i++) { | ||
y[i] *= 10.0 / 100.0; | ||
} | ||
|
||
constexpr auto mu0 = 2.5; | ||
|
||
for (auto i = 0u; i < nrow; i++) { | ||
tmpx[i] = 2 * y[i]; | ||
if (ctx.shift[i] < 0.0) | ||
tmpx[i] *= -1.; | ||
} | ||
for (auto i = 0u; i < nrow; i++) { | ||
z[i] = tmpx[i]; | ||
tmpx[i] += mu0; | ||
} | ||
|
||
double tmp{}; | ||
double tmp1{}; | ||
double tmp2{}; | ||
constexpr auto d = 1.0; | ||
auto s = 1.0 - 1.0 / (2.0 * std::pow(static_cast<double>(nrow) + 20.0, 0.5) - 8.2); | ||
auto mu1 = -std::pow((mu0 * mu0 - d) / s, 0.5); | ||
for (auto i = 0u; i < nrow; i++) { | ||
tmp = tmpx[i] - mu0; | ||
tmp1 += tmp * tmp; | ||
tmp = tmpx[i] - mu1; | ||
tmp2 += tmp * tmp; | ||
} | ||
tmp2 *= s; | ||
tmp2 += d * static_cast<double>(nrow); | ||
tmp = 0.0; | ||
auto output{0.0}; | ||
|
||
if (to_underlying(mask.rot) == 1) { | ||
detail::rotatefunc(z, y, ctx.rotate); | ||
for (auto i = 0u; i < nrow; i++) { | ||
tmp += std::cos(2.0 * M_PI * y[i]); | ||
} | ||
if (tmp1 < tmp2) { | ||
output = tmp1; | ||
} else { | ||
output = tmp2; | ||
} | ||
output += 10.0 * (static_cast<double>(nrow) - tmp); | ||
} else { | ||
for (auto i = 0u; i < nrow; i++) { | ||
tmp += std::cos(2.0 * M_PI * z[i]); | ||
} | ||
if (tmp1 < tmp2) { | ||
output = tmp1; | ||
} else { | ||
output = tmp2; | ||
} | ||
output += 10.0 * (static_cast<double>(nrow) - tmp); | ||
} | ||
|
||
return output; | ||
} | ||
auto bi_rastrigin(std::span<const double> input, benchmark::detail::problem_context_view_t ctx, | ||
benchmark::affine_mask_t mask) -> double; | ||
|
||
} // namespace cecxx::functions::multimodal::legacy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
include/cecxx/benchmark/detail/problem_invokers/basic_problem_invoker.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.