@Override
public IntegrationResult integrate(Evaluator evaluator, StopCondition condition, List<Visualizer> visualizers) throws IntegrationFailedException {
int dimension = evaluator.dimension();
if (dimension == 0) {
throw new IntegrationFailedException("Cannot integrate integrands with indefinite dimension");
}
SparseResult result = new SparseResult();
Queue<IndexData> queue = new PriorityQueue<IndexData>();
Map<Index, IndexData> indexMap = new HashMap<Index, IndexData>();
Visualizers.submitToList(visualizers, new Integrand(evaluator));
Visualizers.submitToList(visualizers, new StartIntegration());
Index zeroIndex = new FastIndex();
if (! condition.stop(result)) {
IndexData indexData = evaluateIndex(zeroIndex, evaluator, result, visualizers);
indexMap.put(zeroIndex, indexData);
indexData.priority = 0.0;
queue.add(indexData);
}
while (! condition.stop(result)) {
if(queue.isEmpty()) {
throw new IntegrationFailedException("Index queue is empty");
}
IndexData indexData = queue.poll();
Index index = indexData.index;