Documentation

This page is simply a web version of the README file found in the repository.

What Is sga?

sga is a program that demonstrates a standard genetic algorithm with some
simple fitness functions. Its features include:

o Fixed-length binary strings.
o Static population size (all generations equal size).
o Standard proportionate reproduction.
o Optional one-point crossover and/or mutation (bit-flipping).
o Choice of fitness function:
1 constant (all fitnesses the same),
2 random (fitness() returns a random value),
3 onemax (maximise the number of ones),
4 diffmax (maximise the difference between number of ones and zeros),
5 integer (fitness equals integer equivalent of bitstring).
o Statistics: best, worst, mean, standard deviation per generation.
o A one-line summary of the number of ones in each locus is shown below
each displayed generation. A '-' means all ones or no ones, and a digit
represents the percentage of ones: 0=less than 10%, 1=10%+, 2=20%+ etc.

Command line options

each option takes a non-negative integer as an argument,
the default value for each option is shown):
-p 300 popsize (must be even, not 0 and not greater than 1000)
-c 16 chromsize (length of bitstring, not 0 and not greater than 80)
-x 70 crossover probability (0 = no crossover)
-m 1000 mutation rate (0 = no mutation, 500 = 1 in 500 bits mutated)
-f 1 fitness function (1 = constant, 2 = random, ... , 5 = integer)
-b 1 fitness boost (e.g. 2 = double the fitness of each individual)
-r 1 random seed (not 0)
-g 1000 number of generations (0 = run indefinitely)
-s 10 number of individuals to show in one generation (not > popsize)
-d 1 frequency of display (not 0, 8 = display every 8th generation)
-h displays help and exits
-v displays the version and exits

Examples:

sga defaults as above
sga -p500 popsize = 500
sga -c31 -x0 -m500 chromsize = 31, no crossover, 1 in 500 bits mutated
sga -s33 -d2 display 33 individuals from every other generation

Installing, compiling, linking and running sga

Install the source code and makefile in a directory, ensure that you have
already installed both the gcc compiler and gsl development libraries,
and type 'make'. The program should now run if you type './sga'