diff --git a/src/eva2/server/stat/AbstractStatistics.java b/src/eva2/server/stat/AbstractStatistics.java index 064a5af7..5864b94c 100644 --- a/src/eva2/server/stat/AbstractStatistics.java +++ b/src/eva2/server/stat/AbstractStatistics.java @@ -61,6 +61,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter */ private boolean refineMultiRuns = true; // private ArrayList meanCollection; + private ArrayList finalObjectData; private ArrayList sumDataCollection; // collect summed-up data of multiple runs indexed per iteration protected Object[] currentStatObjectData = null; // the raw Object data collected in an iteration protected Double[] currentStatDoubleData = null; // the parsed doubles collected in an iteration (or null for complex data fields) @@ -140,13 +141,16 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter * Notify listeners on the start and stop of a run. * * @param runNumber current run (started or stopped) - * @param normal in case of stop: the stop was terminated normally (as opposted to manually) + * @param normal in case of stop: the stop was terminated normally (as opposed to manually) * @param start if true, give the start signal, otherwise the stop signal */ private void fireDataListenersStartStop(int runNumber, boolean normal, boolean start) { if (dataListeners!=null) for (InterfaceStatisticsListener l : dataListeners) { if (start) l.notifyRunStarted(runNumber, m_StatsParams.getMultiRuns()); - else l.notifyRunStopped(optRunsPerformed, normal); + else { + l.notifyRunStopped(optRunsPerformed, normal); + if (optRunsPerformed>1) l.finalMultiRunResults(currentHeaderData, finalObjectData); + } } } @@ -245,6 +249,8 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter if (refineMultiRuns) sumDataCollection = new ArrayList(); else sumDataCollection = null; + finalObjectData = null; + statDataSumOverAll = null; // lastAdditionalInfoSums = null; feasibleFoundAfterSum=-1; @@ -327,6 +333,9 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter } } } + if (finalObjectData==null) finalObjectData = new ArrayList(); + finalObjectData.add(currentStatObjectData); + if (printFinalVerbosity()) printToTextListener("."); // if (currentBestFit!= null) { // if (printRunStoppedVerbosity()) printToTextListener(" Best Fitness: " + BeanInspector.toString(currentBestFit) + "\n"); @@ -426,6 +435,13 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter for (int i=0; i addData = getOutputData(informerList, lastSols); +// System.out.println("lastSols size: " + 500*PSymbolicRegression.getAvgIndySize(lastSols)); +// System.out.println("Mem use: " + getMemoryUse()); Pair addData = getOutputData(informerList, lastSols); if (doTextOutput()) { // this is where the text output is actually written if (printLineByVerbosity(iterationCounter)) { diff --git a/src/eva2/server/stat/InterfaceStatistics.java b/src/eva2/server/stat/InterfaceStatistics.java index e0c0095e..222dadc0 100644 --- a/src/eva2/server/stat/InterfaceStatistics.java +++ b/src/eva2/server/stat/InterfaceStatistics.java @@ -33,6 +33,8 @@ public interface InterfaceStatistics { * Finalize statistics computations. */ public void stopOptPerformed(boolean normal, String stopMessage); // called from processor + public void addDataListener(InterfaceStatisticsListener listener); + public boolean removeDataListener(InterfaceStatisticsListener listener); public void addTextListener(InterfaceTextListener listener); public boolean removeTextListener(InterfaceTextListener listener); public void printToTextListener(String s); diff --git a/src/eva2/server/stat/InterfaceStatisticsListener.java b/src/eva2/server/stat/InterfaceStatisticsListener.java index 826c94ed..025bf9c8 100644 --- a/src/eva2/server/stat/InterfaceStatisticsListener.java +++ b/src/eva2/server/stat/InterfaceStatisticsListener.java @@ -1,9 +1,12 @@ package eva2.server.stat; +import java.util.List; + /** * An interface to listen to statistical data of an optimization run. * * @see AbstractStatistics + * @see InterfaceStatisticsParameter * @author mkron * */ @@ -33,4 +36,15 @@ public interface InterfaceStatisticsListener { * @param completedLastRun true, if the last run was stopped normally, otherwise false, e.g. indicating a user break */ public void notifyRunStopped(int runsPerformed, boolean completedLastRun); + + /** + * Receive the list of last data lines for a set of multiruns. The data list may be null if no runs were + * performed or no data was collected. The method will only be called if a multi-run experiment was performed. + * + * @see InterfaceStatisticsParameter + * @see AbstractStatistics + * @param header + * @param multiRunFinalObjectData + */ + public void finalMultiRunResults(String[] header, List multiRunFinalObjectData); } diff --git a/src/eva2/server/stat/StatisticsDummy.java b/src/eva2/server/stat/StatisticsDummy.java index 543b3555..52b03071 100644 --- a/src/eva2/server/stat/StatisticsDummy.java +++ b/src/eva2/server/stat/StatisticsDummy.java @@ -93,4 +93,12 @@ public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListen if (consoleOut) System.out.println(str); } + public void addDataListener(InterfaceStatisticsListener l) { + System.err.println("addDataListener not provided!"); + } + + public boolean removeDataListener(InterfaceStatisticsListener l) { + System.err.println("removeDataListener not provided!"); + return false; + } } diff --git a/src/eva2/server/stat/StatisticsWithGUI.java b/src/eva2/server/stat/StatisticsWithGUI.java index 0d25325a..9439c99e 100644 --- a/src/eva2/server/stat/StatisticsWithGUI.java +++ b/src/eva2/server/stat/StatisticsWithGUI.java @@ -37,7 +37,8 @@ import eva2.tools.jproxy.RMIProxyRemote; /** * A statistics class to plot fitness curves in client-server mode. Mainly, arrays of GraphWindows * and Graphs are managed and the selected data fields are plotted. - * + * TODO: this could finally be cleanly reduced to an InterfaceStatisticsListener - without inheriting + * from AbstractStatistics. */ public class StatisticsWithGUI extends AbstractStatistics implements Serializable, InterfaceStatistics { private static final long serialVersionUID = 3213603978877954103L;