<commit_before>namespace mant {
  template <typename T>
  class CuckooSearch : public PopulationBasedOptimisationAlgorithm<T> {
    public:
      explicit CuckooSearch(
          const std::shared_ptr<OptimisationProblem<T>> optimisationProblem,
          const unsigned int populationSize) noexcept;
		  
      void setDiscoveryProbability(
					const double discoveryProbability) noexcept;
      void setLevyStepSize(
					const T levyStepSize) noexcept;
	  
			std::string toString() const noexcept override;

    protected:
      double discoveryProbability_;
      T levyStepSize_;

      void optimiseImplementation() override;
  };

  //
  //Implementation
  //

  template <typename T>
  CuckooSearch<T>::CuckooSearch(
      const std::shared_ptr<OptimisationProblem<T>> optimisationProblem,
      const unsigned int populationSize) noexcept
    : PopulationBasedOptimisationAlgorithm<T>(optimisationProblem, populationSize) {
    setDiscoveryProbability(0.25);
    setLevyStepSize(1.0);
  }

  template <typename T>
  void CuckooSearch<T>::optimiseImplementation() {
    arma::Mat<T> nests = this->getRandomPopulation();

    arma::Col<double> objectiveValues(this->populationSize_);
    for (std::size_t n = 0; n < this->populationSize_; ++n) {
			++this->numberOfIterations_;
      this->updateBestParameter(nests.col(n), this->getSoftConstraintsValue(nests.col(n)), this->getObjectiveValue(nests.col(n)));
    }
    
		unsigned int rankIndex;
    while(!this->isFinished() && !this->isTerminated()){
			++this->numberOfIterations_;
      
			objectiveValues.min(rankIndex);			
      const arma::Col<T>& cuckooCandidate = this->boundaryHandling(nests.col(rankIndex) + levyStepSize_ * 0.01 * ((arma::randn<arma::Col<T>>(this->numberOfDimensions_) * std::pow(std::tgamma(2.5) * std::sin(arma::datum::pi * 0.75) / (std::tgamma(1.25) * 1.5 * std::pow(2, 0.25)), 2/3)) / arma::pow(arma::abs(arma::randn<arma::Col<T>>(this->numberOfDimensions_)), 2/3)) % (nests.col(rankIndex) - this->bestParameter_));
      const double objectiveValue = this->getObjectiveValue(cuckooCandidate);
      
			objectiveValues.max(rankIndex);
			if(objectiveValue < objectiveValues(rankIndex)) {
				nests.col(rankIndex) = cuckooCandidate;
				objectiveValues(rankIndex) = objectiveValue;
			}			
      
			this->updateBestParameter(cuckooCandidate, 0.0, objectiveValue);
      
      if(this->isFinished() || this->isTerminated()) {
        break;
      }
        <commit_msg>fixed some minor bugs<commit_after>namespace mant {
  template <typename T>
  class CuckooSearch : public PopulationBasedOptimisationAlgorithm<T> {
    public:
      explicit CuckooSearch(
          const std::shared_ptr<OptimisationProblem<T>> optimisationProblem,
          const unsigned int populationSize) noexcept;
		  
      void setDiscoveryProbability(
					const double discoveryProbability) noexcept;
      void setLevyStepSize(
					const T levyStepSize) noexcept;
	  
			std::string toString() const noexcept override;

    protected:
      double discoveryProbability_;
      T levyStepSize_;

      void optimiseImplementation() override;
  };

  //
  //Implementation
  //

  template <typename T>
  CuckooSearch<T>::CuckooSearch(
      const std::shared_ptr<OptimisationProblem<T>> optimisationProblem,
      const unsigned int populationSize) noexcept
    : PopulationBasedOptimisationAlgorithm<T>(optimisationProblem, populationSize) {
    setDiscoveryProbability(0.25);
    setLevyStepSize(1.0);
  }

  template <typename T>
  void CuckooSearch<T>::optimiseImplementation() {
    arma::Mat<T> nests = this->getRandomPopulation();

    arma::Col<double> objectiveValues(this->populationSize_);
    for (std::size_t n = 0; n < this->populationSize_; ++n) {
			++this->numberOfIterations_;
			objectiveValues(n) = this->getObjectiveValue(nests.col(n));
      this->updateBestParameter(nests.col(n), this->getSoftConstraintsValue(nests.col(n)), objectiveValues(n));
    }
    
		unsigned int rankIndex;
    while(!this->isFinished() && !this->isTerminated()){
			++this->numberOfIterations_;
      
			objectiveValues.min(rankIndex);	
      const arma::Col<T>& cuckooCandidate = this->boundaryHandling(nests.col(rankIndex) + (levyStepSize_ / 100) * (arma::randn<arma::Col<T>>(this->numberOfDimensions_) * (std::pow(std::tgamma(2.5) * std::sin(arma::datum::pi * 0.75) / (std::tgamma(1.25) * 1.5 * std::pow(2, 0.25)), 2/3)) / (arma::pow(arma::abs(arma::randn<arma::Col<T>>(this->numberOfDimensions_)), 2/3))));
			
      const double objectiveValue = this->getObjectiveValue(cuckooCandidate);

			objectiveValues.max(rankIndex);
			if(objectiveValue < objectiveValues(rankIndex)) {
				nests.col(rankIndex) = cuckooCandidate;
				objectiveValues(rankIndex) = objectiveValue;
			}			
      
			this->updateBestParameter(cuckooCandidate, 0.0, objectiveValue);
      
      if(this->isFinished() || this->isTerminated()) {
        break;
      }
        
{'fraction_non_alphanumeric': 0.13314390095392734, 'fraction_numerical': 0.01177186929165821, 'mean_word_length': 4.0961737331954495, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 74, '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': '5112046', 'n_tokens_mistral': 1716, 'n_tokens_neox': 1547, 'n_words': 255}