Class GeneticParameters

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--GeneticParameters

public class GeneticParameters
extends java.lang.ClassLoader

Contains parameters affecting mating and simulation. These can be edited using an associated GUI panel. This class also contains helper functions for generating new expressions and subexpressions.


Inner classes inherited from class java.lang.ClassLoader
java.lang.ClassLoader.NativeLibrary
 
Field Summary
(package private)  double baseMutationProbability
          Probability of a mutatation before accounting for parental complexity.
(package private)  double callFrequency
           
(package private)  double callProbability
           
static int CHANGE_OPERATOR_MUTATION
           
static int CLONE_SIBLING_MUTATION
           
(package private)  double crossoverProbability
          The probability that any mating will be crossover (vs a tree walk).
static int ENCLOSE_IN_NEW_CALL_MUTATION
           
(package private) static MutationDescription[] mutationDescription
          Descriptions and details about each kind of mutation.
static int NEW_EXPRESSION_MUTATION
           
(package private) static int NUM_MUTATIONS
           
(package private)  OperatorDescription[] operatorDescription
           
(package private)  java.util.HashMap operatorsByName
          A hash table mapping operator names (as strings) to ELOperators to allow fast parsing of expressions.
static int SCALAR_CONSTANT_MUTATION
           
(package private)  double scalarDisturbance
          Maximum change in a scalar due to mutation.
(package private)  double scalarFrequency
           
(package private)  double scalarProbability
           
static int SIMPLIFY_MUTATION
           
static int VECTOR_CONSTANT_MUTATION
           
(package private)  double vectorDisturbance
          Maximum change in a vector's individual components due to mutation.
(package private)  double vectorFrequency
           
(package private)  double vectorProbability
           
 
Fields inherited from class java.lang.ClassLoader
nocerts
 
Constructor Summary
GeneticParameters(java.lang.String operatorPath)
           
 
Method Summary
(package private)  void computeProbabilities()
          Computes the normalized mutation and operator probabilities.
 ELExpression createGeneticMorphExpression(ELExpression a, ELExpression b)
          Creates a new expression containing ELMorphInterpolators that will interpolate between two expressions.
protected  java.lang.Class findClass(java.lang.String name)
           
 ELExpression mate(ELExpression a, ELExpression b)
          Genetically mates two expressions and produces a single offspring.
 boolean mutationOccurs(ELCall parent)
          Randomly chooses whether a mutation will occur based on the length of the parent expression and the base mutation probability and returns true if a mutation will occur.
 ELExpression parseELExpression(java.lang.String exprString)
          Parses a string of EL code.
 ELCall randomCall()
           
 ELCall randomCallWithOperator(ELExpression expression)
          Generates a random call of at least one argument, using expression as the first argument.
 ELExpression randomExpression()
          Generates a new random expression of any type.
 int randomMutationType()
          Chooses a random type of expression mutation based on the probabilities provided.
 ELOperator randomOperator()
          Generates a random operator based the normalized operator probabilities.
 java.lang.String unparseELExpression(ELExpression e)
           
 
Methods inherited from class java.lang.ClassLoader
, addClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findNative, findResource, findResources, findSystemClass, getBootstrapClassPath, getCallerClassLoader, getGetClassLoaderPerm, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, isAncestor, loadClass, loadClass, loadLibrary, resolveClass, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHANGE_OPERATOR_MUTATION

public static final int CHANGE_OPERATOR_MUTATION

ENCLOSE_IN_NEW_CALL_MUTATION

public static final int ENCLOSE_IN_NEW_CALL_MUTATION

NEW_EXPRESSION_MUTATION

public static final int NEW_EXPRESSION_MUTATION

SIMPLIFY_MUTATION

public static final int SIMPLIFY_MUTATION

CLONE_SIBLING_MUTATION

public static final int CLONE_SIBLING_MUTATION

SCALAR_CONSTANT_MUTATION

public static final int SCALAR_CONSTANT_MUTATION

VECTOR_CONSTANT_MUTATION

public static final int VECTOR_CONSTANT_MUTATION

NUM_MUTATIONS

static final int NUM_MUTATIONS

mutationDescription

static MutationDescription[] mutationDescription
Descriptions and details about each kind of mutation. The order of the values in this array must match the mutation constants.

scalarDisturbance

double scalarDisturbance
Maximum change in a scalar due to mutation.

vectorDisturbance

double vectorDisturbance
Maximum change in a vector's individual components due to mutation.

baseMutationProbability

double baseMutationProbability
Probability of a mutatation before accounting for parental complexity.

operatorDescription

OperatorDescription[] operatorDescription

operatorsByName

java.util.HashMap operatorsByName
A hash table mapping operator names (as strings) to ELOperators to allow fast parsing of expressions.

crossoverProbability

double crossoverProbability
The probability that any mating will be crossover (vs a tree walk). The probability of a tree walk is 1 - crossoverProbability.

scalarFrequency

double scalarFrequency

vectorFrequency

double vectorFrequency

callFrequency

double callFrequency

callProbability

double callProbability

scalarProbability

double scalarProbability

vectorProbability

double vectorProbability
Constructor Detail

GeneticParameters

public GeneticParameters(java.lang.String operatorPath)
Parameters:
operatorPath - a path that can be searched for .class files implementing ELOperator.
Method Detail

computeProbabilities

void computeProbabilities()
Computes the normalized mutation and operator probabilities. Call this whenever frequencies change.

randomOperator

public ELOperator randomOperator()
Generates a random operator based the normalized operator probabilities.

randomExpression

public ELExpression randomExpression()
Generates a new random expression of any type.

randomCall

public ELCall randomCall()

randomCallWithOperator

public ELCall randomCallWithOperator(ELExpression expression)
Generates a random call of at least one argument, using expression as the first argument.

mate

public ELExpression mate(ELExpression a,
                         ELExpression b)
Genetically mates two expressions and produces a single offspring. The type of reproduction that occurs is determined probabilistically by the crossoverProbability. For a crossover mating, one parent is cloned, then a randomly chosen subexpression from the other parent is cloned and substituted at a random location.

createGeneticMorphExpression

public ELExpression createGeneticMorphExpression(ELExpression a,
                                                 ELExpression b)
Creates a new expression containing ELMorphInterpolators that will interpolate between two expressions. The two expressions are completely cloned (excepting operators).

mutationOccurs

public boolean mutationOccurs(ELCall parent)
Randomly chooses whether a mutation will occur based on the length of the parent expression and the base mutation probability and returns true if a mutation will occur. This is used by ELExpression implementations in the geneticClone() method.
Parameters:
parent - The parent of the expression that may be mutated. The probability of mutation is not directly depenent on the expression itself.

randomMutationType

public int randomMutationType()
Chooses a random type of expression mutation based on the probabilities provided. The return value is one of the _MUTATION constants this class defines.

findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Overrides:
findClass in class java.lang.ClassLoader

unparseELExpression

public java.lang.String unparseELExpression(ELExpression e)

parseELExpression

public ELExpression parseELExpression(java.lang.String exprString)
Parses a string of EL code. This is used for unserializing ELExpressions. Will return the scalar 0 if anything goes wrong while parsing.