
NonStrictTest |
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.
The trainingMode parameter is a shared parameter,
meaning that if you change it for any one instance of this
actor in the model, then it will be changed for all instances.
Author(s): Paul Whitaker, Christopher Hylands, Edward A. Lee
Version:$Id: NonStrictTest.java,v 1.79 2006/04/20 09:06:35 hyzheng Exp $
Pt.Proposed Rating:Yellow (cxh)
Pt.Accepted Rating:Yellow (cxh)
correctValues
A matrix specifying what the input should be.
This defaults to a one-by-one array containing a boolean true.
tolerance
A double specifying how close the input has to be to the value
given by correctValues. This is a DoubleToken, with default
value 10-9.
trainingMode
If true, then do not check inputs, but rather collect them into
the correctValues array. This parameter is a boolean,
and it defaults to false. It is a shared parameter, meaning
that changing it for any one instance in a model will change
it for all instances in the model.