Refactoring foo
This commit is contained in:
parent
117284ace5
commit
945889dcaf
@ -627,9 +627,9 @@ public class OptimizerFactory {
|
||||
if (params != null) {
|
||||
opt = new OptimizerRunnable(params, outputFilePrefix);
|
||||
if (terminator != null) {
|
||||
opt.getGOParams().setTerminator(terminator);
|
||||
opt.getOptimizationParameters().setTerminator(terminator);
|
||||
} else {
|
||||
opt.getGOParams().setTerminator(getTerminator());
|
||||
opt.getOptimizationParameters().setTerminator(getTerminator());
|
||||
}
|
||||
}
|
||||
return opt;
|
||||
|
@ -42,7 +42,7 @@ public class OptimizerRunnable implements Runnable {
|
||||
* @param params
|
||||
* @param outputFilePrefix
|
||||
*/
|
||||
public OptimizerRunnable(OptimizationParameters params, String outputFilePrefix) {
|
||||
public OptimizerRunnable(InterfaceOptimizationParameters params, String outputFilePrefix) {
|
||||
this(params, outputFilePrefix, false);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ public class OptimizerRunnable implements Runnable {
|
||||
* @param params
|
||||
* @param restart
|
||||
*/
|
||||
public OptimizerRunnable(OptimizationParameters params, boolean restart) {
|
||||
public OptimizerRunnable(InterfaceOptimizationParameters params, boolean restart) {
|
||||
this(params, new StatisticsDummy(), restart);
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ public class OptimizerRunnable implements Runnable {
|
||||
* @param outputFilePrefix
|
||||
* @param restart
|
||||
*/
|
||||
public OptimizerRunnable(OptimizationParameters params, String outputFilePrefix, boolean restart) {
|
||||
public OptimizerRunnable(InterfaceOptimizationParameters params, String outputFilePrefix, boolean restart) {
|
||||
this(params, new StatisticsStandalone(outputFilePrefix), restart);
|
||||
}
|
||||
|
||||
@ -75,10 +75,10 @@ public class OptimizerRunnable implements Runnable {
|
||||
* If restart is true, the processor will not reinitialize the population allowing search on predefined populations.
|
||||
*
|
||||
* @param params
|
||||
* @param outputFilePrefix
|
||||
* @param stats
|
||||
* @param restart
|
||||
*/
|
||||
public OptimizerRunnable(OptimizationParameters params, InterfaceStatistics stats, boolean restart) {
|
||||
public OptimizerRunnable(InterfaceOptimizationParameters params, InterfaceStatistics stats, boolean restart) {
|
||||
rnblID = cntID;
|
||||
cntID++;
|
||||
|
||||
@ -106,7 +106,7 @@ public class OptimizerRunnable implements Runnable {
|
||||
return rnblID;
|
||||
}
|
||||
|
||||
public InterfaceOptimizationParameters getGOParams() {
|
||||
public InterfaceOptimizationParameters getOptimizationParameters() {
|
||||
return proc.getOptimizationParameters();
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ public class OptimizerRunnable implements Runnable {
|
||||
return proc.getStatistics();
|
||||
}
|
||||
|
||||
public void setStats(InterfaceStatistics stats) {
|
||||
public void setStatistics(InterfaceStatistics stats) {
|
||||
if (proc.isOptimizationRunning()) {
|
||||
throw new RuntimeException("Error - cannot change statistics instance during optimization.");
|
||||
}
|
||||
|
@ -813,11 +813,11 @@ public class PostProcess {
|
||||
* Just execute the runnable.
|
||||
*/
|
||||
private static void runPP(OptimizerRunnable rnbl) {
|
||||
rnbl.getGOParams().setDoPostProcessing(false);
|
||||
rnbl.getOptimizationParameters().setDoPostProcessing(false);
|
||||
rnbl.setVerbosityLevel(StatisticsParameter.VERBOSITY_NONE);
|
||||
ppRunnables.add(rnbl);
|
||||
rnbl.run();
|
||||
rnbl.getGOParams().setDoPostProcessing(true);
|
||||
rnbl.getOptimizationParameters().setDoPostProcessing(true);
|
||||
ppRunnables.remove(rnbl);
|
||||
}
|
||||
|
||||
@ -901,7 +901,7 @@ public class PostProcess {
|
||||
InterfaceMultimodalProblemKnown mmp = (InterfaceMultimodalProblemKnown) problem;
|
||||
OptimizerRunnable runnable = OptimizerFactory.getOptRunnable(OptimizerFactory.STD_GA, problem, 100, null);
|
||||
runnable.run();
|
||||
Population pop = runnable.getGOParams().getOptimizer().getPopulation();
|
||||
Population pop = runnable.getOptimizationParameters().getOptimizer().getPopulation();
|
||||
Population found = getFoundOptima(pop, mmp.getRealOptima(), 0.05, true);
|
||||
System.out.println("all found (" + found.size() + "): " + BeanInspector.toString(found));
|
||||
|
||||
|
@ -253,7 +253,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
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
|
||||
// store the initial graph selection state, so that modifications during runtime cannot cause inconsistencies
|
||||
lastFieldSelection = (StringSelection) statisticsParameter.getFieldSelection().clone();
|
||||
lastIsShowFull = statisticsParameter.isOutputAllFieldsAsText();
|
||||
|
||||
@ -305,20 +305,19 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
if (printRunIntroVerbosity()) {
|
||||
printToTextListener("\n****** Multirun " + runNumber);
|
||||
}
|
||||
/*
|
||||
ToDo: Figure out if we need this. Right now it is just spamming the text output
|
||||
if (params != null) {
|
||||
if (printRunIntroVerbosity()) {
|
||||
printToTextListener("\nModule parameters: ");
|
||||
}
|
||||
if (printRunIntroVerbosity()) {
|
||||
printToTextListener("\nOptimization parameters: ");
|
||||
printToTextListener(BeanInspector.niceToString(params));
|
||||
}
|
||||
}
|
||||
if (printRunIntroVerbosity()) {
|
||||
printToTextListener("\nStatistics parameters: ");
|
||||
}
|
||||
if (printRunIntroVerbosity()) {
|
||||
printToTextListener(BeanInspector.niceToString(getStatisticsParameter()) + '\n');
|
||||
}
|
||||
*/
|
||||
functionCalls = 0;
|
||||
fireDataListenersStartStop(runNumber, true, true);
|
||||
}
|
||||
@ -326,7 +325,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
@Override
|
||||
public void stopOptimizationPerformed(boolean normal, String stopMessage) {
|
||||
if (lastSols == null) {
|
||||
System.err.println("WARNING, possibly there was no call to createNextGenerationPerformed before calling stopOptimizationPerformed (AnstractStatistics).");
|
||||
System.err.println("WARNING, possibly there was no call to createNextGenerationPerformed before calling stopOptimizationPerformed (AbstractStatistics).");
|
||||
}
|
||||
|
||||
if (iterationCounter < sumDataCollection.size()) {
|
||||
|
@ -366,7 +366,7 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
|
||||
runnable.setOutputFullStatsToText(outputAllStatsField);
|
||||
|
||||
if (seedPopulation != null) {
|
||||
runnable.getGOParams().getOptimizer().setPopulation(seedPopulation);
|
||||
runnable.getOptimizationParameters().getOptimizer().setPopulation(seedPopulation);
|
||||
runnable.setDoRestart(true);
|
||||
log("Setting seed population of size " + seedPopulation.size() + ", target size " + seedPopulation.getTargetSize() + "\n");
|
||||
log(BeanInspector.toString(seedPopulation.getStringRepresentation()) + "\n");
|
||||
@ -378,7 +378,7 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
|
||||
System.err.println("mismatching value list for parameter arguments: " + specValues);
|
||||
} else {
|
||||
log("setting specific parameters...\n");
|
||||
InterfaceOptimizer opt = runnable.getGOParams().getOptimizer();
|
||||
InterfaceOptimizer opt = runnable.getOptimizationParameters().getOptimizer();
|
||||
for (int i = 0; i < specParams.length; i++) { // loop over settings
|
||||
log("try setting " + specParams[i] + " to " + specValues[i]);
|
||||
String paramName = null;
|
||||
@ -481,7 +481,7 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
|
||||
if (runnable == null) {
|
||||
return 0;
|
||||
}
|
||||
return runnable.getGOParams().getOptimizer().getPopulation().getFunctionCalls();
|
||||
return runnable.getOptimizationParameters().getOptimizer().getPopulation().getFunctionCalls();
|
||||
}
|
||||
|
||||
void exportResultPopulationToMatlab(Population pop) {
|
||||
|
@ -37,7 +37,7 @@ class WaitForEvARunnable implements Runnable {
|
||||
try {
|
||||
mp.log("runnable.getDoubleSolution: " + BeanInspector.toString(runnable.getDoubleSolution()) + "\n");
|
||||
mp.log("runnable.getIntegerSolution: " + BeanInspector.toString(runnable.getIntegerSolution()) + "\n");
|
||||
mp.log("getAllSols best: " + AbstractEAIndividual.getDefaultDataString(runnable.getGOParams().getOptimizer().getAllSolutions().getSolutions().getBestEAIndividual()) + "\n");
|
||||
mp.log("getAllSols best: " + AbstractEAIndividual.getDefaultDataString(runnable.getOptimizationParameters().getOptimizer().getAllSolutions().getSolutions().getBestEAIndividual()) + "\n");
|
||||
mp.log("\n");
|
||||
// write results back to matlab
|
||||
mp.exportResultToMatlab(runnable);
|
||||
|
Loading…
x
Reference in New Issue
Block a user