Documentation for package rsm.genetic-alg


Author : R. Scott McIntire

Version: 1.0

Overview:

A gene pool is a list of genes. 
 Each gene is made up of characters from a vector of letters. 
 Succeeding generations are formed by choosing pairs of genes randomly;
 splicing them randomly; and then possibly mutating them. 
 Although the choice of pairs is random, it is not uniformly random; 
 pairs which are more "fit" are selected more frequently.
 Fitness is determined by a fitness function that is supplied by the user.
 The value of any fitness function should be >= the value *base-fitness-value*
 defined below.
 The two primary macros/functions used are <defgenetic> and
 <solve-all-genetic-problems>. The first (defgenetic) defines genetic problems 
 for genetic programming while the second solves them.

REQUIRES: package rsm.cache


Export Summary:

genetic: The name of the structure that stores
         the genetic information necessary to 
         run a simulation.
   
    ACCESS FUNCTIONS TO STRUCTURE GENETIC (named below as G).
   
g-name            : G name (string).
g-mutation-rate   : G mutation rate (fixnum).
g-fitness-function: G fitness function(compiled function).
g-alphabet        : G alphabet (vector).
g-pool            : G initial gene pool (list of genes).
   
         BEGIN PRIMARY EXPORTS

defgenetic: Macro to define a genetic problem.
   
solve-all-genetic-problems: Solve all registered problems.
solve-genetic-problems    : Solve genetic problems in a name list.
solve-genetic-problem     : Solve a named genetic problem.
   
clear-genetic-problems    : Clear the registry of genetic problems.
   
display-solutions         : Display the solutions.
display-solution          : Display a solution.

         END PRIMARY EXPORTS
   
ga-sim: Simulate the evolution of a gene pool.

clear-genetic-problems ()

Clear out the genetic problem definitions introduced by defgenetic.

defgenetic   (name &key mutation-rate fitness-function alphabet pool)

Define a genetic problem (store it by its name in a hash.)

display-solution   (solution)

Display a solution.

display-solutions   (solutions)

Display the solutions.

g-alphabet   (struct)

nil

g-fitness-function   (struct)

nil

g-mutation-rate   (struct)

nil

g-name   (struct)

nil

g-pool   (struct)

nil

ga-sim   (n gene-pool fitness-function mutation-rate gene-alphabet &key (gene-length-constant? t) (print-pools? nil) (print-intermediate? nil) (k 1))

Run a genetic algorithm simulation <n> times with initial gene pool
<gene-pool> which is a list of genes (each gene is a list from
alphabet <fitness-function> which
determines the fitness of a given gene (fitness values produced should be 
greater than *base-fitness-value*; a mutation rate
<mutation-rate> which determines the rate at which gene mutation
occurs; <gene-length-constant?> which determines if the length of a
gene is constant; and, <print-intermediate?> which determines whether
to print intermediate gene pools. If <print-pools?> is nil, no
generations are printed regardless of the value of <print-intermediate?>. 
Store the best k solutions in a cache.

solve-all-genetic-problems   (n &key (gene-length-constant? t) (print-pools? nil) (print-intermediate? nil) (mutation-rate nil) (k 1))

Solve the list of genetic problems introduced by defgenetic.
Run the simulation <n> times. Return the best <k> solutions for
each problem. If <k> is a vector or list, then the ith value of <k>
is used with the ith value of the genetic problem 
(ordered alphabetically by name). The same is true of <n> and the 
genetic problems. See ga-sim for an explanation of the keyword parameters.

solve-genetic-problem   (n g-name &key (gene-length-constant? t) (print-pools? nil) (print-intermediate? nil) (mutation-rate nil) (k 1))

Solve a genetic problem defined by structure genetic named by <g-name>.
Return the <k> best solutions. See ga-sim for an explanation of the 
keyword parameters.

solve-genetic-problems   (n names &key (gene-length-constant? t) (print-pools? nil) (print-intermediate? nil) (mutation-rate nil) (k 1))

Solve the list of genetic problems introduced by defgenetic named by <names>.
Run the simulation <n> times. Return the best <k> solutions for
each problem. If <k> is a vector or list, then the ith value of <k>
is used with the ith value of the genetic problem 
(ordered alphabetically by name). The same is true of <n> and the 
genetic problems. See ga-sim for an explanation of the keyword parameters.