Search code examples
genetic-algorithmgenetic-programmingn-queens

Apply mutation (with small probability) to the offspring


I am learning genetic algorithm and when I studied about mutation some thing was there I can't figured out.It was a little unusual after we produce offspring by crossover point we should apply mutation(with small probability) what is that small probability? I have image about 8 queen problem that we found optimal answer for it here our crossover point is 3 so why for example we have mutation in first and third and last population but not in second one?? enter image description here

I am sorry that this question might be silly!


Solution

  • First, what you call population, it's actually just an individual from a population. The population is the whole set of all individuals.

    A good genetic algorithm is one that balances "Exploration & Exploatation". Exploration tries to find out new solutions not caring how good they are (because they might be leading to some better solutions). Exploatation is trying to take advantage of what the algorithm already knows as being "good solutions".

    CROSSOVER = EXPLOATATION Using crossover you are trying to combine the best individuals (fitness wise) to produce even better solutions

    MUTATION = EXPLORATION Using mutation you try to get out of your "gene pool" and find out new solutions, with new characteristics that don't arise from your current population.

    This being said, the best way to balance them is usually trial&error. For a certain input try to play with the parameters and see how they work.

    About why the 2nd individual didn't mutate at all is just simply because the probabilistic process that mutates individual didn't choose it. Usually, on this kind of problems, mutation works like this:

    for individual in population do:
        for gene in individual:
            if random() < MUTATION_RATIO:
                mutate(gene)
    

    This means that an individual might suffer even more than one mutation.