Genetic Algorithm Library
From CSWiki
Full name: Simple Genetic Algorithm Package
Brief description: A small, easy-to-use, generic genetic algorithm library written in Java.
Ownership: Open source, written by Russ Abbott
Point(s) of contact: Russ Abbott
Download: "Simple Genetic Algorithm Library" (zip) (upload page)
Contents |
[edit] Model description
A small class library that allows developers to specify a fitness function against which to evolve parameters. The parameters may be int, double, or boolean.
[edit] Applications
Genetic algorithms are typically used to find optima in very large search spaces.
[edit] Implementation details
The following are the primary classes and interfaces.
[edit] class GA;
/** This class stores the population and implements the genetic algorithm. The size of the population, the frequency with which each genetic operator is used, and other parameters are up to the user. /* /** The population is an array of PopElt objects. */ public final PopElt[ ] population; /** The PEfactory is a factory for PopElt objects. This allows the user to generate population elements, which must be a subclass of PopElt */ public final PopEltFactory PEfactory; /** Return the best population element found so far. */ public PopElt getBest() /** Uses a genetic operator to generate a new population element. 1. Generate two parents 2. Select a GeneticOperator. 3. Call the perform() method in that operator, passing the two parents. 4. Select an element in the population for replacement. 5. Store the new element where the replaced element had been. */ public PopElt newChildElt() /** The package uses a steady state rather than a generational model. Generates as many new population elements as the size of the population array. */ public void runAGeneration()
[edit] interface PopEltFactory
/** The class that implements this interface stores meta-information about PopElt's. In particular it should know what the ranges of the possible values are and whether they should be treated as <b>double</b> or <b>long</b>. */ /** Generate a new population element. The genetic variables, (often called "genes") are stored in the values array. Ensure that the fitness value of the generated element is computed and stored in the PopElt. */ public PopElt newPopElement(long id, double[ ] values, Object pedigree);
[edit] interface PopElt
/** The genetic variables are stored as an array of doubles. Return the array of genetic variables. This gives the genetic operators access to the genetic variables. */ public double[ ] getValues(); /** Should the argument be considered genetically identical to this PopElt? */ public boolean isGeneticallyIdenticalTo(PopElement elt); /** Is this PopElt more fit than the argument? This allows the package not to commit to whether a higher fitness value is better or worse. */ public boolean isMoreFitThan(PopElement elt);
[edit] abstract class GeneticOperator
/** Allows users to write their own genetic operators. Only one method is required. */ /** Generate a child population element from the given parents. */ public abstract PopElt perform(PopElt e1, PopElt e2);
Genetic operators for crossover, mutation, and the generation of a random element are included in the package.

