<commit_before>#include <iostream>
#include <fstream>
#include <sstream>

#include "boost/program_options.hpp"

#include "maxis/graph.hpp"
#include "maxis/solver.hpp"
#include "maxis/genetic.hpp"

using namespace maxis;

int
main(int argc, char *argv[]) {
    namespace po = boost::program_options;
    using std::cout;
    using std::endl;

    // Parse arguments
    po::options_description opts{"Options"};
    opts.add_options()
        ("help,h", "Display usage information")
        ("file", po::value<std::string>(), "Input file")
        ("population,p", po::value<size_t>(), "Population size")
        ("constraint,w", po::value<double>()->default_value(30), "Constraint weight")
        ("mutation,m", po::value<double>()->default_value(7), "Mutation rate")
        ("mutation-start", po::value<size_t>()->default_value(5000), "Point at which mutation"
            " reaches half of its final rate (will only take effect with VariableRateMutator)")
        ("mutation-gradient", po::value<double>()->default_value(0.005), "Mutation growth rate (will only take effect with Variable Rate Mutator)")
        ("selector,s", po::value<size_t>()->default_value(2), "Tournament Size");

    po::positional_options_description p;
    p.add("file", -1);
    po::variables_map vm;
    po::store(po::command_line_parser(argc, argv).options(opts).positional(p).run(), vm);
    po::notify(vm);
    if (!vm.count("file")) {
        cout << "No input file specified" << endl;
        return 1;
    }

    // Parse and initialize graph
    std::ifstream is(vm["file"].as<std::string>());
    auto graph = maxis::Graph::from_ascii_dimacs(is);

    // Initialize genetic solver
    auto pop_size = graph.order() / 2;
    if (vm.count("population")) {
        pop_size = vm["population"].as<size_t>();
    }
    genetic::TournamentSelector sel{vm["selector"].as<size_t>()};
    genetic::BlendingRecombinator rec{};
    genetic::VariableRateMutator mut{
        vm["mutation"].as<double>(),
        vm["mutation-start"].as<size_t>(),
        vm["mutation-gradient"].as<double>()
    };

    maxis::ParallelGeneticMaxisSolver solver{graph, genetic::AlgorithmStrategy(sel, rec, mut)};
    solver.constraint = vm["constraint"].as<double>();
    solver.size = pop_size;
    solver.migration_period = 512;

    // Solve and print results
    auto result = graph.weighted_maxis(solver);

    auto is_valid_result = graph.is_independent_set(result);
    cout << endl << "Results" << endl << "=======" << endl;
    if (!is_valid_result) {
        cout << "ERROR Invalid Independent Set: ";
    } else {
        cout << "Vertices: ";
    }

    for (auto it = begin(result); it != end(result); ++it) {
        if (*it) {
            cout << std::distance(begin(result), it) << " ";
        }
    }
    cout << endl;

    if (is_valid_result) {
        cout << "Weight: " << graph.weighted_total(result) << endl;
    }
}<commit_msg>Change migration period for parallel solver<commit_after>#include <iostream>
#include <fstream>
#include <sstream>

#include "boost/program_options.hpp"

#include "maxis/graph.hpp"
#include "maxis/solver.hpp"
#include "maxis/genetic.hpp"

using namespace maxis;

int
main(int argc, char *argv[]) {
    namespace po = boost::program_options;
    using std::cout;
    using std::endl;

    // Parse arguments
    po::options_description opts{"Options"};
    opts.add_options()
        ("help,h", "Display usage information")
        ("file", po::value<std::string>(), "Input file")
        ("population,p", po::value<size_t>(), "Population size")
        ("constraint,w", po::value<double>()->default_value(30), "Constraint weight")
        ("mutation,m", po::value<double>()->default_value(7), "Mutation rate")
        ("mutation-start", po::value<size_t>()->default_value(5000), "Point at which mutation"
            " reaches half of its final rate (will only take effect with VariableRateMutator)")
        ("mutation-gradient", po::value<double>()->default_value(0.005), "Mutation growth rate (will only take effect with Variable Rate Mutator)")
        ("selector,s", po::value<size_t>()->default_value(2), "Tournament Size");

    po::positional_options_description p;
    p.add("file", -1);
    po::variables_map vm;
    po::store(po::command_line_parser(argc, argv).options(opts).positional(p).run(), vm);
    po::notify(vm);
    if (!vm.count("file")) {
        cout << "No input file specified" << endl;
        return 1;
    }

    // Parse and initialize graph
    std::ifstream is(vm["file"].as<std::string>());
    auto graph = maxis::Graph::from_ascii_dimacs(is);

    // Initialize genetic solver
    auto pop_size = graph.order() / 2;
    if (vm.count("population")) {
        pop_size = vm["population"].as<size_t>();
    }

    // genetic::RouletteSelector sel{};
    genetic::TournamentSelector sel{vm["selector"].as<size_t>()};

    genetic::BlendingRecombinator rec{};

    // genetic::SimpleMutator mut{vm["mutation"].as<double>()};
    genetic::VariableRateMutator mut{
        vm["mutation"].as<double>(),
        vm["mutation-start"].as<size_t>(),
        vm["mutation-gradient"].as<double>()
    };

    maxis::ParallelGeneticMaxisSolver solver{graph, genetic::AlgorithmStrategy(sel, rec, mut)};
    solver.constraint = vm["constraint"].as<double>();
    solver.size = pop_size;
    solver.migration_period = 2048;

    // Solve and print results
    auto result = graph.weighted_maxis(solver);

    auto is_valid_result = graph.is_independent_set(result);
    cout << endl << "Results" << endl << "=======" << endl;
    if (!is_valid_result) {
        cout << "ERROR Invalid Independent Set: ";
    } else {
        cout << "Vertices: ";
    }

    for (auto it = begin(result); it != end(result); ++it) {
        if (*it) {
            cout << std::distance(begin(result), it) << " ";
        }
    }
    cout << endl;

    if (is_valid_result) {
        cout << "Weight: " << graph.weighted_total(result) << endl;
    }
}
{'fraction_non_alphanumeric': 0.17427037906742704, 'fraction_numerical': 0.006205971150620597, 'mean_word_length': 3.5174242424242426, 'pattern_counts': {'":': 0, '<': 98, '<?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': '449652', 'n_tokens_mistral': 1935, 'n_tokens_neox': 1854, 'n_words': 397}