public Improvement findIncrementalImprovement(Optimizee optimizee, double jumpSize,
Improvement lastImprovement, Set<ParameterArray> cache) {
int maxTries = 1000;
int numTries = 0;
double fitnessDelta;
Improvement improvement = new Improvement(this, 0, jumpSize);
do {
PermutedParameterArray nbr = getRandomNeighbor(jumpSize);
fitnessDelta = 0;
if (!cache.contains(nbr)) {
cache.add(nbr);
if (optimizee.evaluateByComparison()) {
fitnessDelta = optimizee.compareFitness(nbr, this);
} else {
double fitness = optimizee.evaluateFitness(nbr);
fitnessDelta = fitness - getFitness();
nbr.setFitness(fitness);
}
if (fitnessDelta > 0) {
improvement = new Improvement(nbr, fitnessDelta, jumpSize);
}
}
numTries++;
} while (fitnessDelta <= 0 && numTries < maxTries);