<commit_before>from pyislands.example.evolvetsp import generate_tsp_evolution

from pyislands.types import Island, create_single_island
from pyislands.evolution import finite_evolution, stagnation_evolution

from pyislands import archipelago
from pyislands.archipelago import topology
from pyislands.archipelago import form_destinations
from pyislands.archipelago import assimilation
from pyislands.archipelago.assimilation import get_immigration
from pyislands.archipelago import migration
from pyislands.archipelago.migration import get_emmigration

import pyislands.permutation.tsp.graph as tsp

from itertools import chain


def solve_tsp_classic(adjacency_matrix, max_stagnation=100, population_size=10,
                      selection_pressure=0.5, mutation_probability=0.6):
    '''
    This functions runs a simple genetic algorithm which evolves a solution of
    a travelling salesman problem. It shows how to print out simple diagnostic
    for population.
    '''

# Simple Genetic Algorithm
    create_population, evolve = \
        generate_tsp_evolution(population_size, selection_pressure,
                               mutation_probability, adjacency_matrix)

    island = create_single_island(create_population, evolve)
    enumerated_evolution = enumerate(stagnation_evolution(max_stagnation, island))
    for iteration, population in enumerated_evolution:
        best = min(population)
        print("iter = {0}, penalty = {1}".format(iteration, best.penalty))

    return tuple(tsp.form_cycle(best.genotype)), best.penalty


def solve_tsp_islands(adjacency_matrix, num_iterations=10000, use_multiprocess=False):
    '''
    This functions runs an island genetic algorithm which evolves a solution of
    a travelling salesman problem. It shows how to print out simple diagnostic
    for population.
    '''

    num_islands = 4
    migration_size = 1
    migration_interval = 1
    degree = 1
<commit_msg>verbose added to solve_tsp_classic<commit_after>from pyislands.example.evolvetsp import generate_tsp_evolution

from pyislands.types import Island, create_single_island
from pyislands.evolution import finite_evolution, stagnation_evolution

from pyislands import archipelago
from pyislands.archipelago import topology
from pyislands.archipelago import form_destinations
from pyislands.archipelago import assimilation
from pyislands.archipelago.assimilation import get_immigration
from pyislands.archipelago import migration
from pyislands.archipelago.migration import get_emmigration

import pyislands.permutation.tsp.graph as tsp

from itertools import chain


def solve_tsp_classic(adjacency_matrix, max_stagnation=100, population_size=10,
                      selection_pressure=0.5, mutation_probability=0.6,
                      verbose=True):
    '''
    This functions runs a simple genetic algorithm which evolves a solution of
    a travelling salesman problem. It shows how to print out simple diagnostic
    for population.
    '''

# Simple Genetic Algorithm
    create_population, evolve = \
        generate_tsp_evolution(population_size, selection_pressure,
                               mutation_probability, adjacency_matrix)

    island = create_single_island(create_population, evolve)
    enumerated_evolution = enumerate(stagnation_evolution(max_stagnation, island))
    for iteration, population in enumerated_evolution:
        if verbose:
            best = min(population)
            print("iter = {0}, penalty = {1}".format(iteration, best.penalty))

    return tuple(tsp.form_cycle(best.genotype)), best.penalty


def solve_tsp_islands(adjacency_matrix, num_iterations=10000, use_multiprocess=False):
    '''
    This functions runs an island genetic algorithm which evolves a solution of
    a travelling salesman problem. It shows how to print out simple diagnostic
    for population.
    '''

    num_islands = 4
    migration_size = 1
    migration_interval = 1
    degree = 1

{'fraction_non_alphanumeric': 0.05556965237249429, 'fraction_numerical': 0.010149708195889368, 'mean_word_length': 4.180026281208936, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3839308', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1064, 'n_words': 306}