|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectec.gp.GPNode
ec.gp.ERC
ERC is an abstract GPNode which implements Ephemeral Random Constants, as described in Koza I. An ERC is a node which, when first instantiated, gets set to some random constant value which it always returns from then on, even after being crossed over into other individuals. In order to implement an ERC, you need to override several methods below.
Remember that if your ERC value isn't a simple or mutable type (like an int or a string), you'll have to deep-clone it in an overridden protoClone() method.
Field Summary | |
static java.lang.String |
ERC_PREFIX
|
Fields inherited from class ec.gp.GPNode |
argposition, children, constraints, GPNODEPRINTTAB, MAXPRINTBYTES, NODESEARCH_ALL, NODESEARCH_CUSTOM, NODESEARCH_NONTERMINALS, NODESEARCH_TERMINALS, P_NODE, P_NODECONSTRAINTS, parent, REPLACEMENT_CHAR, SITUATION_MUTATION, SITUATION_NEWIND |
Constructor Summary | |
ERC()
|
Method Summary | |
void |
checkConstraints(EvolutionState state,
int tree,
GPIndividual typicalIndividual,
Parameter individualBase)
Checks to make certain that the ERC has no children. |
abstract boolean |
decode(DecodeReturn dret)
Decodes data into the ERC from dret. |
abstract java.lang.String |
encode()
Encodes data from the ERC, using ec.util.Code. |
void |
mutateERC(EvolutionState state,
int thread)
Mutates the node's "value". |
abstract java.lang.String |
name()
Returns the lowercase "name" of this ERC function class, some simple, short name which distinguishes this class from other ERC function classes you're using. |
abstract boolean |
nodeEquals(GPNode node)
Implement this to do ERC-to-ERC comparisons. |
abstract int |
nodeHashCode()
Implement this to hash ERCs, along with other nodes, in such a way that two "equal" ERCs will usually hash to the same value. |
GPNode |
readNode(DecodeReturn dret)
Reads the node symbol, advancing the DecodeReturn to the first character in the string beyond the node symbol, and returns a new, empty GPNode of the appropriate class representing that symbol, else null if the node symbol is not of the correct type for your GPNode class. |
void |
readNode(EvolutionState state,
java.io.DataInput dataInput)
To successfully read from a DataOutput, you must override this to read your specific ERC data in. |
abstract void |
resetNode(EvolutionState state,
int thread)
Remember to override this to randomize your ERC after it has been cloned. |
java.lang.String |
toString()
This defaults to simply ERC_PREFIX + name() + "[" + encode() + "]" |
java.lang.String |
toStringForHumans()
You might want to override this to return a special human-readable version of the erc value; otherwise this defaults to toString(); This should be something that resembles a LISP atom. |
void |
writeNode(EvolutionState state,
java.io.DataOutput dataOutput)
To successfully write to a DataOutput, you must override this to write your specific ERC data out. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String ERC_PREFIX
Constructor Detail |
public ERC()
Method Detail |
public abstract java.lang.String name()
public void checkConstraints(EvolutionState state, int tree, GPIndividual typicalIndividual, Parameter individualBase)
checkConstraints
in class GPNode
public abstract void resetNode(EvolutionState state, int thread)
resetNode
in class GPNode
public abstract boolean nodeEquals(GPNode node)
nodeEquals
in class GPNode
public abstract int nodeHashCode()
nodeHashCode
in class GPNode
public java.lang.String toStringForHumans()
toStringForHumans
in class GPNode
public java.lang.String toString()
toString
in class GPNode
public abstract java.lang.String encode()
public abstract boolean decode(DecodeReturn dret)
public void mutateERC(EvolutionState state, int thread)
public void writeNode(EvolutionState state, java.io.DataOutput dataOutput) throws java.io.IOException
writeNode
in class GPNode
java.io.IOException
public void readNode(EvolutionState state, java.io.DataInput dataInput) throws java.io.IOException
readNode
in class GPNode
java.io.IOException
public GPNode readNode(DecodeReturn dret)
GPNode
readNode
in class GPNode
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |