<commit_before>// Catch
#include <catch.hpp>

// C++ Standard Library
#include <cstdlib>
#include <string>

// Armadillo
#include <armadillo>

// Mantella
#include <mantella>

TEST_CASE("RandomSerach.optimise()", "") {
  std::shared_ptr<mant::OptimisationProblem<>> randomProblem(new mant::bbob::SphereFunction<>(2));
  mant::RandomSearch<> testRandomSearch(randomProblem);
  testRandomSearch.setMaximalNumberOfIterations(1000000);
  testRandomSearch.optimise();

  std::vector<std::pair<arma::Col<double>,double>> history = testRandomSearch.getParameterHistory();

  SECTION("Checks if the parameters are uniformly distributed"){
    for (double dimension : arma::linspace(0, randomProblem->numberOfDimensions_ - 1, randomProblem->numberOfDimensions_)) {
      std::vector<double> marks;
      for (auto mark : history) {
        marks.push_back(mark.first.at(dimension));
      }

      arma::Col<unsigned int> histogram = arma::hist(arma::Col<double>(marks), arma::linspace<arma::Col<double>>(randomProblem->getLowerBounds().at(dimension), randomProblem->getUpperBounds().at(dimension), 100));
      CHECK(0.05 > static_cast<double>(histogram.max() - histogram.min()) / marks.size());
    }<commit_msg>Removed obsolete include<commit_after>// Catch
#include <catch.hpp>

// C++ Standard Library
#include <cstdlib>

// Armadillo
#include <armadillo>

// Mantella
#include <mantella>

TEST_CASE("RandomSerach.optimise()", "") {
  std::shared_ptr<mant::OptimisationProblem<>> randomProblem(new mant::bbob::SphereFunction<>(2));
  mant::RandomSearch<> testRandomSearch(randomProblem);
  testRandomSearch.setMaximalNumberOfIterations(1000000);
  testRandomSearch.optimise();

  std::vector<std::pair<arma::Col<double>,double>> history = testRandomSearch.getParameterHistory();

  SECTION("Checks if the parameters are uniformly distributed"){
    for (double dimension : arma::linspace(0, randomProblem->numberOfDimensions_ - 1, randomProblem->numberOfDimensions_)) {
      std::vector<double> marks;
      for (auto mark : history) {
        marks.push_back(mark.first.at(dimension));
      }

      arma::Col<unsigned int> histogram = arma::hist(arma::Col<double>(marks), arma::linspace<arma::Col<double>>(randomProblem->getLowerBounds().at(dimension), randomProblem->getUpperBounds().at(dimension), 100));
      CHECK(0.05 > static_cast<double>(histogram.max() - histogram.min()) / marks.size());
    }
{'fraction_non_alphanumeric': 0.16021639617145236, 'fraction_numerical': 0.013316687473990845, 'mean_word_length': 6.0498533724340176, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6990453', 'n_tokens_mistral': 793, 'n_tokens_neox': 726, 'n_words': 120}