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