Preview lessons, content and tests

Computer Science & Programming solved. All in one platform.

1. To trial the platform and take tests, please take a few seconds to SIGN UP and SET UP FREE.

2. Searching for something specific? See our text overview of all tests. Scroll right for levels, and lists.

3. Student and Teacher User Guides |  Schemes of Work |   Real Teacher use Videos |


Join 36000+ teachers and students using TTIO.

Fitness Functions

A Fitness Score is given to each individual which shows the ability of an individual to “compete”. The individual having an optimal fitness score (or near optimal) are sought after or  A Fitness score is the number of characters which differ from the characters in the target string at a particular index. An individual which has a lower fitness value is given preference.

The GAs maintains the population of n individuals (chromosome/solutions) along with their fitness scores.

Suggested Video

Video tutorial showing adding a GA (space invaders)

The algorithm (notice point 2)

The whole algorithm can be summarized as –

1) Randomly initialize populations p
2) Determine fitness of population
3) Untill convergence repeat:
        >>  a) Select parents from population
        >>  b) Crossover and generate new population
        >>  c) Perform mutation on new population
        >>  d) Calculate fitness for new population

The individuals having better fitness scores are given more chance to reproduce than others. The individuals with better fitness scores are selected who mate and produce better offspring by combining chromosomes of parents. The population size is static so the room has to be created for new arrivals. So, some individuals die and get replaced by new arrivals eventually creating new generation when all the mating opportunity of the old population is exhausted. It is hoped that over successive generations better solutions will arrive while least fit die.

Source: https://www.geeksforgeeks.org/genetic-algorithms/

www.teachyourselfpython.com