ga_simple.py
def mutation(population):
    """
        Individuals are randomly mutated. Without the mutation of new genes,
        the solution could never be reached.
    """
    for i in range(len(population)-pressure):
        if random.random() <= mutation: # Each individual of the population (minus the parents) has a probability of mutating
            cut_point = random.randint(0,gen_size-1) # A random cut point is chosen
            nuevo_valor = random.randint(1,9) #A nd a new value for this point

            # It is important to see that the new value is not the same as the old one
            while nuevo_valor == population[i][cut_point]:
                nuevo_valor = random.randint(1,9)

            # Mutation is applied
            population[i][cut_point] = nuevo_valor

    return population

        Individuals are randomly mutated. Without the mutation of new genes,
        the solution could never be reached.
    
Individuals are randomly mutated. Without the mutation of new genes,
the solution could never be reached.
Individuals are randomly mutated . Without the mutation of new genes the solution could never be reached .
def mutation(population):
    for i in range(len(population)-pressure):
        if random.random() <= mutation: 
            cut_point = random.randint(0,gen_size-1) 
            nuevo_valor = random.randint(1,9) 
            while nuevo_valor == population[i][cut_point]:
                nuevo_valor = random.randint(1,9)
            population[i][cut_point] = nuevo_valor
    return population
def mutation ( population ) : for i in range ( len ( population ) - pressure ) : if random . random ( ) <= mutation : cut_point = random . randint ( 0 , gen_size - 1 ) nuevo_valor = random . randint ( 1 , 9 ) while nuevo_valor == population [ i ] [ cut_point ] : nuevo_valor = random . randint ( 1 , 9 ) population [ i ] [ cut_point ] = nuevo_valor return population
Individuals are randomly mutated.
Individuals are randomly mutated .
"""
        Individuals are randomly mutated. Without the mutation of new genes,
        the solution could never be reached.
    """ # Each individual of the population (minus the parents) has a probability of mutating # A random cut point is chosen #A nd a new value for this point # It is important to see that the new value is not the same as the old one # Mutation is applied
population