<commit_before>/**
 *  \file
 *  \remark This file is part of VITA.
 *
 *  \copyright Copyright (C) 2013-2014 EOS <NAME>.
 *
 *  \license
 *  This Source Code Form is subject to the terms of the Mozilla Public
 *  License, v. 2.0. If a copy of the MPL was not distributed with this file,
 *  You can obtain one at http://mozilla.org/MPL/2.0/
 */

#if !defined(VITA_EVOLUTION_SELECTION_INL_H)
#define      VITA_EVOLUTION_SELECTION_INL_H

///
/// \param[in] pop current population.
/// \param[in] eva current evaluator.
/// \param[in] sum up to date summary of the evolution.
///
template<class T>
strategy<T>::strategy(const population<T> &pop, evaluator<T> &eva,
                      const summary<T> &sum)
  : pop_(pop), eva_(eva), sum_(sum)
{
}

///
/// \return the index of a random individual.
///
template<class T>
coord strategy<T>::pickup() const
{
  const auto n_layers(pop_.layers());

  if (n_layers == 1)
    return {0, vita::random::sup(pop_.individuals(0))};

  // If we have multiple layers we cannot be sure that every layer has the
  // same number of individuals. So the simple (and faster) solution:
  //
  //   const auto l(vita::random::sup(n_layers));
  //
  // would not be appropriate.
  std::vector<unsigned> s(n_layers);
  for (auto l(decltype(n_layers){0}); l < n_layers; ++l)
    s[l] = pop_[l].individuals();

  std::discrete_distribution<> dd(s);
  const auto l(dd(vita::random::engine()));
  return {l, vita::random::sup(pop_.individuals(l))};
}

///
/// \param[in] target coordinates of a reference individual.
/// \return the coordinates of a random individual "near" \a target.
///
/// Parameters from the environment:
/// * mate_zone - to restrict the selection of individuals to a segment of
///   the population;
///
template<class T>
coord strategy<T>::pickup(coord target) const<commit_msg>[FIX] Compilation error under Windows with the new pickup method<commit_after>/**
 *  \file
 *  \remark This file is part of VITA.
 *
 *  \copyright Copyright (C) 2013-2014 EOS di <NAME>.
 *
 *  \license
 *  This Source Code Form is subject to the terms of the Mozilla Public
 *  License, v. 2.0. If a copy of the MPL was not distributed with this file,
 *  You can obtain one at http://mozilla.org/MPL/2.0/
 */

#if !defined(VITA_EVOLUTION_SELECTION_INL_H)
#define      VITA_EVOLUTION_SELECTION_INL_H

///
/// \param[in] pop current population.
/// \param[in] eva current evaluator.
/// \param[in] sum up to date summary of the evolution.
///
template<class T>
strategy<T>::strategy(const population<T> &pop, evaluator<T> &eva,
                      const summary<T> &sum)
  : pop_(pop), eva_(eva), sum_(sum)
{
}

///
/// \return the index of a random individual.
///
template<class T>
coord strategy<T>::pickup() const
{
  const auto n_layers(pop_.layers());

  if (n_layers == 1)
    return {0, vita::random::sup(pop_.individuals(0))};

  // If we have multiple layers we cannot be sure that every layer has the
  // same number of individuals. So the simple (and faster) solution:
  //
  //   const auto l(vita::random::sup(n_layers));
  //
  // would not be appropriate.
  std::vector<unsigned> s(n_layers);
  for (auto l(decltype(n_layers){0}); l < n_layers; ++l)
    s[l] = pop_.individuals(l);

  std::discrete_distribution<unsigned> dd(s.begin(), s.end());
  const auto l(dd(vita::random::engine()));
  return {l, vita::random::sup(pop_.individuals(l))};
}

///
/// \param[in] target coordinates of a reference individual.
/// \return the coordinates of a random individual "near" \a target.
///
/// Parameters from the environment:
/// * mate_zone - to restrict the selection of individuals to a segment of
///   the population;
///
template<class T>
coord strategy<T>::pickup(coord target) const
{'fraction_non_alphanumeric': 0.1507362784471218, 'fraction_numerical': 0.00856760374832664, 'mean_word_length': 3.324074074074074, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 27, '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': '4310614', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1216, 'n_words': 400}