org.primordion.ealontro.ec.app.cartcentering
Class GT

java.lang.Object
  extended byorg.primordion.xholon.base.Xholon
      extended byorg.primordion.xholon.base.Activity
          extended byec.gp.GPNode
              extended byorg.primordion.ealontro.ec.app.cartcentering.GT
All Implemented Interfaces:
ec.gp.GPNodeParent, IActivity, IXholon

public class GT
extends ec.gp.GPNode


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, REPLACEMENT_CHAR, SITUATION_MUTATION, SITUATION_NEWIND
 
Fields inherited from class org.primordion.xholon.base.Xholon
DEFAULT_LEVEL, interaction, interactionsEnabled
 
Fields inherited from interface org.primordion.xholon.base.IXholon
DEFAULT_SIZE_MSG_Q, NINCLUDE_PSC, NINCLUDE_PSx, NINCLUDE_PxC, NINCLUDE_Pxx, NINCLUDE_xSC, NINCLUDE_xSx, NINCLUDE_xxC, NINCLUDE_xxx
 
Constructor Summary
GT()
           
 
Method Summary
 void checkConstraints(ec.EvolutionState state, int tree, ec.gp.GPIndividual typicalIndividual, ec.util.Parameter individualBase)
          You ought to override this method to check to make sure that the constraints are valid as best you can tell.
 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.
 java.lang.String toString()
          Returns a Lisp-like atom for the node which can be read in again by computer.
 
Methods inherited from class ec.gp.GPNode
atDepth, clone, cloneReplacing, cloneReplacing, cloneReplacing, cloneReplacingAtomic, cloneReplacingAtomic, cloneReplacingNoSubclone, constraints, contains, defaultBase, depth, errorInfo, getFirstChild, getName, getNextSibling, makeCTree, makeLatexTree, nodeEquals, nodeEquivalentTo, nodeHashCode, nodeInPosition, numNodes, numNodes, parentType, printNode, printNode, printNodeForHumans, printRootedTree, printRootedTree, printRootedTreeForHumans, readNode, readNode, readRootedTree, readRootedTree, replaceWith, resetNode, rootedTreeEquals, rootedTreeHashCode, rootParent, setup, swapCompatibleWith, toStringForError, toStringForHumans, writeNode, writeRootedTree, writeXml
 
Methods inherited from class org.primordion.xholon.base.Activity
clone
 
Methods inherited from class org.primordion.xholon.base.Xholon
act, appendChild, appendChild, appendChild, cleanup, configure, configure, createStructure, decVal, decVal, draw, getChildNodes, getFirstSibling, getId, getLastChild, getLastSibling, getNeighbors, getNextId, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, getPort, getPreviousSibling, getRoleName, getRootNode, getSiblings, getSizeMessageQ, getUid, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getVal, getXhc, getXhcId, getXhcName, getXhType, handleNodeSelection, hasAncestor, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, height, incVal, incVal, initialize, initStatics, inOrderPrint, insertAfter, insertBefore, insertFirstChild, isActiveObject, isBound, isContainer, isExternal, isInternal, isLeaf, isPassiveObject, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postConfigure, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, resetNextId, sendMessage, sendMessage, sendMessage, setAttributeVal, setFactory, setFirstChild, setId, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setPorts, setRoleName, setSizeMessageQ, setUid, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVariableValue, setXhc, swapNode, terminate, treeSize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.primordion.xholon.base.IXholon
act, appendChild, appendChild, appendChild, cleanup, configure, configure, createStructure, decVal, decVal, draw, getChildNodes, getFirstSibling, getId, getLastChild, getLastSibling, getNeighbors, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, getPort, getPreviousSibling, getRoleName, getRootNode, getSiblings, getUid, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getVal, getXhc, getXhcId, getXhcName, getXhType, handleNodeSelection, hasAncestor, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, height, incVal, incVal, initialize, initStatics, inOrderPrint, insertAfter, insertBefore, insertFirstChild, isActiveObject, isBound, isContainer, isExternal, isInternal, isLeaf, isPassiveObject, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postConfigure, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, sendMessage, sendMessage, sendMessage, setAttributeVal, setFirstChild, setId, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setPorts, setRoleName, setUid, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVariableValue, setXhc, swapNode, terminate, treeSize
 

Constructor Detail

GT

public GT()
Method Detail

toString

public java.lang.String toString()
Description copied from class: ec.gp.GPNode
Returns a Lisp-like atom for the node which can be read in again by computer. If you need to encode an integer or a float or whatever for some reason (perhaps if it's an ERC), you should use the ec.util.Code library.


checkConstraints

public void checkConstraints(ec.EvolutionState state,
                             int tree,
                             ec.gp.GPIndividual typicalIndividual,
                             ec.util.Parameter individualBase)
Description copied from class: ec.gp.GPNode
You ought to override this method to check to make sure that the constraints are valid as best you can tell. Things you might check for: You can't check for everything, of course, but you might try some obvious checks for blunders. The default version of this method is empty for now, but you should still call super.checkConstraints(state) just to be certain. The ultimate caller of this method must guarantee that he will eventually call state.output.exitIfErrors(), so you can freely use state.output.error instead of state.output.fatal(), which will help a lot. Warning: this method may get called more than once.


eval

public void eval(ec.EvolutionState state,
                 int thread,
                 ec.gp.GPData input,
                 ec.gp.ADFStack stack,
                 ec.gp.GPIndividual individual,
                 ec.Problem problem)
Description copied from class: ec.gp.GPNode
Evaluates 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;
    }