Class VladERCA
- java.lang.Object
-
- ec.gp.GPNode
-
- ec.gp.ERC
-
- ec.app.regression.func.RegERC
-
- ec.app.regression.func.VladERCA
-
- All Implemented Interfaces:
- GPNodeParent, Prototype, Setup, java.io.Serializable, java.lang.Cloneable
public class VladERCA extends RegERC
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class ec.gp.GPNode
argposition, children, CHILDREN_UNKNOWN, constraints, GPNODEPRINTTAB, MAXPRINTBYTES, NODESEARCH_ALL, NODESEARCH_NONTERMINALS, NODESEARCH_TERMINALS, P_NODE, P_NODECONSTRAINTS, parent
-
-
Constructor Summary
Constructors Constructor and Description VladERCA()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voideval(EvolutionState state, int thread, GPData input, ADFStack stack, GPIndividual individual, Problem problem)Evaluates the node with the given thread, state, individual, problem, and stack.intexpectedChildren()Usually ERCs don't have children, and this default implementation makes certain of it.java.lang.Stringname()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.voidresetNode(EvolutionState state, int thread)Remember to override this to randomize your ERC after it has been cloned.java.lang.StringtoStringForHumans()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 ec.app.regression.func.RegERC
decode, encode, nodeEquals, nodeHashCode, readNode, writeNode
-
Methods inherited from class ec.gp.GPNode
atDepth, checkConstraints, clone, cloneReplacing, cloneReplacing, cloneReplacing, cloneReplacingAtomic, cloneReplacingAtomic, cloneReplacingNoSubclone, constraints, contains, defaultBase, depth, errorInfo, iterator, iterator, iterator, lightClone, makeCTree, makeGraphvizTree, makeLatexTree, makeLispTree, makeLispTree, nodeEquivalentTo, nodeInPosition, nodeInPosition, numNodes, numNodes, parentType, pathLength, printNode, printNode, printNode, printNodeForHumans, printNodeForHumans, printRootedTree, printRootedTree, printRootedTree, printRootedTreeForHumans, printRootedTreeForHumans, readRootedTree, readRootedTree, replaceWith, rootedTreeEquals, rootedTreeHashCode, rootParent, setup, swapCompatibleWith, toStringForError, writeRootedTree
-
-
-
-
Method Detail
-
name
public java.lang.String name()
Description copied from class:ERCReturns the lowercase "name" of this ERC function class, some simple, short name which distinguishes this class from other ERC function classes you're using. If you have more than one ERC function, you need to distinguish them here. By default the value is "ERC", which works fine for a single ERC function in the function set. Whatever the name is, it should generally only have letters, numbers, or hyphens or underscores in it. No whitespace or other characters.
-
expectedChildren
public int expectedChildren()
Description copied from class:ERCUsually ERCs don't have children, and this default implementation makes certain of it. But if you want to override this, you're welcome to.- Overrides:
expectedChildrenin classERC
-
resetNode
public void resetNode(EvolutionState state, int thread)
Description copied from class:ERCRemember to override this to randomize your ERC after it has been cloned. The prototype will not ever receive this method call.
-
toStringForHumans
public java.lang.String toStringForHumans()
Description copied from class:ERCYou 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. If a simple number or other object won't suffice, you might use something that begins with name() + [ + ... + ]- Overrides:
toStringForHumansin classRegERC
-
eval
public void eval(EvolutionState state, int thread, GPData input, ADFStack stack, GPIndividual individual, Problem problem)
Description copied from class:GPNodeEvaluates the node with the given thread, state, individual, problem, and stack. Your random number generator will be state.random[thread]. The node should, as appropriate, evaluate child nodes with these same items passed to eval(...).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; }
-
-
DMelt 3.0 © DataMelt by jWork.ORG