de.torstennahm.integrate
Class Integrator<I>

java.lang.Object
  extended by de.torstennahm.integrate.Integrator<I>
Direct Known Subclasses:
DefaultSparseIntegrator, EstimateIntegrator, EvaluateIntegrator, MCIntegrator, ProductIntegrator, QMCIntegrator, SimplexIntegrator, WeightedIntegrator

public abstract class Integrator<I>
extends java.lang.Object

The integrator performs integration of the integrand until a specified condition is reached. The condition may for example be that a certain error tolerance has been reached. The implementing classes use various specific algorithms for numerical integration. Unless stated otherwise, integration is always performed over the unit cube [0,1]^d with the Lesbegue measure, where d is the dimension of the function.

Many integrators use quadrature formulas consisting of coordinates and weights. See the package de.torstennahm.integrate.quadratureformula.

Implementor's note: Only the abstract method integrate needs to be implemented. All other methods refer to this method using specific stop conditions. In the integrate method, subclasses should perform an open-ended process of integration, in which the result of the integration is continually refined. At regular times, they should check if the integration should be continued. For this, they store the result of the integration so far in an IntegrationResult instance and pass it to the stop condition's stop method. If true is returned, the integration stops and the same IntegrationResult instance for which the stop condition was reached is passed back as final result of the integration. This assures that the IntegrationResult actually fulfills the stop condition.

Author:
Torsten Nahm
See Also:
StopConditions

Constructor Summary
Integrator()
           
 
Method Summary
 IntegrationResult integrate(I integrand, StopCondition condition)
          Convenience method for integration run without visualizers.
abstract  IntegrationResult integrate(I integrand, StopCondition condition, java.util.List<Visualizer> visualizers)
          Performs numerical integration of the integrand until the given condition is fulfilled.
 IntegrationResult integrateAbsTol(I integrand, double absoluteTolerance)
          Convenience method for integration until the absolute estimated error is less than than the specified threshold.
 IntegrationResult integrateAbsTol(I integrand, double absoluteTolerance, java.util.List<Visualizer> visualizers)
          Convenience method for integration with visualizers until the absolute estimated error is less than than the specified threshold.
 IntegrationResult integrateByPoints(I integrand, long evals)
          Convenience method for integration until the specified number of evaluations has been reached.
 IntegrationResult integrateByPoints(I integrand, long evals, java.util.List<Visualizer> visualizers)
          Convenience method for integration with visualizers until the specified number of evaluations has been reached.
 IntegrationResult integrateRelTol(I integrand, double relativeTolerance)
          Convenience method for integration until the absolute estimated error is less than than the specified threshold.
 IntegrationResult integrateRelTol(I integrand, double relativeTolerance, java.util.List<Visualizer> visualizers)
          Convenience method for integration with visualizers until the relative estimated error is less than than the specified threshold.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Integrator

public Integrator()
Method Detail

integrate

public abstract IntegrationResult integrate(I integrand,
                                            StopCondition condition,
                                            java.util.List<Visualizer> visualizers)
                                     throws IntegrationFailedException
Performs numerical integration of the integrand until the given condition is fulfilled.

Parameters:
integrand - object to be integrated
condition - stop condition
visualizers - list of visualizers or null for no visualization
Returns:
result of integration
Throws:
IntegrationFailedException - if an integration error occurs

integrate

public IntegrationResult integrate(I integrand,
                                   StopCondition condition)
                            throws IntegrationFailedException
Convenience method for integration run without visualizers. Calls integrate(I, StopCondition, null).

Parameters:
integrand - object to be integrated
condition - stop condition
Returns:
result of integration
Throws:
IntegrationFailedException - if an integration error occurs

integrateByPoints

public IntegrationResult integrateByPoints(I integrand,
                                           long evals)
                                    throws IntegrationFailedException
Convenience method for integration until the specified number of evaluations has been reached. Calls integrate(integrand, condition, null) with StopConditions.UntilCallsReached as condition. For some integrators the number of evaluations may exceed the requested number, but it will never be less than it.

Parameters:
integrand - object to be integrated
evals - number of function evaluations
Returns:
result of the integration
Throws:
IntegrationFailedException - if an integration error occurs

integrateByPoints

public IntegrationResult integrateByPoints(I integrand,
                                           long evals,
                                           java.util.List<Visualizer> visualizers)
                                    throws IntegrationFailedException
Convenience method for integration with visualizers until the specified number of evaluations has been reached. Calls integrate(integrand, condition, null) with StopConditions.UntilCallsReached as condition. For some integrators the number of evaluations may exceed the requested number, but it will never be less than it.

Parameters:
integrand - object to be integrated
evals - number of evaluations
Returns:
result of the integration
Throws:
IntegrationFailedException - if an integration error occurs

integrateAbsTol

public IntegrationResult integrateAbsTol(I integrand,
                                         double absoluteTolerance)
                                  throws IntegrationFailedException
Convenience method for integration until the absolute estimated error is less than than the specified threshold. Calls integrate(I, StopCondition) with StopConditions.UntilAbsTol as condition. Performs numerical integration of the integrand until

Parameters:
integrand - object to be integrated
absoluteTolerance - absolute tolerance to be reached
Returns:
result of the integration
Throws:
IntegrationFailedException - if an integration error occurs

integrateAbsTol

public IntegrationResult integrateAbsTol(I integrand,
                                         double absoluteTolerance,
                                         java.util.List<Visualizer> visualizers)
                                  throws IntegrationFailedException
Convenience method for integration with visualizers until the absolute estimated error is less than than the specified threshold. Calls integrate(I, StopCondition, List) with StopConditions.UntilAbsTol as condition. Performs numerical integration of the integrand until

Parameters:
integrand - object to be integrated
absoluteTolerance - absolute tolerance to be reached
visualizers - list of visualizers or null for no visualization
Returns:
result of the integration
Throws:
IntegrationFailedException - if an integration error occurs

integrateRelTol

public IntegrationResult integrateRelTol(I integrand,
                                         double relativeTolerance)
                                  throws IntegrationFailedException
Convenience method for integration until the absolute estimated error is less than than the specified threshold. Calls integrate(I, StopCondition) with StopConditions.UntilRelTol as condition. Performs numerical integration of the integrand until

Parameters:
integrand - object to be integrated
relativeTolerance - absolute tolerance to be reached
Returns:
result of the integration
Throws:
IntegrationFailedException - if an integration error occurs

integrateRelTol

public IntegrationResult integrateRelTol(I integrand,
                                         double relativeTolerance,
                                         java.util.List<Visualizer> visualizers)
                                  throws IntegrationFailedException
Convenience method for integration with visualizers until the relative estimated error is less than than the specified threshold. Calls integrate(I, StopCondition) with StopConditions.UntilRelTol as condition. Performs numerical integration of the integrand until

Parameters:
integrand - object to be integrated
relativeTolerance - absolute tolerance to be reached
visualizers - list of visualizers or null for no visualization
Returns:
result of the integration
Throws:
IntegrationFailedException - if an integration error occurs