diff --git a/src/eva2/optimization/modules/AbstractModuleAdapter.java b/src/eva2/optimization/modules/AbstractModuleAdapter.java index cd0f52cd..b0026a41 100644 --- a/src/eva2/optimization/modules/AbstractModuleAdapter.java +++ b/src/eva2/optimization/modules/AbstractModuleAdapter.java @@ -108,7 +108,7 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab public void setOptimizationParameters(InterfaceOptimizationParameters goParams) { if ((processor != null) && (processor instanceof Processor)) { - ((Processor) processor).setGOParams(goParams); + ((Processor) processor).setOptimizationParameters(goParams); } } diff --git a/src/eva2/optimization/modules/Processor.java b/src/eva2/optimization/modules/Processor.java index a182c2bc..d32277e3 100644 --- a/src/eva2/optimization/modules/Processor.java +++ b/src/eva2/optimization/modules/Processor.java @@ -230,6 +230,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo String popLog = null; //"populationLog.txt"; 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()); this.optimizationParameters.getProblem().initializeProblem(); @@ -240,7 +241,6 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo this.optimizationParameters.getOptimizer().init(); } - //statistics.createNextGenerationPerformed((PopulationInterface)this.m_ModulParameter.getOptimizer().getPopulation()); if (optimizationStateListener != null) { optimizationStateListener.updateProgress(getStatusPercent(optimizationParameters.getOptimizer().getPopulation(), runCounter, statistics.getStatisticsParameter().getMultiRuns()), null); } @@ -257,8 +257,8 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo if (popLog != null) { EVAHELP.logString(this.optimizationParameters.getOptimizer().getPopulation().getIndyList(), popLog); } - } - while (isOptimizationRunning() && !this.optimizationParameters.getTerminator().isTerminated(this.optimizationParameters.getOptimizer().getAllSolutions())); + } while (isOptimizationRunning() && !this.optimizationParameters.getTerminator().isTerminated(this.optimizationParameters.getOptimizer().getAllSolutions())); + runCounter++; maybeFinishParamCtrl(optimizationParameters); userAborted = !isOptimizationRunning(); // stop is "normal" if opt wasnt set false by the user (and thus still true) @@ -403,33 +403,12 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo return informerList; } - /** - * This method writes Data to file. - * - * @param line The line that is to be added to the file - */ -// private void writeToFile(String line) { -// //String write = line + "\n"; -// if (this.m_OutputFile == null) return; -// try { -// this.m_OutputFile.write(line, 0, line.length()); -// this.m_OutputFile.write('\n'); -// this.m_OutputFile.flush(); -// } catch (IOException e) { -// System.err.println("Problems writing to output file!"); -// } -// } @Override public String getInfoString() { //StringBuffer sb = new StringBuffer("processing "); StringBuilder sb = new StringBuilder(this.optimizationParameters.getProblem().getName()); sb.append("+"); sb.append(this.optimizationParameters.getOptimizer().getName()); - // commented out because the number of multi-runs can be changed after start - // so it might create misinformation (would still be the user's fault, though) -// sb.append(" for "); -// sb.append(statistics.getStatistisParameter().getMultiRuns()); -// sb.append(" runs"); return sb.toString(); } @@ -447,11 +426,11 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo return optimizationParameters; } - public void setGOParams(InterfaceOptimizationParameters params) { + public void setOptimizationParameters(InterfaceOptimizationParameters params) { if (params != null) { optimizationParameters = params; } else { - System.err.println("Setting parameters failed (parameters were null) (Processor.setGOParams)"); + System.err.println("Setting parameters failed (parameters were null) (Processor.setOptimizationParameters)"); } } @@ -487,16 +466,8 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo } Population resultPop = (Population) (optimizationParameters.getOptimizer().getAllSolutions().getSolutions().clone()); if (resultPop.getFunctionCalls() != optimizationParameters.getOptimizer().getPopulation().getFunctionCalls()) { - // System.err.println("bad case in Processor::performNewPostProcessing "); resultPop.setFunctionCalls(optimizationParameters.getOptimizer().getPopulation().getFunctionCalls()); } -// if (!resultPop.contains(statistics.getBestSolution())) { -// resultPop.add(statistics.getBestSolution()); - // this is a minor cheat but guarantees that the best solution ever found is contained in the final results - // This was evil in case multiple runs were performed with PP, because the best of an earlier run is added which is confusing. - // the minor cheat should not be necessary anymore anyways, since the getAllSolutions() variant replaced the earlier getPopulation() call -// resultPop.synchSize(); -// } PostProcess.checkAccuracy((AbstractOptimizationProblem) optimizationParameters.getProblem(), resultPop, ppp.getAccuracies(), ppp.getAccAssumeConv(), -1, ppp.getAccMaxEval(), (SolutionHistogram[]) null, true, listener); diff --git a/src/eva2/optimization/stat/AbstractStatistics.java b/src/eva2/optimization/stat/AbstractStatistics.java index efdafe5d..47647651 100644 --- a/src/eva2/optimization/stat/AbstractStatistics.java +++ b/src/eva2/optimization/stat/AbstractStatistics.java @@ -219,7 +219,6 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter System.out.println("Error: " + e); } resultOut.println("StartDate:" + startDate); - resultOut.println("On Host:" + getHostName()); } else { resultOut = null; } @@ -652,34 +651,8 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter sbuf.append("\n"); } } - -// double[][] mean; -// StringBuffer sbuf = new StringBuffer("Iteration\tFun.Calls\tBest\tMean\tWorst\n"); -// double step = result.size()/(iterationsToShow-1.); -// int printedIteration=0; -// -// for(int i = 1; i < result.size()+1; i++) { -// // print the first, last and intermediate iterations requested by the integer parameter -// // first one is printed always, as printedIteration=0 -// if ((i==result.size()) || ((i-1)==Math.round(printedIteration*step))) { -// printedIteration++; -// mean = result.get(i-1); -// sbuf.append(i); -// sbuf.append("\t"); -// sbuf.append(BeanInspector.toString(mean[0])); -// sbuf.append("\t"); -// sbuf.append(BeanInspector.toString(mean[1])); -// sbuf.append("\t"); -// sbuf.append(BeanInspector.toString(mean[2])); -// sbuf.append("\t"); -// sbuf.append(BeanInspector.toString(mean[3])); -// sbuf.append("\n"); -// } -// } -// return sbuf.toString(); } - public abstract String getHostName(); @Override public void printToTextListener(String s) { diff --git a/src/eva2/optimization/stat/InterfaceStatisticsParameter.java b/src/eva2/optimization/stat/InterfaceStatisticsParameter.java index a7cff48d..33220d51 100644 --- a/src/eva2/optimization/stat/InterfaceStatisticsParameter.java +++ b/src/eva2/optimization/stat/InterfaceStatisticsParameter.java @@ -6,7 +6,7 @@ import eva2.tools.StringSelection; /** * An interface to encapsulate statistics parameters. * - * @see StatsParameter + * @see StatisticsParameter */ public interface InterfaceStatisticsParameter { String getName(); diff --git a/src/eva2/optimization/stat/StatisticsParameter.java b/src/eva2/optimization/stat/StatisticsParameter.java index 2701cd9c..4b6afc14 100644 --- a/src/eva2/optimization/stat/StatisticsParameter.java +++ b/src/eva2/optimization/stat/StatisticsParameter.java @@ -44,12 +44,12 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf SelectedTag outputTo = new SelectedTag("File (current dir.)", "Text-window", "Both file and text-window"); private int verboK = 10; private int m_Textoutput = 0; - private int m_MultiRuns = 1; - private String m_ResultFilePrefix = "EvA2"; + private int multiRuns = 1; + private String resultFilePrefix = "EvA2"; protected String m_Name = "not defined"; - private boolean m_useStatPlot = true; + private boolean useStatPlot = true; private boolean showAdditionalProblemInfo = false; - private double m_ConvergenceRateThreshold = 0.001; + private double convergenceRateThreshold = 0.001; private StringSelection graphSel = new StringSelection(GraphSelectionEnum.currentBest, GraphSelectionEnum.getInfoStrings()); /** @@ -97,7 +97,7 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf */ @Override public String toString() { - String ret = "\r\nStatisticsParameter (" + super.toString() + "):\r\nm_MultiRuns=" + m_MultiRuns + String ret = "\r\nStatisticsParameter (" + super.toString() + "):\r\nmultiRuns=" + multiRuns + ", m_Textoutput=" + m_Textoutput + // ", m_Plotoutput=" + m_Plotoutput + ", verbosity= " + outputVerbosity.getSelectedString() @@ -123,13 +123,13 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf * */ private StatisticsParameter(StatisticsParameter Source) { - m_ConvergenceRateThreshold = Source.m_ConvergenceRateThreshold; - m_useStatPlot = Source.m_useStatPlot; + convergenceRateThreshold = Source.convergenceRateThreshold; + useStatPlot = Source.useStatPlot; m_Textoutput = Source.m_Textoutput; // m_Plotoutput = Source.m_Plotoutput; // m_PlotFitness = Source.m_PlotFitness; - m_MultiRuns = Source.m_MultiRuns; - m_ResultFilePrefix = Source.m_ResultFilePrefix; + multiRuns = Source.multiRuns; + resultFilePrefix = Source.resultFilePrefix; verboK = Source.verboK; } @@ -153,7 +153,7 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf */ @Override public void setMultiRuns(int x) { - m_MultiRuns = x; + multiRuns = x; } /** @@ -161,7 +161,7 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf */ @Override public int getMultiRuns() { - return m_MultiRuns; + return multiRuns; } /** @@ -184,7 +184,7 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf */ @Override public boolean getUseStatPlot() { - return m_useStatPlot; + return useStatPlot; } /** @@ -192,7 +192,7 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf */ @Override public void setUseStatPlot(boolean x) { - m_useStatPlot = x; + useStatPlot = x; } public String useStatPlotTipText() { @@ -205,9 +205,9 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf @Override public void setResultFilePrefix(String x) { if (x == null) { - m_ResultFilePrefix = ""; + resultFilePrefix = ""; } else { - m_ResultFilePrefix = x; + resultFilePrefix = x; } } @@ -216,7 +216,7 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf */ @Override public String getResultFilePrefix() { - return m_ResultFilePrefix; + return resultFilePrefix; } @Override @@ -250,7 +250,7 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf */ @Override public void setConvergenceRateThreshold(double x) { - m_ConvergenceRateThreshold = x; + convergenceRateThreshold = x; } /** @@ -258,7 +258,7 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf */ @Override public double getConvergenceRateThreshold() { - return m_ConvergenceRateThreshold; + return convergenceRateThreshold; } @Override diff --git a/src/eva2/optimization/stat/StatisticsWithGUI.java b/src/eva2/optimization/stat/StatisticsWithGUI.java index 0f475c75..79f3e925 100644 --- a/src/eva2/optimization/stat/StatisticsWithGUI.java +++ b/src/eva2/optimization/stat/StatisticsWithGUI.java @@ -267,9 +267,4 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl } // } } - - @Override - public String getHostName() { - return hostName; - } } \ No newline at end of file