Skip to content

0-harshit-0/genetic-algo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

genetic algorithm

special thaks to Daniel Shiffman and his work Nature of code.

In computer science and operations research, a genetic algorithm (GA) is a metaheuristic inspired by the process of natural selection that belongs to the larger class of evolutionary algorithms (EA). Genetic algorithms are commonly used to generate high-quality solutions to optimization and search problems by relying on biologically inspired operators such as mutation, crossover and selection.

process involved in genetic algorithm:-

    SETUP:
  1. Initialize. Create a population of N elements, each with randomly generated DNA.
  2. LOOP:
  3. Selection. Evaluate the fitness of each element of the population and build a matingpool.
  4. Reproduction. Repeat N times:
    1. Pick two parents with probability according to relative fitness.
    2. Crossover—create a “child” by combining the DNA of these two parents.
    3. Mutation—mutate the child’s DNA based on a given probability.
    4. Add the new child to a new population.
  5. Replace the old population with the new population and return to Step 2.