Package ptolemy.domains.tester.kernel
Class TesterDirector
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.actor.Director
-
- ptolemy.domains.tester.kernel.TesterDirector
-
- All Implemented Interfaces:
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$
- Author:
- Christopher Brooks, Dai Bui, Edward A. Lee, Ben Lickly
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description Parameter
trainingMode
Indicator of whether to invoke train() or test() on the Testable objects.-
Fields inherited from class ptolemy.actor.Director
_actorsFinishedExecution, _aspectForActor, _aspectsPresent, _defaultMicrostep, _executionAspects, _finishRequested, _initializables, _nextScheduleTime, _stopRequested, _tokenSentToCommunicationAspect, _zeroTime, localClock, startTime, stopTime
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _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
Constructors Constructor Description TesterDirector(CompositeEntity container, java.lang.String name)
Construct a director.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _schedule, _transferInputs, _transferOutputs, attributeChanged, clone, createSchedule, defaultDependency, delayDependency, elapsedTimeSinceStart, finish, fireAt, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getCurrentTime, getDeadline, getEnvironmentTime, getExecutionAspect, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, initialize, invalidateResolvedTypes, invalidateSchedule, isEmbedded, isFireFunctional, isStopRequested, isStrict, iterate, mutexLockObject, newReceiver, notifyTokenSentToCommunicationAspect, preinitialize, removeInitializable, requestInitialization, resume, resumeActor, scheduleContainedActors, setContainer, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, stop, stopFire, suggestedModalModelDirectors, supportMultirateFiring, suspend, terminate, transferOutputs
-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, 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, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
-
-
-
-
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 interfaceInitializable
- Overrides:
addInitializable
in classDirector
- 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 interfaceExecutable
- Overrides:
fire
in classDirector
-
initialize
public void initialize()
Do nothing.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classDirector
-
postfire
public boolean postfire()
Return false, indicating that we are done.- Specified by:
postfire
in interfaceExecutable
- Overrides:
postfire
in classDirector
- Returns:
- True to continue execution, and false otherwise.
-
prefire
public boolean prefire()
Return true.- Specified by:
prefire
in interfaceExecutable
- Overrides:
prefire
in classDirector
- 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 interfaceInitializable
- Overrides:
preinitialize
in classDirector
- Throws:
IllegalActionException
- If the superclass throws it.
-
transferInputs
public boolean transferInputs(IOPort port)
Do nothing.- Overrides:
transferInputs
in classDirector
- 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 classDirector
- 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 interfaceInitializable
- Overrides:
wrapup
in classDirector
-
-