public abstract class ThresholdStoppingConditionConstraintEvaluator extends StoppingConditionConstraintEvaluator
Modifier | Constructor and Description |
---|---|
protected |
ThresholdStoppingConditionConstraintEvaluator(EvaluatorGroup group,
ThresholdStoppingConditionConstraint definition)
Initializes a new instance.
|
protected |
ThresholdStoppingConditionConstraintEvaluator(ThresholdStoppingConditionConstraintEvaluator existingInstance,
CopyContext context)
Initializes a new instance as a copy of an existing instance.
|
Modifier and Type | Method and Description |
---|---|
void |
checkCurrentState(ITimeBasedState currentState)
This method gets called every time a new
ITimeBasedState is checked
by the parent StoppingConditionEvaluator . |
protected abstract double |
evaluateSingleValue(ITimeBasedState state)
|
boolean |
getIsThreadSafe()
Gets a value indicating whether the methods on this instance are safe to call from
multiple threads simultaneously.
|
boolean |
isConstraintSatisfied(ITimeBasedState state)
This method will examine from the state and return
true if this
constraint is satisfied, and false
if not. |
static boolean |
simpleCheck(double currentValue,
double threshold,
double tolerance,
boolean useAbsoluteValue,
InequalityCondition inequalityCriteria,
double smallestValue,
double largestValue)
Performs a simple check of the
currentValue against a threshold and tolerance ,
using the useAbsoluteValue and inequalityCriteria to determine if this
constraint is satisfied by the currentValue . |
areConstraintsSatisfied, clone, dispose, dispose, getAvailabilityIntervals, getCachingWrapper, getGroup, getName, getWhenToCheck, initialize, isAvailable, updateEvaluatorReferences
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close
protected ThresholdStoppingConditionConstraintEvaluator(@Nonnull EvaluatorGroup group, @Nonnull ThresholdStoppingConditionConstraint definition)
group
- The group that contains this evaluator.definition
- The ThresholdStoppingConditionConstraint
that is creating this evaluator.ArgumentNullException
- Thrown when group
or definition
is null
.protected ThresholdStoppingConditionConstraintEvaluator(@Nonnull ThresholdStoppingConditionConstraintEvaluator existingInstance, @Nonnull CopyContext context)
See ICloneWithContext.clone(CopyContext)
for more information about how to implement this constructor
in a derived class.
existingInstance
- The existing instance to copy.context
- A CopyContext
that controls the depth of the copy.ArgumentNullException
- Thrown when existingInstance
or context
is null
.public boolean getIsThreadSafe()
If this property is true
, all methods and properties are guaranteed to be thread safe.
Conceptually, an object that returns true
for this method acts as if there is a lock
protecting each method and property such that only one thread at a time can be inside any method or
property in the class. In reality, such locks are generally not used and are in fact discouraged. However,
the user must not experience any exceptions or inconsistent behavior that would not be experienced if such
locks were used.
If this property is false
, the behavior when using this class from multiple threads
simultaneously is undefined and may include inconsistent results and exceptions. Clients wishing to use
multiple threads should call CopyForAnotherThread.copy(T)
to get a separate instance of the
object for each thread.
getIsThreadSafe
in interface IThreadAware
getIsThreadSafe
in class StoppingConditionConstraintEvaluator
public static boolean simpleCheck(double currentValue, double threshold, double tolerance, boolean useAbsoluteValue, @Nonnull InequalityCondition inequalityCriteria, double smallestValue, double largestValue)
currentValue
against a threshold
and tolerance
,
using the useAbsoluteValue
and inequalityCriteria
to determine if this
constraint is satisfied by the currentValue
.
This method can be called by ThresholdStoppingConditionConstraintEvaluator.isConstraintSatisfied(agi.foundation.coordinates.ITimeBasedState)
if your constraint is simply computing a value to be compared to a threshold.currentValue
- The current computed value.threshold
- The threshold.tolerance
- The tolerance.smallestValue
- The smallest value that has been computed up to this point.largestValue
- The largest value that has been computed up to this point.inequalityCriteria
- The InequalityCondition
that should be used to compare the
currentValue
to the threshold
.useAbsoluteValue
- Whether or not the absolute value of the currentValue
should be used when determining if the constraint is satisfied.true
if the currentValue
satisfies the constraint; otherwise false
.public void checkCurrentState(ITimeBasedState currentState)
ITimeBasedState
is checked
by the parent StoppingConditionEvaluator
. This method
should be used when the criteria of your StoppingConditionConstraintEvaluator
needs to check every computed state. For example,
ThresholdStoppingConditionConstraintEvaluator
needs to keep track of extrema if its
InequalityCriteria
(get
/ set
) is set to
InequalityCondition.GREATER_THAN_MINIMUM
or InequalityCondition.LESS_THAN_MAXIMUM
.checkCurrentState
in class StoppingConditionConstraintEvaluator
currentState
- The state to check at every step of propagation.public boolean isConstraintSatisfied(ITimeBasedState state)
true
if this
constraint
is satisfied, and false
if not.isConstraintSatisfied
in class StoppingConditionConstraintEvaluator
state
- The state to check.true
if this constraint is satisfied; otherwise false
.
When all constraints
return true
, then the
stopping condition
may stop propagation if it too is satisfied.protected abstract double evaluateSingleValue(ITimeBasedState state)
This method will return the value that will be compared to the
Threshold
(get
/ set
). This method does not
need to deal with UseAbsoluteValue
(get
/ set
).
state
- The current state
of propagation.constraint
.