|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.actor.lib.Sink
ptolemy.actor.lib.NonStrictTest
This actor compares the inputs against the value specified by the correctValues parameter. That parameter is an ArrayToken, where each element of the array is of the same type as the input. On each firing where the input is present, the value of the input is compared against the next token in the correctValues parameter. If it matches, the firing succeeds. If it doesn't match, then an exception is thrown. After matching each of the value in the correctValues parameter, subsequent iterations always succeed, so the actor can be used as a "power-up" test for a model, checking the first few iterations against some known results.
Unlike the Test actor, NonStrictTest does not support a multiport input, only single port inputs are supported. This also differs from Test in that it ignores absent inputs, and it checks the inputs in the postfire() method rather than the fire() method.
If the input is a DoubleToken or ComplexToken, then the comparison passes if the value is close to what it should be, within the specified tolerance (which defaults to 10-9. The input data type is undeclared, so it can resolve to anything.
If the parameter trainingMode is true, then instead of performing the test, this actor collects the inputs into the correctValues parameter. Thus, to use this actor, you can place it in a model, set trainingMode to true to collect the reference data, then set trainingMode to false. Any subsequent run of the actor will throw an exception if the input data does not match the training data. The value of the reference token is set in the wrapup() method.
Test,
Serialized Form
| Yellow (cxh) |
| Yellow (cxh) |
| Nested Class Summary |
| Nested classes inherited from class ptolemy.kernel.Entity |
Entity.ContainedObjectsIterator |
| Field Summary | |
protected int |
_iteration
Count of iterations. |
protected int |
_numberOfInputTokensSeen
Number of input tokens seen by this actor in the fire method. |
protected double |
_tolerance
A double that is read from the tolerance parameter specifying how close the input has to be to the value given by correctValues. |
protected java.util.List |
_trainingTokens
List to store tokens for training mode. |
Parameter |
correctValues
A matrix specifying what the input should be. |
Parameter |
tolerance
A double specifying how close the input has to be to the value given by correctValues. |
static java.lang.String |
TRAINING_MODE_ERROR_MESSAGE
Exception message that is used if we are running under the nightly build and the trainingMode parameter is true. |
Parameter |
trainingMode
If true, then do not check inputs, but rather collect them into the correctValues array. |
| Fields inherited from class ptolemy.actor.lib.Sink |
input |
| Fields inherited from class ptolemy.actor.AtomicActor |
_stopRequested |
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
| Fields inherited from interface ptolemy.actor.Executable |
COMPLETED, NOT_READY, STOP_ITERATING |
| Constructor Summary | |
NonStrictTest(CompositeEntity container,
java.lang.String name)
Construct an actor with an input multiport. |
|
| Method Summary | |
void |
attributeChanged(Attribute attribute)
If the attribute being changed is tolerance, then check that it is increasing and nonnegative. |
void |
initialize()
Override the base class to set the iteration counter to zero. |
static boolean |
isRunningNightlyBuild()
If the trainingMode parameter is true and the model is being run as part of the test suite, then throw an exception. |
boolean |
postfire()
Read one token from each input channel and compare against the value specified in correctValues. |
void |
wrapup()
If trainingMode is true, then take the collected training tokens and store them as an array in correctValues. |
| Methods inherited from class ptolemy.actor.TypedAtomicActor |
_addPort, attributeTypeChanged, clone, newPort, typeConstraintList |
| Methods inherited from class ptolemy.actor.AtomicActor |
_createReceivers, clone, connectionsChanged, fire, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate |
| Methods inherited from class ptolemy.kernel.ComponentEntity |
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, propagateExistence, setName |
| Methods inherited from class ptolemy.kernel.Entity |
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables |
| Methods inherited from class ptolemy.kernel.InstantiableNamedObj |
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface ptolemy.actor.Actor |
getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, newReceiver, outputPortList |
| Methods inherited from interface ptolemy.actor.Executable |
fire, iterate, prefire, preinitialize, stop, stopFire, terminate |
| Methods inherited from interface ptolemy.kernel.util.Derivable |
getDerivedLevel, getDerivedList, propagateValue |
| Methods inherited from interface ptolemy.kernel.util.Nameable |
description, getFullName, getName, getName |
| Field Detail |
public Parameter correctValues
public Parameter tolerance
public Parameter trainingMode
public static java.lang.String TRAINING_MODE_ERROR_MESSAGE
protected int _numberOfInputTokensSeen
protected double _tolerance
protected int _iteration
protected java.util.List _trainingTokens
| Constructor Detail |
public NonStrictTest(CompositeEntity container,
java.lang.String name)
throws NameDuplicationException,
IllegalActionException
container - The container.name - The name of this actor.
IllegalActionException - If the entity cannot be contained
by the proposed container.
NameDuplicationException - If the container already has an
actor with this name.| Method Detail |
public void attributeChanged(Attribute attribute)
throws IllegalActionException
attributeChanged in class NamedObjattribute - The attribute that changed.
IllegalActionException - If the indexes vector is not
increasing and nonnegative, or the indexes is not a row vector.
public void initialize()
throws IllegalActionException
initialize in interface Executableinitialize in class AtomicActorIllegalActionException - If the base class throws it or
if we are running under the test suite and the trainingMode
parameter is set to true.isRunningNightlyBuild()public static boolean isRunningNightlyBuild()
make nightly
public boolean postfire()
throws IllegalActionException
postfire in interface Executablepostfire in class AtomicActorIllegalActionException - If an input does not match
the required value or if the width of the input is not 1.
public void wrapup()
throws IllegalActionException
wrapup in interface Executablewrapup in class AtomicActorIllegalActionException - Not thrown in this base class.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||