Skip to content

Commit

Permalink
add batch evaluation unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
foolnotion committed Aug 13, 2023
1 parent 6dc25f1 commit 1f11336
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/source/implementation/evaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "operon/error_metrics/mean_squared_error.hpp"
#include "operon/formatter/formatter.hpp"
#include "operon/interpreter/interpreter.hpp"
#include "operon/operators/creator.hpp"
#include "operon/operators/evaluator.hpp"
#include "operon/optimizer/likelihood/gaussian_likelihood.hpp"
#include "operon/optimizer/likelihood/poisson_likelihood.hpp"
Expand Down Expand Up @@ -77,6 +78,29 @@ TEST_CASE("Evaluation correctness")
}
}

TEST_CASE("Batch evaluation")
{
auto ds = Dataset("./data/Poly-10.csv", /*hasHeader=*/true);
auto range = Range { 0, ds.Rows<std::size_t>() };

using DTable = DispatchTable<Operon::Scalar>;

Operon::Problem problem{ds, range, range};
Operon::PrimitiveSet pset{PrimitiveSet::Arithmetic};
Operon::BalancedTreeCreator creator{pset, ds.VariableHashes()};

Operon::RandomGenerator rng{0};
auto constexpr n{10};

std::vector<Operon::Tree> trees;
std::vector<Operon::Scalar> result(range.Size() * n); for (auto i = 0; i < n; ++i) {
trees.push_back(creator(rng, 20, 10, 20));
}

Operon::EvaluateTrees(trees, ds, range, {result.data(), result.size()});
Operon::EvaluateTrees(trees, ds, range);
}

TEST_CASE("parameter optimization")
{
Operon::RandomGenerator rng{0};
Expand Down

0 comments on commit 1f11336

Please sign in to comment.