ptolemy.domains.tester.kernel
Class TesterDirector

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.actor.Director
              extended by ptolemy.domains.tester.kernel.TesterDirector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Executable, Initializable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class TesterDirector
extends Director

This director does not execute a model, but instead looks for attributes contained by the model at the same level of the hierarchy as this director that implement the Testable interface. If the train parameter is false, it invokes the test() method on them, and otherwise, it invokes the train() method on them. It does everything in preinitialize(). It first invokes preinitialize() on all contained actors, and then runs test() or train() on all contained Testable attributes. If any of those throws an exception, then preinitialize() throws an exception.

Since:
Ptolemy II 8.0
Version:
$Id: TesterDirector.java 59167 2010-09-21 17:08:02Z cxh $
Author:
Christopher Brooks, Dai Bui, Edward A. Lee, Ben Lickly
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
 Parameter trainingMode
          Indicator of whether to invoke train() or test() on the Testable objects.
 
Fields inherited from class ptolemy.actor.Director
_actorsFinishedExecution, _currentTime, _finishRequested, _initializables, _stopRequested, timeResolution
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
TesterDirector(CompositeEntity container, java.lang.String name)
          Construct a director.
 
Method Summary
 void addInitializable(Initializable initializable)
          Do nothing.
 void fire()
          Do nothing.
 void initialize()
          Do nothing.
 boolean postfire()
          Return false, indicating that we are done.
 boolean prefire()
          Return true.
 void preinitialize()
          Override the base class to first invoke preinitialize() on all contained actors and then invoke either test() or train() on all Testable attributes.
 boolean transferInputs(IOPort port)
          Do nothing.
 boolean transferOutputs(IOPort port)
          Do nothing.
 void wrapup()
          Do nothing.
 
Methods inherited from class ptolemy.actor.Director
_description, _fireContainerAt, _isEmbedded, _isTopLevel, _transferInputs, _transferOutputs, attributeChanged, createSchedule, defaultDependency, finish, fireAt, fireAt, fireAtCurrentTime, getCausalityInterface, getCurrentTime, getErrorTolerance, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, initialize, invalidateResolvedTypes, invalidateSchedule, isFireFunctional, isStopRequested, isStrict, iterate, newReceiver, preinitialize, removeInitializable, requestInitialization, setContainer, setCurrentTime, setModelTime, stop, stopFire, suggestedModalModelDirectors, supportMultirateFiring, terminate
 
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, clone, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

trainingMode

public Parameter trainingMode
Indicator of whether to invoke train() or test() on the Testable objects. This defaults to false which means test().

Constructor Detail

TesterDirector

public TesterDirector(CompositeEntity container,
                      java.lang.String name)
               throws IllegalActionException,
                      NameDuplicationException
Construct a director.

Parameters:
container - The container.
name - The name.
Throws:
IllegalActionException - If the base class throws it.
NameDuplicationException - If the base class throws it.
Method Detail

addInitializable

public void addInitializable(Initializable initializable)
Do nothing.

Specified by:
addInitializable in interface Initializable
Overrides:
addInitializable in class Director
Parameters:
initializable - The object whose methods should be invoked.
See Also:
Director.removeInitializable(Initializable), CompositeActor.addPiggyback(Executable)

fire

public void fire()
Do nothing.

Specified by:
fire in interface Executable
Overrides:
fire in class Director

initialize

public void initialize()
Do nothing.

Specified by:
initialize in interface Initializable
Overrides:
initialize in class Director

postfire

public boolean postfire()
Return false, indicating that we are done.

Specified by:
postfire in interface Executable
Overrides:
postfire in class Director
Returns:
True to continue execution, and false otherwise.

prefire

public boolean prefire()
Return true.

Specified by:
prefire in interface Executable
Overrides:
prefire in class Director
Returns:
True.

preinitialize

public void preinitialize()
                   throws IllegalActionException
Override the base class to first invoke preinitialize() on all contained actors and then invoke either test() or train() on all Testable attributes.

Specified by:
preinitialize in interface Initializable
Overrides:
preinitialize in class Director
Throws:
IllegalActionException - If the superclass throws it.

transferInputs

public boolean transferInputs(IOPort port)
Do nothing.

Overrides:
transferInputs in class Director
Parameters:
port - The port to transfer tokens from.
Returns:
True if at least one data token is transferred.

transferOutputs

public boolean transferOutputs(IOPort port)
Do nothing.

Overrides:
transferOutputs in class Director
Parameters:
port - The port to transfer tokens from.
Returns:
True if at least one data token is transferred.

wrapup

public void wrapup()
Do nothing.

Specified by:
wrapup in interface Initializable
Overrides:
wrapup in class Director