CIS 479 Assignment 5
Summer 2020

In this assignment, you will implement a simple genetic algorithm in the language of your choice with fitness-proportionate selection (roulette-wheel sampling), population size 50, single-point crossover rate pc = 0.7, and bitwise mutation rate pm = 0.001. Try it on the following fitness function: f(x) = number of ones in x, where x is a genome of length 10. Perform 30 runs and measure the average generation at which the string of all ones is discovered. Perform the same experiment with crossover turned off (pc = 0). If it turns out that mutation with crossover is better than mutation alone, why? You may work with a partner and turn in a joint write-up – please be sure the name and contribution of each lab partner is described in final report.

Your solution should include the following functions or procedures and then use them as building blocks in your main GA program. Feel free to write any other helper functions that you like.

Your GA program should print out the fitness of the best individual in the current population and the average fitness of the population as a whole. A run terminates if you find a string of ten ones “1111111111”. Here is an example of the kind of output your program should produce:

>>> runGA(50, 0.7, 0.001)

Population size: 50

Genome length: 10

Generation    0: average fitness 5.07, best fitness 5.00

Generation    1: average fitness 5.91, best fitness 5.00

Generation    2: average fitness 5.45, best fitness 6.00

Generation    3: average fitness 6.02, best fitness 6.00

...

Generation   18: average fitness 8.09, best fitness 9.00

Generation   19: average fitness 8.38, best fitness 10.00

You will need to turn in an annotated file listing of your source code, report, and test run results. Your write-up for this project should follow the experiment write-up template and include relevant data displays (tables and/or graphs) in the results section. Your discussion to discuss the output and observations from you graphs/tables. Your conclusions should include things that went right, things that went wrong, and lessons learned. Your work is due on Monday, June 12th.

 

Assigned: 6/03/20
Date due: 6/12/20