Minor update to stats: InterfaceStatistics, InterfaceStatisticsListener
This commit is contained in:
parent
6c277c5960
commit
bb980caca8
@ -61,6 +61,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
|||||||
*/
|
*/
|
||||||
private boolean refineMultiRuns = true;
|
private boolean refineMultiRuns = true;
|
||||||
// private ArrayList<double[][]> meanCollection;
|
// private ArrayList<double[][]> meanCollection;
|
||||||
|
private ArrayList<Object[]> finalObjectData;
|
||||||
private ArrayList<Double[]> sumDataCollection; // collect summed-up data of multiple runs indexed per iteration
|
private ArrayList<Double[]> sumDataCollection; // collect summed-up data of multiple runs indexed per iteration
|
||||||
protected Object[] currentStatObjectData = null; // the raw Object data collected in an 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)
|
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.
|
* Notify listeners on the start and stop of a run.
|
||||||
*
|
*
|
||||||
* @param runNumber current run (started or stopped)
|
* @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
|
* @param start if true, give the start signal, otherwise the stop signal
|
||||||
*/
|
*/
|
||||||
private void fireDataListenersStartStop(int runNumber, boolean normal, boolean start) {
|
private void fireDataListenersStartStop(int runNumber, boolean normal, boolean start) {
|
||||||
if (dataListeners!=null) for (InterfaceStatisticsListener l : dataListeners) {
|
if (dataListeners!=null) for (InterfaceStatisticsListener l : dataListeners) {
|
||||||
if (start) l.notifyRunStarted(runNumber, m_StatsParams.getMultiRuns());
|
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<Double[]>();
|
if (refineMultiRuns) sumDataCollection = new ArrayList<Double[]>();
|
||||||
else sumDataCollection = null;
|
else sumDataCollection = null;
|
||||||
|
|
||||||
|
finalObjectData = null;
|
||||||
|
|
||||||
statDataSumOverAll = null;
|
statDataSumOverAll = null;
|
||||||
// lastAdditionalInfoSums = null;
|
// lastAdditionalInfoSums = null;
|
||||||
feasibleFoundAfterSum=-1;
|
feasibleFoundAfterSum=-1;
|
||||||
@ -327,6 +333,9 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (finalObjectData==null) finalObjectData = new ArrayList<Object[]>();
|
||||||
|
finalObjectData.add(currentStatObjectData);
|
||||||
|
|
||||||
if (printFinalVerbosity()) printToTextListener(".");
|
if (printFinalVerbosity()) printToTextListener(".");
|
||||||
// if (currentBestFit!= null) {
|
// if (currentBestFit!= null) {
|
||||||
// if (printRunStoppedVerbosity()) printToTextListener(" Best Fitness: " + BeanInspector.toString(currentBestFit) + "\n");
|
// 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<sumDataCollection.size(); i++) divideMean(sumDataCollection.get(i), optRunsPerformed);
|
for (int i=0; i<sumDataCollection.size(); i++) divideMean(sumDataCollection.get(i), optRunsPerformed);
|
||||||
if (printFinalVerbosity()) printToTextListener(refineToText(sumDataCollection, showAvgIntervals));
|
if (printFinalVerbosity()) printToTextListener(refineToText(sumDataCollection, showAvgIntervals));
|
||||||
}
|
}
|
||||||
|
if (printFinalVerbosity() && (finalObjectData!=null)) {
|
||||||
|
printToTextListener(" Last data line of " + finalObjectData.size() + " multi-runs:\n" );
|
||||||
|
for (int i=0; i<finalObjectData.size(); i++) {
|
||||||
|
printToTextListener(BeanInspector.toString(finalObjectData.get(i)));
|
||||||
|
printToTextListener("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TRACE)
|
if (TRACE)
|
||||||
@ -956,6 +972,8 @@ 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);
|
// 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)) {
|
||||||
|
@ -33,6 +33,8 @@ public interface InterfaceStatistics {
|
|||||||
* Finalize statistics computations.
|
* Finalize statistics computations.
|
||||||
*/
|
*/
|
||||||
public void stopOptPerformed(boolean normal, String stopMessage); // called from processor
|
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 void addTextListener(InterfaceTextListener listener);
|
||||||
public boolean removeTextListener(InterfaceTextListener listener);
|
public boolean removeTextListener(InterfaceTextListener listener);
|
||||||
public void printToTextListener(String s);
|
public void printToTextListener(String s);
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package eva2.server.stat;
|
package eva2.server.stat;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface to listen to statistical data of an optimization run.
|
* An interface to listen to statistical data of an optimization run.
|
||||||
*
|
*
|
||||||
* @see AbstractStatistics
|
* @see AbstractStatistics
|
||||||
|
* @see InterfaceStatisticsParameter
|
||||||
* @author mkron
|
* @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
|
* @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);
|
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<Object[]> multiRunFinalObjectData);
|
||||||
}
|
}
|
||||||
|
@ -93,4 +93,12 @@ public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListen
|
|||||||
if (consoleOut) System.out.println(str);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,8 @@ import eva2.tools.jproxy.RMIProxyRemote;
|
|||||||
/**
|
/**
|
||||||
* A statistics class to plot fitness curves in client-server mode. Mainly, arrays of GraphWindows
|
* 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.
|
* 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 {
|
public class StatisticsWithGUI extends AbstractStatistics implements Serializable, InterfaceStatistics {
|
||||||
private static final long serialVersionUID = 3213603978877954103L;
|
private static final long serialVersionUID = 3213603978877954103L;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user