|
What Are Genetic Algorithms (GAs)?
The genetic algorithm (GA) is basically
a computer program which simulates evolution. Namely, a simulated
population of chromosomes is randomly created and allowed to reproduce
according to the laws of evolution with the hope that a very fit
individual chromosome will eventually result. These chromosomes
are actually (encrypted) candidate solutions to a problem, so when
a good chromosome evolves, a good solution to a problem has evolved.
How
Do GAs Work?
First you create a random population of chromosomes
and test the fitness of each one with a special fitness function.
For example, if you are trying to minimize the time required for
a signal to travel through a network, each chromosome would represent
a network configuration and the fitness function would determine
the fitness of that network configuration.
Although all the initial fitness values are probably very low (since
the algorithm randomly created them), some are still higher than
others. These chromosomes with higher fitness values are given a
correspondingly higher probability to reproduce in the next generation.
Thus for each generation in the evolution, a fitness function simulates
natural selection by pushing the population in the direction of
improved fitness (much like how natural selection nudges a biological
species toward improved fitness with regards to its environment).
Reproduction in our GA is diploid (sexual),
meaning that when two chromosomes are mated, pieces (genes) of each
are combined in the offspring. Thus chromosomes recombine their
parts at random (two point crossover) gene locations, occasionally
producing a fitter chromosomes. This improvement to the gene pool
is amplified by a corresponding increase in that fitter chromosome's
probability to reproduce.
GA
Class Libary
With our Object Pascal (Delphi) class library,
you have many options, you can model your chromosomes in three different
ways by subclassing one of the three main classes of GAs (each of
which is a subclass of my main GA class):
- Character strings
- Floating point numbers
- Sequences or lists (e.g., optimize network
nodes)
You can choose among the following GA parameters:
- chomosome size
- population size
- crossover probability
- random selection probability
- number of preliminary generations (to build
better breeding stock before main GA run)
- mutation probability
- number of decimal points (for floating point
number GAs)
- gene space (constrain the possible values
for genes)
- crossover type (OnePoint, TwoPoint, Uniform,
or Roulette)
Possible
Applications Using This Class Libary
- Get the fitness of a complex mathematical
equation using TGAFloat (or TGAString where each character in
the string is a digit in the solution)
- Sequence (order) a string using TGASequenceList
- To optimize a network for minimal transmission
time
- Genetic sequencing of proteins (to find
minimal energy to fold a protein into a certain shape)
- Compute the coeffients of the optimal polynomial
to fit a given set of data points (curve fitting)
- Find the maxima or minima to a complex equation
Download
The class
library source code
A sample
program using the class library. The sample program has examples
for curve fitting, traveling salesman, maxima of an equation, and
getting the maximum binary string problems.
Note: The class library
is copyrighted © 2000-2002 by Jeff S Smith and SoftTech Design,
Inc. It may be freely distributed for educational and non-profit
use only.
|