Small cleanup and better documentation.

This commit is contained in:
Fabian Becker 2014-10-26 17:08:01 +01:00
parent ca30e6c705
commit 5bd11e4624
4 changed files with 15 additions and 9 deletions

View File

@ -225,6 +225,10 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
runCounter = 0;
/**
* We keep the optimization running until it is aborted by the user or
* the number of multiple runs has been reached.
*/
while (isOptimizationRunning() && (runCounter < statistics.getStatisticsParameter().getMultiRuns())) {
LOGGER.info(String.format("Starting Optimization %d/%d", runCounter + 1, statistics.getStatisticsParameter().getMultiRuns()));
statistics.startOptimizationPerformed(getInfoString(), runCounter, optimizationParameters, getInformerList());
@ -241,12 +245,16 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
optimizationStateListener.updateProgress(getStatusPercent(optimizationParameters.getOptimizer().getPopulation(), runCounter, statistics.getStatisticsParameter().getMultiRuns()), null);
}
do { // main loop
/**
* This is the main optimization loop. We keep calling
* optimize() until a termination criterion is met or
* the user aborts the optimization manually.
*/
do {
maybeUpdateParamCtrl(optimizationParameters);
this.optimizationParameters.getOptimizer().optimize();
}
while (isOptimizationRunning() && !this.optimizationParameters.getTerminator().isTerminated(this.optimizationParameters.getOptimizer().getAllSolutions()));
} while (isOptimizationRunning() && !this.optimizationParameters.getTerminator().isTerminated(this.optimizationParameters.getOptimizer().getAllSolutions()));
runCounter++;
maybeFinishParamCtrl(optimizationParameters);

View File

@ -696,8 +696,7 @@ public class DifferentialEvolution extends AbstractOptimizer implements java.io.
@Override
public InterfaceSolutionSet getAllSolutions() {
Population pop = getPopulation();
return new SolutionSet(pop, pop);
return new SolutionSet(this.population);
}
/**

View File

@ -110,7 +110,7 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati
/**
* This method evaluates a given population and set the fitness values
* accordingly
* accordingly. It also keeps track of the function call count.
*
* @param population The population that is to be evaluated.
*/
@ -120,7 +120,6 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati
evaluatePopulationStart(population);
if (this.parallelThreads > 1) {
Vector<AbstractEAIndividual> queue = new Vector<>(population.size());
Semaphore sema = new Semaphore(0);
ExecutorService pool = Executors.newFixedThreadPool(parallelThreads);
int cntIndies = 0;

View File

@ -39,8 +39,8 @@ public interface InterfaceOptimizationProblem extends InterfaceAdditionalPopulat
public void initializePopulation(Population population);
/**
* This method evaluates a given population and set the fitness values
* accordingly
* This method evaluates a given population and sets the fitness values
* accordingly. It also keeps track of the function call count.
*
* @param population The population that is to be evaluated.
*/