Some refactoring for proper method names
This commit is contained in:
parent
784a0f4ee5
commit
8200d398fb
@ -273,7 +273,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
|
||||
CommandLine commandLine = null;
|
||||
|
||||
switch(optimizerName) {
|
||||
case "DifferentialEvolution":
|
||||
case "DifferentialEvolution": {
|
||||
System.out.println("DE");
|
||||
opt.addOption("F", true, "Differential Weight");
|
||||
opt.addOption("CR", true, "Crossover Rate");
|
||||
@ -309,10 +309,11 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case "GeneticAlgorithm":
|
||||
System.out.println("Genetic Algorithm");
|
||||
break;
|
||||
case "ParticleSwarmOptimization":
|
||||
case "ParticleSwarmOptimization": {
|
||||
opt.addOption("initialVelocity", true, "Initial Velocity");
|
||||
opt.addOption("speedLimit", true, "Speed Limit");
|
||||
opt.addOption("topology", true, "Particle Swarm Topology (0-7)");
|
||||
@ -323,12 +324,14 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
|
||||
opt.addOption("algType", true, "Type of PSO");
|
||||
|
||||
break;
|
||||
case "EvolutionStrategies":
|
||||
//double cm, cr;
|
||||
//int mu, lambda;
|
||||
}
|
||||
case "EvolutionStrategies": {
|
||||
double cm, cr;
|
||||
int mu, lambda;
|
||||
boolean plusStrategy;
|
||||
//this.optimizer = OptimizerFactory.createEvolutionStrategy()
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new Exception("Unsupported Optimizer");
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
} catch (Exception ex) {
|
||||
} catch (Error error) {
|
||||
}
|
||||
//statistics.stopOptPerformed(false);
|
||||
//statistics.stopOptimizationPerformed(false);
|
||||
setOptimizationRunning(false); // normal finish
|
||||
if (optimizationStateListener != null) {
|
||||
optimizationStateListener.performedStop(); // is only needed in client server mode
|
||||
@ -235,7 +235,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
|
||||
while (isOptimizationRunning() && (runCounter < statistics.getStatisticsParameter().getMultiRuns())) {
|
||||
LOGGER.info(String.format("Starting Optimization %d/%d", runCounter + 1, statistics.getStatisticsParameter().getMultiRuns()));
|
||||
statistics.startOptPerformed(getInfoString(), runCounter, optimizationParameters, getInformerList());
|
||||
statistics.startOptimizationPerformed(getInfoString(), runCounter, optimizationParameters, getInformerList());
|
||||
|
||||
this.optimizationParameters.getProblem().initializeProblem();
|
||||
this.optimizationParameters.getOptimizer().setProblem(this.optimizationParameters.getProblem());
|
||||
@ -268,7 +268,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
maybeFinishParamCtrl(optimizationParameters);
|
||||
userAborted = !isOptimizationRunning(); // stop is "normal" if opt wasnt set false by the user (and thus still true)
|
||||
//////////////// Default stats
|
||||
statistics.stopOptPerformed(!userAborted, optimizationParameters.getTerminator().lastTerminationMessage()); // stop is "normal" if opt wasnt set false by the user (and thus still true)
|
||||
statistics.stopOptimizationPerformed(!userAborted, optimizationParameters.getTerminator().lastTerminationMessage()); // stop is "normal" if opt wasnt set false by the user (and thus still true)
|
||||
|
||||
//////////////// PP or set results without further PP
|
||||
if (!userAborted) {
|
||||
|
@ -21,9 +21,9 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* An abstract class handling statistics. Most important stuff happens in startOptPerformed, stopOptPerformed
|
||||
* and createNextGenerationPerformed. Any measures (run based or multi-run based) are reset in startOptPerformed,
|
||||
* updated per iteration in createNextGenerationPerformed and reported to listeners in stopOptPerformed.
|
||||
* An abstract class handling statistics. Most important stuff happens in startOptimizationPerformed, stopOptimizationPerformed
|
||||
* and createNextGenerationPerformed. Any measures (run based or multi-run based) are reset in startOptimizationPerformed,
|
||||
* updated per iteration in createNextGenerationPerformed and reported to listeners in stopOptimizationPerformed.
|
||||
* Several different verbosity levels are regarded.
|
||||
* The method plotCurrentResults should be implemented to plot further results per iteration.
|
||||
* <p/>
|
||||
@ -39,9 +39,6 @@ import java.util.*;
|
||||
* <p/>
|
||||
* Listeners implementing InterfaceTextListener receive String output (human readable).
|
||||
* Listeners implementing InterfaceStatisticsListener receive the raw data per iteration.
|
||||
*
|
||||
* @author mkron
|
||||
* @see StatsParameter
|
||||
*/
|
||||
public abstract class AbstractStatistics implements InterfaceTextListener, InterfaceStatistics {
|
||||
private transient PrintWriter resultOut;
|
||||
@ -254,7 +251,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startOptPerformed(String infoString, int runNumber, Object params, List<InterfaceAdditionalPopulationInformer> informerList) {
|
||||
public void startOptimizationPerformed(String infoString, int runNumber, Object params, List<InterfaceAdditionalPopulationInformer> informerList) {
|
||||
|
||||
if (runNumber == 0) {
|
||||
// store the intial graph selection state, so that modifications during runtime cannot cause inconsistencies
|
||||
@ -328,9 +325,9 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopOptPerformed(boolean normal, String stopMessage) {
|
||||
public void stopOptimizationPerformed(boolean normal, String stopMessage) {
|
||||
if (lastSols == null) {
|
||||
System.err.println("WARNING, possibly there was no call to createNextGenerationPerformed before calling stopOptPerformed (AnstractStatistics).");
|
||||
System.err.println("WARNING, possibly there was no call to createNextGenerationPerformed before calling stopOptimizationPerformed (AnstractStatistics).");
|
||||
}
|
||||
|
||||
if (iterationCounter < sumDataCollection.size()) {
|
||||
@ -1170,7 +1167,6 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
}
|
||||
if (firstPlot) {
|
||||
initPlots(pop, informerList);
|
||||
// if (doTextOutput()) printToTextListener(getOutputHeader(informer, pop)+'\n');
|
||||
firstPlot = false;
|
||||
currentBestFeasibleFit = null;
|
||||
}
|
||||
@ -1190,13 +1186,9 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
}
|
||||
|
||||
lastSols = (opt != null) ? new Population(opt.getAllSolutions().getSolutions()) : pop;
|
||||
// Pair<String,Double[]> addData = getOutputData(informerList, lastSols);
|
||||
// System.out.println("lastSols size: " + 500*PSymbolicRegression.getAvgIndySize(lastSols));
|
||||
// System.out.println("Mem use: " + getMemoryUse());
|
||||
Pair<String, Object[]> addData = getOutputData(informerList, lastSols);
|
||||
if (doTextOutput()) { // this is where the text output is actually written
|
||||
if (printLineByVerbosity(iterationCounter)) {
|
||||
// printToTextListener(functionCalls + textFieldDelimiter);
|
||||
printToTextListener(addData.head() + '\n');
|
||||
}
|
||||
}
|
||||
|
@ -15,12 +15,12 @@ public interface InterfaceStatistics {
|
||||
/**
|
||||
* Initialize statistics computations.
|
||||
*/
|
||||
void startOptPerformed(String InfoString, int runnumber, Object params, List<InterfaceAdditionalPopulationInformer> informerList); // called from processor
|
||||
void startOptimizationPerformed(String InfoString, int runnumber, Object params, List<InterfaceAdditionalPopulationInformer> informerList); // called from processor
|
||||
|
||||
/**
|
||||
* Finalize statistics computations.
|
||||
*/
|
||||
void stopOptPerformed(boolean normal, String stopMessage); // called from processor
|
||||
void stopOptimizationPerformed(boolean normal, String stopMessage); // called from processor
|
||||
|
||||
void addDataListener(InterfaceStatisticsListener listener);
|
||||
|
||||
|
@ -93,8 +93,8 @@ public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startOptPerformed(String InfoString, int runnumber,
|
||||
Object params, List<InterfaceAdditionalPopulationInformer> informerList) {
|
||||
public void startOptimizationPerformed(String InfoString, int runnumber,
|
||||
Object params, List<InterfaceAdditionalPopulationInformer> informerList) {
|
||||
if (runnumber == 0) {
|
||||
bestIndividualAllover = null;
|
||||
}
|
||||
@ -102,7 +102,7 @@ public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopOptPerformed(boolean normal, String stopMessage) {
|
||||
public void stopOptimizationPerformed(boolean normal, String stopMessage) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,8 +55,8 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public synchronized void startOptPerformed(String infoString, int runNumber, Object goParams, List<InterfaceAdditionalPopulationInformer> informerList) {
|
||||
super.startOptPerformed(infoString, runNumber, goParams, informerList);
|
||||
public synchronized void startOptimizationPerformed(String infoString, int runNumber, Object goParams, List<InterfaceAdditionalPopulationInformer> informerList) {
|
||||
super.startOptimizationPerformed(infoString, runNumber, goParams, informerList);
|
||||
graphInfoString = infoString;
|
||||
|
||||
if ((fitnessFrame != null) && (fitnessFrame[0] != null)) {
|
||||
@ -68,8 +68,8 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopOptPerformed(boolean normal, String stopMessage) {
|
||||
super.stopOptPerformed(normal, stopMessage);
|
||||
public void stopOptimizationPerformed(boolean normal, String stopMessage) {
|
||||
super.stopOptimizationPerformed(normal, stopMessage);
|
||||
|
||||
if (optRunsPerformed > statisticsParameter.getMultiRuns()) {
|
||||
// this may happen if the user reduces the multirun parameter during late multiruns
|
||||
|
Loading…
x
Reference in New Issue
Block a user