Genetic Algorithms Homework



This assignment is out of 50 points, and is worth 5 percent of your grade.

Write a genetic algorithm that follows the standard cycle as described in the lecture notes in language of your choice that works on linux.gl (C, C++, java, python, perl, lisp, etc). The only requirements are that your genetic algorithm maintains a population of 200 at all times and your fitness function takes at most O(N^2) to compute, where N is the length of a string. The cycle is:
  1. Initialize random population - this generation is #0
  2. Evaluate population
  3. Select survivors (with a selection algorithm of your choice)
  4. Repopulate with crossover and mutation (with methods of your choice)
  5. Check to see if the word is correct; if so exit; otherwise go to step 2

Turn in a document that states how your genetic algorithm works, by explaining the main components. Be sure to at least answer the following questions in your writeup:

The goal of your genetic algorithm is to guess a word of length up to 50 characters. The only characters will be A-Z capital letters and a-z lower case letters (case sensitive). Some examples: DonMiner, AbCdEaBcDe, IAmBatman, A, AB...

It is suggested you print out statistical information about each generation as it is generated.

Your program must take exactly one command line argument: the string to match. For example: $ ./myprogram DONMINER. Once the string is found, print out the amount of generations it took to get there.

Your algorithm must not cheat by looking at the goal string. The only functions that should know the secret string are the termination check and the fitness function. However, you may use the length of the string wherever you wish (i.e., you may initialize your population so that all of them have the same length as the goal string).

Here is some sample output from my implementation.

For extra credit, your genetic algorithm will be pitted in a competition to find solutions the fastest (fewest generations). The fastest genetic algorithm will receive 10 points extra credit, with several runner ups earning less than 10. If you do not follow instructions (use a population of a different size than 200, fitness function takes more than O(N^2) time, etc.) you will be disqualified from possible extra credit. Also, if you "cheat" (e.g., lie about number of generations, use the string incorrectly) you will be disqualified.

For an additional 4 points of extra credit, implement your genetic algorithm in LISP.