public abstract class StoppingCondition extends DefinitionalObject
Evaluator
that will actually produce
the value.
See the Stopping Conditions topic for more detail on how to use stopping conditions.
Modifier | Constructor and Description |
---|---|
protected |
StoppingCondition()
Initializes a new instance.
|
protected |
StoppingCondition(double valueTolerance,
StopType type)
Initializes a new instance.
|
protected |
StoppingCondition(StoppingCondition existingInstance,
CopyContext context)
Initializes a new instance as a copy of an existing instance.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkForSameDefinition(DefinitionalObject other)
Checks to determine if another instance has the same definition as this instance and
returns
true if it does. |
protected abstract boolean |
checkForSameDefinition(StoppingCondition 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 ValueDefinition<Double> |
createDoubleThreshold()
Creates a
ValueDefinition of type double . |
void |
enumerateDependencies(DependencyEnumerator enumerator)
Enumerates the dependencies of this object by calling
DependencyEnumerator#enumerate(T) for each object that this object directly depends upon. |
protected void |
freezeAggregatedObjects()
Called by
DefinitionalObject.freeze() to also freeze any objects that are considered to be a part of this object. |
CircularRange |
getAngularSetting()
Gets the range a value should be cropped to if the value computed is a angle, or indicates that the value
computed is not an angle.
|
List<StoppingConditionConstraint> |
getConstraints()
Gets additional
constraints on the stopping condition. |
StoppingConditionEnabled |
getEnabled()
Gets if this
StoppingCondition will be considered during propagation. |
abstract StoppingConditionEvaluator |
getEvaluator(EvaluatorGroup group)
Gets a
StoppingConditionEvaluator for use in the
NumericalPropagator . |
double |
getFunctionTolerance()
Gets how close the function value must get to the
threshold to
be considered equal to. |
String |
getName()
Gets an optional name for this stopping condition.
|
boolean |
getRequireFunctionTolerance()
|
StoppingTriggeredCallback |
getSatisfiedCallback()
Gets a callback that is executed when this condition is satisfied.
|
int |
getStopOnEventNumber()
Gets how many times the threshold must be met, or how many extrema must be found before stopping.
|
StopType |
getTypeOfStoppingCondition()
Gets the type of the event to stop on (extrema, threshold, ...).
|
void |
setAngularSetting(CircularRange value)
Sets the range a value should be cropped to if the value computed is a angle, or indicates that the value
computed is not an angle.
|
void |
setEnabled(StoppingConditionEnabled value)
Sets if this
StoppingCondition will be considered during propagation. |
void |
setFunctionTolerance(double value)
Sets how close the function value must get to the
threshold to
be considered equal to. |
void |
setName(String value)
Sets an optional name for this stopping condition.
|
void |
setRequireFunctionTolerance(boolean value)
|
void |
setSatisfiedCallback(StoppingTriggeredCallback value)
Sets a callback that is executed when this condition is satisfied.
|
void |
setStopOnEventNumber(int value)
Sets how many times the threshold must be met, or how many extrema must be found before stopping.
|
void |
setTypeOfStoppingCondition(StopType value)
Sets the type of the event to stop on (extrema, threshold, ...).
|
protected void |
validateProperties()
Validates that required properties are configured correctly in order to get an
evaluator for this instance.
|
areSameDefinition, areSameDefinition, areSameDefinition, areSameDefinition, areSameDefinition, clone, collectionItemsAreSameDefinition, collectionItemsAreSameDefinition, collectionItemsAreSameDefinition, dictionaryItemsAreSameDefinition, freeze, getCollectionHashCode, getCollectionHashCode, getCollectionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDictionaryHashCode, getIsFrozen, isSameDefinition, throwIfFrozen
protected StoppingCondition()
protected StoppingCondition(double valueTolerance, @Nonnull StopType type)
valueTolerance
- The tolerance between the value computed and the
threshold.type
- Specifies what type of threshold or extrema this stopping condition is attempting to stop on.protected StoppingCondition(@Nonnull StoppingCondition 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(DefinitionalObject 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 DefinitionalObject
other
- The other instance to compare to this one.true
if the two objects are defined equivalently; otherwise false
.protected abstract boolean checkForSameDefinition(StoppingCondition 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()
StoppingCondition.checkForSameDefinition(agi.foundation.infrastructure.DefinitionalObject)
method.computeCurrentDefinitionHashCode
in class DefinitionalObject
public void enumerateDependencies(DependencyEnumerator enumerator)
DependencyEnumerator#enumerate(T)
for each object that this object directly depends upon.
Derived classes which contain additional dependencies MUST override this method, call the base
implementation, and enumerate dependencies introduced by the derived class.enumerateDependencies
in interface IEnumerateDependencies
enumerateDependencies
in class DefinitionalObject
enumerator
- The enumerator that is informed of the dependencies of this object.protected void freezeAggregatedObjects()
DefinitionalObject.freeze()
to also freeze any objects that are considered to be a part of this object.
Derived classes which contain additional aggregated objects MUST override this method, call the base
implementation, and freeze aggregated objects introduced by the derived class. The objects that need to be
frozen in this method are frequently created in this object's constructor and are not settable via
properties.freezeAggregatedObjects
in class DefinitionalObject
public final String getName()
public final void setName(String value)
public final StoppingTriggeredCallback getSatisfiedCallback()
public final void setSatisfiedCallback(StoppingTriggeredCallback value)
@Nonnull public final StopType getTypeOfStoppingCondition()
public final void setTypeOfStoppingCondition(@Nonnull StopType value)
public abstract ValueDefinition<Double> createDoubleThreshold()
ValueDefinition
of type double
. If the
derived StoppingCondition
defines its threshold to be of a different
type than a double, it can use a ValueDefinition
of that other
type in its StoppingConditionEvaluator
. However it is required that
the threshold can be represented as a double
and this must return such
a value. If the specified StoppingCondition
threshold is just a
ValueDefinition
of type double
, that property can simply
be returned here.ValueDefinition
where the type is a double
.public final double getFunctionTolerance()
threshold
to
be considered equal to. Note that even if there is unquestionably a threshold, if the event search can not
converge to a value at or below this value, it will not satisfy the stopping condition and no event will be
logged. This must be larger than machine precision of values near the threshold.public final void setFunctionTolerance(double value)
threshold
to
be considered equal to. Note that even if there is unquestionably a threshold, if the event search can not
converge to a value at or below this value, it will not satisfy the stopping condition and no event will be
logged. This must be larger than machine precision of values near the threshold.public final boolean getRequireFunctionTolerance()
FunctionTolerance
(get
/ set
) does not need to be satisfied. The search for an event will
still attempt to converge to within the FunctionTolerance
(get
/ set
), but if it is known that an event
is there (such as a threshold crossing), the event will be reported and this condition consider satisfied
even if the search did not converge within the FunctionTolerance
(get
/ set
). This is true
by default.public final void setRequireFunctionTolerance(boolean value)
FunctionTolerance
(get
/ set
) does not need to be satisfied. The search for an event will
still attempt to converge to within the FunctionTolerance
(get
/ set
), but if it is known that an event
is there (such as a threshold crossing), the event will be reported and this condition consider satisfied
even if the search did not converge within the FunctionTolerance
(get
/ set
). This is true
by default.public final int getStopOnEventNumber()
StoppingConditionEvaluator
finds a valid stop except for a
constraint
being unsatisfied, that will not count as a crossing.public final void setStopOnEventNumber(int value)
StoppingConditionEvaluator
finds a valid stop except for a
constraint
being unsatisfied, that will not count as a crossing.@Nonnull public final CircularRange getAngularSetting()
CircularRange.NOT_CIRCULAR
.public final void setAngularSetting(@Nonnull CircularRange value)
CircularRange.NOT_CIRCULAR
.@Nonnull public final StoppingConditionEnabled getEnabled()
StoppingCondition
will be considered during propagation.public final void setEnabled(@Nonnull StoppingConditionEnabled value)
StoppingCondition
will be considered during propagation.@Nonnull public final List<StoppingConditionConstraint> getConstraints()
constraints
on the stopping condition.
The constraints
allow you to add extra criteria to whether
an event should be considered valid to stop on. See
their help
for more information.@Nonnull public abstract StoppingConditionEvaluator getEvaluator(@Nonnull EvaluatorGroup group)
StoppingConditionEvaluator
for use in the
NumericalPropagator
.
Derived classes should call StoppingCondition.validateProperties()
to check properties
owned by this base class, as well as validate their own properties.
group
- The group
to use to initialize any
evaluators
that will be used by the condition and its Constraints
(get
).evaluator
for this StoppingCondition
.protected void validateProperties()
StoppingCondition.getEvaluator(agi.foundation.EvaluatorGroup)
, as well as validate their own properties.PropertyInvalidException
- Thrown when StopOnEventNumber
(get
/ set
) is not positive.PropertyInvalidException
- Thrown when FunctionTolerance
(get
/ set
) is not positive.