public Tuple<Double, DoubleVector> call() throws Exception {
// loop over all particles and calculate new positions
for (int particleIndex = range.getStart(); particleIndex < range.getEnd(); particleIndex++) {
DoubleVector currentPosition = particlePositions[particleIndex];
DoubleVector currentBest = particlePersonalBestPositions[particleIndex];
DenseDoubleVector vec = new DenseDoubleVector(dim);
for (int index = 0; index < vec.getDimension(); index++) {
double value = (phi * currentPosition.get(index)) // inertia
+ (alpha * random.nextDouble() * (currentBest.get(index) - currentPosition
.get(index))) // personal memory
+ (beta * random.nextDouble() * (globalBestPosition.get(index) - currentPosition
.get(index))); // group memory
vec.set(index, value);
}
particlePositions[particleIndex] = vec;
double cost = f.evaluateCost(vec).getCost();
// check if we have a personal best
if (cost < particlePersonalBestCost[particleIndex]) {