|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectec.gp.GPNode
ec.gp.ERC
ec.app.sequence.func.IntegerTerminal
public class IntegerTerminal
This is an Integer based ERC, for generating Positions. It will generate Uniform Random Integers between maxPosition and minPosition. If maxPosition = 140, minPosition =0, it will generate Positional Features. If maxPosition = 140, minPosition = 60, it will generate only in a downstream of [-60,+80] sequence, simillarly if maxPosition =60, minPosition =0, it will generate in upstream.
Field Summary |
---|
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, SITUATION_MUTATION, SITUATION_NEWIND |
Constructor Summary | |
---|---|
IntegerTerminal()
|
Method Summary | |
---|---|
void |
checkConstraints(ec.EvolutionState state,
int tree,
ec.gp.GPIndividual typicalIndividual,
ec.util.Parameter individualBase)
Usually ERCs don't have children, and this default implementation makes certain of it. |
boolean |
decode(ec.util.DecodeReturn dret)
Decodes data into the ERC from dret. |
java.lang.String |
encode()
Encodes data from the ERC, using ec.util.Code. |
void |
eval(ec.EvolutionState state,
int thread,
ec.gp.GPData input,
ec.gp.ADFStack stack,
ec.gp.GPIndividual individual,
ec.Problem problem)
Evaluates the node with the given thread, state, individual, problem, and stack. |
int |
getRandom(ec.EvolutionState state,
int thread)
|
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. |
boolean |
nodeEquals(ec.gp.GPNode node)
Implement this to do ERC-to-ERC comparisons. |
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. |
void |
readNode(ec.EvolutionState state,
java.io.DataInput dataInput)
To successfully read from a DataOutput, you must override this to read your specific ERC data in. |
void |
resetNode(ec.EvolutionState state,
int thread)
Remember to override this to randomize your ERC after it has been cloned. |
void |
setup(ec.EvolutionState state,
ec.util.Parameter base)
Sets up a prototypical GPNode with those features all nodes of that prototype share, and nothing more. |
java.lang.String |
toString()
This defaults to simply name() + "[" + encode() + "]". |
void |
writeNode(ec.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 ec.gp.ERC |
---|
mutateERC, readNode, toStringForHumans |
Methods inherited from class ec.gp.GPNode |
---|
atDepth, clone, cloneReplacing, cloneReplacing, cloneReplacing, cloneReplacingAtomic, cloneReplacingAtomic, cloneReplacingNoSubclone, constraints, contains, defaultBase, depth, errorInfo, lightClone, makeCTree, makeGraphvizTree, makeLatexTree, makeLispTree, nodeEquivalentTo, nodeInPosition, numNodes, numNodes, parentType, pathLength, printNode, printNode, printNode, printNodeForHumans, printNodeForHumans, printRootedTree, printRootedTree, printRootedTree, printRootedTreeForHumans, printRootedTreeForHumans, readRootedTree, readRootedTree, replaceWith, rootedTreeEquals, rootedTreeHashCode, rootParent, swapCompatibleWith, toStringForError, writeRootedTree |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public IntegerTerminal()
Method Detail |
---|
public void resetNode(ec.EvolutionState state, int thread)
ec.gp.ERC
resetNode
in class ec.gp.ERC
public void setup(ec.EvolutionState state, ec.util.Parameter base)
ec.gp.GPNode
setup
in interface ec.Prototype
setup
in interface ec.Setup
setup
in class ec.gp.GPNode
public java.lang.String name()
ec.gp.ERC
name
in class ec.gp.ERC
public java.lang.String toString()
ec.gp.ERC
toString
in class ec.gp.ERC
public int nodeHashCode()
ec.gp.ERC
nodeHashCode
in class ec.gp.ERC
public boolean nodeEquals(ec.gp.GPNode node)
ec.gp.ERC
nodeEquals
in class ec.gp.ERC
public void readNode(ec.EvolutionState state, java.io.DataInput dataInput) throws java.io.IOException
ec.gp.ERC
readNode
in class ec.gp.ERC
java.io.IOException
public void writeNode(ec.EvolutionState state, java.io.DataOutput dataOutput) throws java.io.IOException
ec.gp.ERC
writeNode
in class ec.gp.ERC
java.io.IOException
public java.lang.String encode()
ec.gp.ERC
encode
in class ec.gp.ERC
public boolean decode(ec.util.DecodeReturn dret)
ec.gp.ERC
decode
in class ec.gp.ERC
public void checkConstraints(ec.EvolutionState state, int tree, ec.gp.GPIndividual typicalIndividual, ec.util.Parameter individualBase)
ec.gp.ERC
checkConstraints
in class ec.gp.ERC
public void eval(ec.EvolutionState state, int thread, ec.gp.GPData input, ec.gp.ADFStack stack, ec.gp.GPIndividual individual, ec.Problem problem)
ec.gp.GPNode
About input: input is special; it is how data is passed between parent and child nodes. If children "receive" data from their parent node when it evaluates them, they should receive this data stored in input. If (more likely) the parent "receives" results from its children, it should pass them an input object, which they'll fill out, then it should check this object for the returned value.
A tree is typically evaluated by dropping a GPData into the root. When the root returns, the resultant input should hold the return value.
In general, you should not be creating new GPDatas. If you think about it, in most conditions (excepting ADFs and ADMs) you can use and reuse input for most communications purposes between parents and children.
So, let's say that your GPNode function implements the boolean AND function,
and expects its children to return return boolean values (as it does itself).
You've implemented your GPData subclass to be, uh, BooleanData, which
looks like
public class BooleanData extends GPData
{
public boolean result;
public GPData copyTo(GPData gpd)
{
((BooleanData)gpd).result = result;
}
}
...so, you might implement your eval(...) function as follows:
public void eval(final EvolutionState state,
final int thread,
final GPData input,
final ADFStack stack,
final GPIndividual individual,
final Problem problem
{
BooleanData dat = (BooleanData)input;
boolean x;
// evaluate the first child
children[0].eval(state,thread,input,stack,individual,problem);
// store away its result
x = dat.result;
// evaluate the second child
children[1].eval(state,thread,input,stack,individual,problem);
// return (in input) the result of the two ANDed
dat.result = dat.result && x;
return;
}
eval
in class ec.gp.GPNode
public int getRandom(ec.EvolutionState state, int thread)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |