<commit_before>#include "simulated_annealing.hpp"

SimulatedAnnealing::SimulatedAnnealing(
      const double start_tmp
    , const double stop_tmp
    , const int max_it
    , const double min_e
    , const double a
    // , const double tol
) :
  start_temperature(start_tmp)
, stop_temperature(stop_tmp)
, iterations_per_temperature(max_it)
, min_energy(min_e)
, alpha(a)
// , acceptation_tolerance(tol)
{};

double SimulatedAnnealing::random_value()
{
    return double(std::rand()) / double(RAND_MAX);
}

bool SimulatedAnnealing::metropolis_critieria(const double delta_e, const double temperature)
{
    if (delta_e <= 0.0)
        return true;
    else if (random_value() <= std::exp(-delta_e / temperature) )
        return true;
    else
        return false;
}

double SimulatedAnnealing::temperature() const
{
    // assert(step_it <= iterations_per_temperature);
    // return ( double(step_it) / double(iterations_per_temperature)) * current_temperature;

    return alpha * current_temperature;
}
<commit_msg>[simulated_annealing] minor update<commit_after>#include "simulated_annealing.hpp"

SimulatedAnnealing::SimulatedAnnealing(
      const double start_tmp
    , const double stop_tmp
    , const int max_it
    , const double min_e
    , const double a
    // , const double tol
) :
  start_temperature(start_tmp)
, stop_temperature(stop_tmp)
, iterations_per_temperature(max_it)
, min_energy(min_e)
, alpha(a)
// , acceptation_tolerance(tol)
{};

double SimulatedAnnealing::random_value()
{
    return double(std::rand()) / double(RAND_MAX);
}

bool SimulatedAnnealing::metropolis_critieria(const double delta_e, const double temperature)
{
    if (delta_e <= 0.0)
        return true;
    else if (random_value() <= std::exp(-delta_e / temperature) )
        return true;
    else
        return false;
}

double SimulatedAnnealing::temperature() const
{
    return alpha * current_temperature;
}

{'fraction_non_alphanumeric': 0.10630536737884315, 'fraction_numerical': 0.0020844189682126106, 'mean_word_length': 4.1474530831099194, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, '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': '787325', 'n_tokens_mistral': 641, 'n_tokens_neox': 604, 'n_words': 128}