.
Unlike the original GEP, a prefix-based grammar should be used for efficiency and ease of
processing, although it is not mandated.
- Author:
- juber patel
Constructor Summary |
GeneGrammar(List<Character> terminals,
Character linkingFunction)
|
Method Summary |
abstract String |
decode(Gene gene)
explain the given gene in a human readable form |
double |
evaluate(Gene[] genes,
List<FitnessCase<T>> fitnessCases)
evaluate the gene array and put a value on it. |
List<Character> |
getAlphabet()
|
Character |
getLinkingFunction()
|
abstract int |
getMaximumArity()
get the maximum arity among the operators of this grammar |
abstract List<Character> |
getOperators()
return the operators that are valid for this grammar |
List<Character> |
getTerminals()
|
boolean |
isOperator(Character symbol)
|
boolean |
isTerminal(Character symbol)
|
protected abstract T |
link(List<T> geneValues)
Link the separate gene values in the Individual and assign a representative value to them. |
protected abstract GEPRootNode<T> |
parse(String sequence)
parse the given sequence and return the root of the AST. |
protected abstract double |
percentError(T calculated,
T expected)
compare the Individual's value for a fitness case to the expected value of the fitness case
and express the difference as (positive double) percent error in estimation. |
List<T> |
useOn(Gene[] genes,
List<FitnessCase<T>> fitnessCases)
|
Methods inherited from class Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GeneGrammar
public GeneGrammar(List<Character> terminals,
Character linkingFunction)
- Parameters:
terminals
- the valid termianls for this grammarlinkingFunction
- the function that links the genes
getTerminals
public List<Character> getTerminals()
getAlphabet
public List<Character> getAlphabet()
isTerminal
public boolean isTerminal(Character symbol)
isOperator
public boolean isOperator(Character symbol)
getLinkingFunction
public Character getLinkingFunction()
useOn
public List<T> useOn(Gene[] genes,
List<FitnessCase<T>> fitnessCases)
throws AmibaException
- Throws:
AmibaException
evaluate
public double evaluate(Gene[] genes,
List<FitnessCase<T>> fitnessCases)
throws AmibaException
- evaluate the gene array and put a value on it. The higher the value, the better the fitness
- Parameters:
genes
-
- Returns:
- a number that represents the fitness of the given gene array
- Throws:
AmibaException
parse
protected abstract GEPRootNode<T> parse(String sequence)
throws AmibaException
- parse the given sequence and return the root of the AST.
To be implemented using JavaCC. This is the entry point into the grammar specification
- Parameters:
sequence
-
- Returns:
-
- Throws:
AmibaException
decode
public abstract String decode(Gene gene)
- explain the given gene in a human readable form
- Parameters:
gene
-
- Returns:
getOperators
public abstract List<Character> getOperators()
- return the operators that are valid for this grammar
getMaximumArity
public abstract int getMaximumArity()
- get the maximum arity among the operators of this grammar
- Returns:
percentError
protected abstract double percentError(T calculated,
T expected)
- compare the Individual's value for a fitness case to the expected value of the fitness case
and express the difference as (positive double) percent error in estimation. This number will
be used as a measure of error in the Individual
The calculated value should be compared with the expected value and a measure of the
difference should be returned. The returned value will generally be percent error. The higher
the returned value, the higher the error.
- Returns:
- a value indicating percent error
link
protected abstract T link(List<T> geneValues)
- Link the separate gene values in the Individual and assign a representative value to them.
The implementation should make collective sense of gene values so as to assign a value to the
Individual.
- Parameters:
geneValues
-
- Returns: