public abstract class ThresholdStoppingConditionConstraint extends StoppingConditionConstraint
StoppingConditionConstraint
that will compute a single value and compare it
to a Threshold
(get
/ set
) to determine
if this constraint is satisfied.Modifier | Constructor and Description |
---|---|
protected |
ThresholdStoppingConditionConstraint()
Initializes a new instance.
|
protected |
ThresholdStoppingConditionConstraint(double threshold,
double tolerance,
WhenToCheckConstraint whenToCheck,
InequalityCondition inequality,
boolean useAbsoluteValue)
Initializes a new instance.
|
protected |
ThresholdStoppingConditionConstraint(ThresholdStoppingConditionConstraint existingInstance,
CopyContext context)
Initializes a new instance as a copy of an existing instance.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkForSameDefinition(StoppingConditionConstraint other)
Checks to determine if another instance has the same definition as this instance and
returns
true if it does. |
protected abstract boolean |
checkForSameDefinition(ThresholdStoppingConditionConstraint other)
Checks to determine if another instance has the same definition as this instance and
returns
true if it does. |
protected int |
computeCurrentDefinitionHashCode()
Computes a hash code based on the current properties of this object.
|
abstract StoppingConditionConstraintEvaluator |
getEvaluator(EvaluatorGroup group)
Gets a
StoppingConditionConstraintEvaluator for use in the
StoppingConditionEvaluator . |
InequalityCondition |
getInequalityCriteria()
Gets how the calculated value should be checked to the threshold in the concrete type.
|
double |
getThreshold()
Gets the threshold to compare with the value evaluated by the
ThresholdStoppingConditionConstraintEvaluator . |
double |
getTolerance()
Gets the tolerance to use when comparing the
Threshold (get / set ) to the value evaluated
by the ThresholdStoppingConditionConstraintEvaluator . |
boolean |
getUseAbsoluteValue()
|
void |
setInequalityCriteria(InequalityCondition value)
Sets how the calculated value should be checked to the threshold in the concrete type.
|
void |
setThreshold(double value)
Sets the threshold to compare with the value evaluated by the
ThresholdStoppingConditionConstraintEvaluator . |
void |
setTolerance(double value)
Sets the tolerance to use when comparing the
Threshold (get / set ) to the value evaluated
by the ThresholdStoppingConditionConstraintEvaluator . |
void |
setUseAbsoluteValue(boolean value)
|
protected void |
validateProperties()
Validates that required properties are configured correctly in order to get an
evaluator for this instance.
|
checkForSameDefinition, getName, getWhenToCheck, setName, setWhenToCheck
areSameDefinition, areSameDefinition, areSameDefinition, areSameDefinition, areSameDefinition, clone, collectionItemsAreSameDefinition, collectionItemsAreSameDefinition, collectionItemsAreSameDefinition, dictionaryItemsAreSameDefinition, enumerateDependencies, freeze, freezeAggregatedObjects, getCollectionHashCode, getCollectionHashCode, getCollectionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDictionaryHashCode, getIsFrozen, isSameDefinition, throwIfFrozen
protected ThresholdStoppingConditionConstraint()
protected ThresholdStoppingConditionConstraint(double threshold, double tolerance, @Nonnull WhenToCheckConstraint whenToCheck, @Nonnull InequalityCondition inequality, boolean useAbsoluteValue)
threshold
- The threshold to compare with the value that gets evaluated.tolerance
- The tolerance to use when comparing the threshold
with the evaluated value.whenToCheck
- Specifies whether this condition should be checked when a stop is detected or found.inequality
- Specifies how the value gets evaluated by this constraint gets compared to the threshold
.useAbsoluteValue
- Specifies if the absolute value of the computed value should be used when compared to the threshold
or not.protected ThresholdStoppingConditionConstraint(@Nonnull ThresholdStoppingConditionConstraint 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
.protected final boolean checkForSameDefinition(StoppingConditionConstraint other)
true
if it does. Derived classes MUST override this method and check
all new fields introduced by the derived class for definitional equivalence. It is NOT necessary
to check base class fields because the base class will already have done that. When overriding this method,
you should NOT call the base implementation because it will return false
for all derived-class instances.
Derived classes should check the type of other
to preserve the symmetric nature of IEquatableDefinition.isSameDefinition(java.lang.Object)
.checkForSameDefinition
in class StoppingConditionConstraint
other
- The other instance to compare to this one.true
if the two objects are defined equivalently; otherwise false
.protected abstract boolean checkForSameDefinition(ThresholdStoppingConditionConstraint other)
true
if it does. Derived classes MUST override this method and check
all new fields introduced by the derived class for definitional equivalence. It is NOT necessary
to check base class fields because the base class will already have done that. When overriding this method,
you should NOT call the base implementation because it will return false
for all derived-class instances.
Derived classes should check the type of other
to preserve the symmetric nature of IEquatableDefinition.isSameDefinition(java.lang.Object)
.other
- The other instance to compare to this one.true
if the two objects are defined equivalently; otherwise false
.protected int computeCurrentDefinitionHashCode()
ThresholdStoppingConditionConstraint.checkForSameDefinition(agi.foundation.stoppingconditions.StoppingConditionConstraint)
method.computeCurrentDefinitionHashCode
in class StoppingConditionConstraint
@Nonnull public final InequalityCondition getInequalityCriteria()
Threshold
(get
/ set
) is 6000
and this property set to InequalityCondition.GREATER_THAN
, this constraint will be
satisfied.public final void setInequalityCriteria(@Nonnull InequalityCondition value)
Threshold
(get
/ set
) is 6000
and this property set to InequalityCondition.GREATER_THAN
, this constraint will be
satisfied.public final boolean getUseAbsoluteValue()
public final void setUseAbsoluteValue(boolean value)
public double getThreshold()
ThresholdStoppingConditionConstraintEvaluator
.public void setThreshold(double value)
ThresholdStoppingConditionConstraintEvaluator
.public double getTolerance()
Threshold
(get
/ set
) to the value evaluated
by the ThresholdStoppingConditionConstraintEvaluator
.public void setTolerance(double value)
Threshold
(get
/ set
) to the value evaluated
by the ThresholdStoppingConditionConstraintEvaluator
.public abstract StoppingConditionConstraintEvaluator getEvaluator(EvaluatorGroup group)
StoppingConditionConstraintEvaluator
for use in the
StoppingConditionEvaluator
.
Derived classes should call ThresholdStoppingConditionConstraint.validateProperties()
to check properties
owned by this base class, as well as validate their own properties.
getEvaluator
in class StoppingConditionConstraint
group
- The group
to use to initialize any
evaluators
that will be used by actual constraint.evaluator
for this
StoppingConditionConstraint
.protected void validateProperties()
ThresholdStoppingConditionConstraint.getEvaluator(agi.foundation.EvaluatorGroup)
, as well as validate their own properties.PropertyInvalidException
- Thrown when Tolerance
(get
/ set
) is negative and InequalityCriteria
(get
/ set
) is
InequalityCondition.EQUALS
or InequalityCondition.NOT_EQUALS
.