|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ec.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. |
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. |
Methods inherited from class java.lang.Object |
clone,
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)
public abstract void resetNode(EvolutionState state, int thread)
public abstract boolean nodeEquals(GPNode node)
public abstract int nodeHashCode()
public java.lang.String toStringForHumans()
public java.lang.String toString()
public abstract java.lang.String encode()
public abstract boolean decode(DecodeReturn dret)
public void mutateERC(EvolutionState state, int thread)
public GPNode readNode(DecodeReturn dret) throws java.lang.CloneNotSupportedException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |