public abstract class AdaptiveNumericalIntegrator extends NumericalIntegrator
NumericalIntegrator
objects who can use error information
produced during integration to adapt the size of the step in order to adjust the amount of
error introduced into the dependent variables over successive integration steps. This
also allows varying the size of the step to arrive at a final stopping time.Modifier | Constructor and Description |
---|---|
protected |
AdaptiveNumericalIntegrator()
Initializes a new instance.
|
protected |
AdaptiveNumericalIntegrator(AdaptiveNumericalIntegrator existingInstance,
CopyContext context)
Initializes a new instance as a copy of an existing instance.
|
Modifier and Type | Method and Description |
---|---|
abstract boolean |
adaptStep()
This method updates the
CurrentStepSize (get ) to account for error in the state and its derivatives. |
protected double |
adjustStep(double step,
double errorRatio)
Adjusts a given step by increasing it or decreasing it based on the given error.
|
protected double |
boundAndTruncateStepSize(double stepSize)
|
double[] |
getAdaptiveWeights()
Gets the weights to be applied to the state elements when
computing the error which determines how to adapt the step size.
|
double |
getCurrentStepSize()
Gets the current (positive) size of the step which the integrator will use for the next integration step.
|
int |
getIterations()
Gets the number of iteration required to adapt the
CurrentStepSize (get ) to
within error tolerance. |
int |
getMaximumIterations()
|
double |
getMaximumStepSize()
Gets the maximum size of the
CurrentStepSize (get ). |
double |
getMinimumStepSize()
Gets the (positive) minimum size of the
CurrentStepSize (get ). |
double |
getStepDeflationExponent()
Gets the exponent to apply to the error when calculating the amount to decrease the size of the step.
|
double |
getStepDeflationFactor()
Gets a scalar multiplier to apply to the step when decreasing it.
|
double |
getStepInflationExponent()
Gets the exponent to apply to the error when calculating the amount to increase the size of the step.
|
double |
getStepInflationFactor()
Gets a scalar multiplier to apply to the step when increasing it.
|
KindOfStepSize |
getStepSizeBehavior()
Gets whether to avoid adapting the step size and instead fix the value of
CurrentStepSize (get ). |
int |
getStepTruncationOrder()
Gets the integer exponent specifying the order of magnitude at which to
truncate the significant digits in the
CurrentStepSize (get ). |
void |
initialize(double x,
double[] y)
Initialize the integrator's initial independent and dependent variables and reset the integration parameters.
|
void |
integrate()
Perform an integration step moving the independent and dependent variables from their
initial (the final values of the previous step) to their new final values,
using the
CurrentStepSize (get ). |
void |
integrate(double stepSize)
Integrate the current integration step with the given step size.
|
void |
setAdaptiveWeights(double[] value)
Sets the weights to be applied to the state elements when
computing the error which determines how to adapt the step size.
|
protected void |
setCurrentStepSize(double value)
Sets the value of the
CurrentStepSize (get ) which the
integrator will use for the next integration step. |
protected void |
setIterations(int value)
Sets the number of iteration required to adapt the
CurrentStepSize (get ) to
within error tolerance. |
void |
setMaximumIterations(int value)
|
void |
setMaximumStepSize(double value)
Sets the maximum size of the
CurrentStepSize (get ). |
void |
setMinimumStepSize(double value)
Sets the (positive) minimum size of the
CurrentStepSize (get ). |
void |
setStepDeflationExponent(double value)
Sets the exponent to apply to the error when calculating the amount to decrease the size of the step.
|
void |
setStepDeflationFactor(double value)
Sets a scalar multiplier to apply to the step when decreasing it.
|
void |
setStepInflationExponent(double value)
Sets the exponent to apply to the error when calculating the amount to increase the size of the step.
|
void |
setStepInflationFactor(double value)
Sets a scalar multiplier to apply to the step when increasing it.
|
void |
setStepSizeBehavior(KindOfStepSize value)
Sets whether to avoid adapting the step size and instead fix the value of
CurrentStepSize (get ). |
void |
setStepTruncationOrder(int value)
Sets the integer exponent specifying the order of magnitude at which to
truncate the significant digits in the
CurrentStepSize (get ). |
clone, getDimension, getDirection, getFinalDependentVariableValues, getFinalIndependentVariableValue, getInitialDependentVariableValues, getInitialIndependentVariableValue, getInitialStepSize, getIsThreadSafe, getPreviousStepSize, getStepSizeInformation, getSystemOfEquations, reintegrate, setDirection, setFinalDependentVariableValues, setFinalIndependentVariableValue, setInitialDependentVariableValues, setInitialIndependentVariableValue, setInitialStepSize, setStepSizeInformation, setSystemOfEquations, startNextStep
protected AdaptiveNumericalIntegrator()
protected AdaptiveNumericalIntegrator(@Nonnull AdaptiveNumericalIntegrator 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 final double getMinimumStepSize()
CurrentStepSize
(get
).public final void setMinimumStepSize(double value)
CurrentStepSize
(get
).public final double getMaximumStepSize()
CurrentStepSize
(get
).public final void setMaximumStepSize(double value)
CurrentStepSize
(get
).public final int getStepTruncationOrder()
CurrentStepSize
(get
). For instance,
to truncate the value to three decimal places, specify a truncation order of -3.
To truncate the value to an order of 100, specify a truncation order of 2. To specify
the step size should be an integer value, specify a truncation order of 0.public final void setStepTruncationOrder(int value)
CurrentStepSize
(get
). For instance,
to truncate the value to three decimal places, specify a truncation order of -3.
To truncate the value to an order of 100, specify a truncation order of 2. To specify
the step size should be an integer value, specify a truncation order of 0.@Nonnull public final KindOfStepSize getStepSizeBehavior()
CurrentStepSize
(get
).public final void setStepSizeBehavior(@Nonnull KindOfStepSize value)
CurrentStepSize
(get
).public final double getStepDeflationFactor()
public final void setStepDeflationFactor(double value)
public final double getStepDeflationExponent()
public final void setStepDeflationExponent(double value)
public final double getStepInflationFactor()
public final void setStepInflationFactor(double value)
public final double getStepInflationExponent()
public final void setStepInflationExponent(double value)
public double getCurrentStepSize()
getCurrentStepSize
in class NumericalIntegrator
protected final void setCurrentStepSize(double value)
CurrentStepSize
(get
) which the
integrator will use for the next integration step.value
- The (positive) value to add to the independent variable
for the next integration step.public final int getIterations()
CurrentStepSize
(get
) to
within error tolerance.protected final void setIterations(int value)
CurrentStepSize
(get
) to
within error tolerance.public final int getMaximumIterations()
public final void setMaximumIterations(int value)
public final double[] getAdaptiveWeights()
AdaptiveNumericalIntegrator.initialize(double, double[])
is called, they will be set to a default value
of one.public final void setAdaptiveWeights(double[] value)
AdaptiveNumericalIntegrator.initialize(double, double[])
is called, they will be set to a default value
of one.public void initialize(double x, double[] y)
initialize
in class NumericalIntegrator
x
- The value of the initial independent variable.y
- The values for the initial dependent variables.public final void integrate()
Perform an integration step moving the independent and dependent variables from their
initial (the final values of the previous step) to their new final values,
using the CurrentStepSize
(get
).
When overriding this method, NumericalIntegrator.startNextStep()
should be called prior to
integration.
integrate
in class NumericalIntegrator
public void integrate(double stepSize)
integrate
in class NumericalIntegrator
stepSize
- The step size at which to take the integration step.public abstract boolean adaptStep()
CurrentStepSize
(get
) to account for error in the state and its derivatives.
It returns true if the integrator should reintegrate with the updated step size or false if the integrator
should continue to the next integration step (potentially with a different step size).protected final double boundAndTruncateStepSize(double stepSize)
CurrentStepSize
(get
) which
will bound the size based on the MinimumStepSize
(get
/ set
) and MaximumStepSize
(get
/ set
),
and will truncate it based on the StepTruncationOrder
(get
/ set
).stepSize
- The size of the previous step to bound and truncate.protected final double adjustStep(double step, double errorRatio)
AdaptiveNumericalIntegrator.boundAndTruncateStepSize(double)
is called.step
- The size of the step to adjust.errorRatio
- The error ratio factor.