-
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.
Fix happycat function and extend fuzzing time
- Loading branch information
Showing
11 changed files
with
73 additions
and
53 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,82 @@ | ||
// clang-format off | ||
#include "gtest/gtest.h" | ||
#include "fuzztest/fuzztest.h" | ||
#include "helpers/combinators.hpp" | ||
#include "fuzztest/googletest_fixture_adapter.h" | ||
#include "fuzztest/domain.h" | ||
// clang-format on | ||
|
||
#include <range/v3/all.hpp> | ||
|
||
#include "cecxx/evaluator.hpp" | ||
#include "cecxx/benchmark/evaluator.hpp" | ||
|
||
#include "cecxx/types.hpp" | ||
#include "helpers/combinators.hpp" | ||
|
||
#include "helpers/cec_suite.hpp" | ||
#include "helpers/oracle.hpp" | ||
|
||
using namespace fuzztest; | ||
using namespace cecxx::benchmark; | ||
|
||
class CecFuzzTest10D : public PerFuzzTestFixtureAdapter<CecTestFixture<cecxx::cec_edition_t::cec2017, 10>> { | ||
public: | ||
constexpr auto MAX_ABS_ERROR = 1e-10; | ||
|
||
class CecFuzzTest10D : public PerFuzzTestFixtureAdapter< | ||
CecTestFixture<cec_edition_t::cec2017, 10>> { | ||
public: | ||
void Cec2017ImplsAreEquiv(std::vector<double> input, int problem_num) { | ||
const auto oracle_output = calculate_oracle_output(input, problem_num); | ||
const auto cecxx_output = cec_evaluator(problem_num, std::vector<std::vector<double>>{input}); | ||
const auto delta = std::abs(oracle_output - cecxx_output[0]); | ||
EXPECT_TRUE(delta < 1); | ||
const auto cecxx_output = | ||
cec_evaluator(problem_num, std::vector<std::vector<double>>{input}); | ||
EXPECT_NEAR(oracle_output, cecxx_output[0], MAX_ABS_ERROR); | ||
} | ||
}; | ||
|
||
FUZZ_TEST_F(CecFuzzTest10D, Cec2017ImplsAreEquiv) | ||
.WithDomains(PositiveVectorOf<double>(InRange(-1.0, 1.0)).WithSize(10), InCecProblemRange(cecxx::cec_edition_t::cec2017)); | ||
.WithDomains(PositiveVectorOf<double>(InRange(-1.0, 1.0)).WithSize(10), | ||
InCecProblemRange(cec_edition_t::cec2017)); | ||
|
||
class CecFuzzTest30D : public PerFuzzTestFixtureAdapter<CecTestFixture<cecxx::cec_edition_t::cec2017, 30>> { | ||
public: | ||
class CecFuzzTest30D : public PerFuzzTestFixtureAdapter< | ||
CecTestFixture<cec_edition_t::cec2017, 30>> { | ||
public: | ||
void Cec2017ImplsAreEquiv(std::vector<double> input, int problem_num) { | ||
const auto oracle_output = calculate_oracle_output(input, problem_num); | ||
const auto cecxx_output = cec_evaluator(problem_num, std::vector<std::vector<double>>{input}); | ||
const auto delta = std::abs(oracle_output - cecxx_output[0]); | ||
EXPECT_TRUE(delta < 1); | ||
const auto cecxx_output = | ||
cec_evaluator(problem_num, std::vector<std::vector<double>>{input}); | ||
EXPECT_NEAR(oracle_output, cecxx_output[0], MAX_ABS_ERROR); | ||
} | ||
}; | ||
|
||
FUZZ_TEST_F(CecFuzzTest30D, Cec2017ImplsAreEquiv) | ||
.WithDomains(PositiveVectorOf<double>(InRange(-1.0, 1.0)).WithSize(30), InCecProblemRange(cecxx::cec_edition_t::cec2017)); | ||
.WithDomains(PositiveVectorOf<double>(InRange(-1.0, 1.0)).WithSize(30), | ||
InCecProblemRange(cec_edition_t::cec2017)); | ||
|
||
class CecFuzzTest50D : public PerFuzzTestFixtureAdapter<CecTestFixture<cecxx::cec_edition_t::cec2017, 50>> { | ||
public: | ||
class CecFuzzTest50D : public PerFuzzTestFixtureAdapter< | ||
CecTestFixture<cec_edition_t::cec2017, 50>> { | ||
public: | ||
void Cec2017ImplsAreEquiv(std::vector<double> input, int problem_num) { | ||
const auto oracle_output = calculate_oracle_output(input, problem_num); | ||
const auto cecxx_output = cec_evaluator(problem_num, std::vector<std::vector<double>>{input}); | ||
const auto delta = std::abs(oracle_output - cecxx_output[0]); | ||
EXPECT_TRUE(delta < 1); | ||
const auto cecxx_output = | ||
cec_evaluator(problem_num, std::vector<std::vector<double>>{input}); | ||
|
||
EXPECT_NEAR(oracle_output, cecxx_output[0], MAX_ABS_ERROR); | ||
} | ||
}; | ||
|
||
FUZZ_TEST_F(CecFuzzTest50D, Cec2017ImplsAreEquiv) | ||
.WithDomains(PositiveVectorOf<double>(InRange(-1.0, 1.0)).WithSize(50), InCecProblemRange(cecxx::cec_edition_t::cec2017)); | ||
.WithDomains(PositiveVectorOf<double>(InRange(-1.0, 1.0)).WithSize(50), | ||
InCecProblemRange(cec_edition_t::cec2017)); | ||
|
||
class CecFuzzTest100D : public PerFuzzTestFixtureAdapter<CecTestFixture<cecxx::cec_edition_t::cec2017, 100>> { | ||
public: | ||
class CecFuzzTest100D : public PerFuzzTestFixtureAdapter< | ||
CecTestFixture<cec_edition_t::cec2017, 100>> { | ||
public: | ||
void Cec2017ImplsAreEquiv(std::vector<double> input, int problem_num) { | ||
const auto oracle_output = calculate_oracle_output(input, problem_num); | ||
const auto cecxx_output = cec_evaluator(problem_num, std::vector<std::vector<double>>{input}); | ||
const auto delta = std::abs(oracle_output - cecxx_output[0]); | ||
EXPECT_TRUE(delta < 10); | ||
const auto cecxx_output = | ||
cec_evaluator(problem_num, std::vector<std::vector<double>>{input}); | ||
EXPECT_NEAR(oracle_output, cecxx_output[0], MAX_ABS_ERROR); | ||
} | ||
}; | ||
|
||
FUZZ_TEST_F(CecFuzzTest100D, Cec2017ImplsAreEquiv) | ||
.WithDomains(PositiveVectorOf<double>(InRange(-1.0, 1.0)).WithSize(100), InCecProblemRange(cecxx::cec_edition_t::cec2017)); | ||
.WithDomains(PositiveVectorOf<double>(InRange(-1.0, 1.0)).WithSize(100), | ||
InCecProblemRange(cec_edition_t::cec2017)); |
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,9 +1,15 @@ | ||
#pragma once | ||
|
||
// clang-format off | ||
#include "gtest/gtest.h" | ||
#include "cecxx/evaluator.hpp" | ||
// clang-format on | ||
|
||
template <cecxx::cec_edition_t Edition, int Dimension> struct CecTestFixture : public testing::Test { | ||
CecTestFixture() : cec_evaluator{cecxx::evaluator(Edition, Dimension, DATA_STORAGE_PATH)} {} | ||
cecxx::evaluator cec_evaluator; | ||
#include "cecxx/benchmark/evaluator.hpp" | ||
|
||
template <cecxx::benchmark::cec_edition_t Edition, int Dimension> | ||
struct CecTestFixture : public testing::Test { | ||
CecTestFixture() | ||
: cec_evaluator{cecxx::benchmark::evaluator(Edition, Dimension, | ||
DATA_STORAGE_PATH)} {} | ||
cecxx::benchmark::evaluator cec_evaluator; | ||
}; |
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