Merging stats from MK branch
This commit is contained in:
parent
3e8c2b14dc
commit
6403679a8c
@ -94,8 +94,8 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
protected double[] currentMeanFit;
|
||||
protected double[] currentWorstFit;
|
||||
// protected double[] meanBestOfRunFitness;
|
||||
protected double currentAvgPopDist;
|
||||
protected double currentMaxPopDist;
|
||||
protected double currentAvgEucDistInPop, currentMaxEucDistInPop;
|
||||
protected double currentAvgPopDistMetric, currentMaxPopDistMetric;
|
||||
protected IndividualInterface bestCurrentIndy, bestOfRunIndy, bestOfRunFeasibleIndy, bestFeasibleAllRuns, bestIndyAllRuns;
|
||||
|
||||
// collect feasible results of a run
|
||||
@ -353,7 +353,10 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
// if (currentBestFit!= null) {
|
||||
// if (printRunStoppedVerbosity()) printToTextListener(" Best Fitness: " + BeanInspector.toString(currentBestFit) + "\n");
|
||||
// }
|
||||
|
||||
if (optRunsPerformed >= m_StatsParams.getMultiRuns()) {
|
||||
if (printFinalVerbosity()) printToTextListener("\n");
|
||||
finalizeOutput();
|
||||
}
|
||||
fireDataListenersStartStop(optRunsPerformed, normal, false);
|
||||
}
|
||||
|
||||
@ -374,11 +377,11 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
}
|
||||
|
||||
private PopulationInterface makeStatsPop() {
|
||||
Population pop = new Population(4);
|
||||
Population pop = new Population(1);
|
||||
|
||||
if (bestCurrentIndy!=null) pop.add(bestCurrentIndy);
|
||||
if (bestOfRunIndy!=null) pop.add(bestOfRunIndy);
|
||||
if (bestOfRunFeasibleIndy!=null) pop.add(bestOfRunFeasibleIndy);
|
||||
// if (bestCurrentIndy!=null) pop.add(bestCurrentIndy);
|
||||
// if (bestOfRunIndy!=null) pop.add(bestOfRunIndy);
|
||||
// if (bestOfRunFeasibleIndy!=null) pop.add(bestOfRunFeasibleIndy);
|
||||
if (bestIndyAllRuns!=null) pop.add(bestIndyAllRuns);
|
||||
return pop;
|
||||
}
|
||||
@ -757,8 +760,10 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
case runBest: ret[i] = bestOfRunIndy.getFitness()[defaultFitCriterion]; break;
|
||||
case currentBestFeasible: ret[i] = (currentBestFeasibleFit==null) ? Double.NaN : currentBestFeasibleFit[defaultFitCriterion]; break;
|
||||
case runBestFeasible: ret[i] = (bestOfRunFeasibleIndy==null) ? Double.NaN : bestOfRunFeasibleIndy.getFitness()[defaultFitCriterion]; break;
|
||||
case avgPopDistance: ret[i] = currentAvgPopDist; break;
|
||||
case maxPopDistance: ret[i] = currentMaxPopDist; break;
|
||||
case avgEucPopDistance: ret[i] = currentAvgEucDistInPop; break;
|
||||
case maxEucPopDistance: ret[i] = currentMaxEucDistInPop; break;
|
||||
case avgPopMetricDist: ret[i] = currentAvgPopDistMetric; break;
|
||||
case maxPopMetricDist: ret[i] = currentMaxPopDistMetric; break;
|
||||
}
|
||||
}
|
||||
// all standard fields should be filled now
|
||||
@ -819,7 +824,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
*/
|
||||
protected List<String> getAdditionalHeaderMetaInfo(List<InterfaceAdditionalPopulationInformer> informerList, List<String> metaInfo) {
|
||||
LinkedList<String> headers = new LinkedList<String>();
|
||||
if (metaInfo!=null && (metaInfo.size()>0)) System.err.println("Warning, metaInfo list should be empty in AbstractStatistics.getAdditionalInfoInfo");
|
||||
if (metaInfo!=null && (metaInfo.size()>0)) System.err.println("Warning, metaInfo list should be empty in AbstractStatistics.getAdditionalHeaderMetaInfo");
|
||||
for (InterfaceAdditionalPopulationInformer informer : informerList) {
|
||||
headers.addAll(Arrays.asList(informer.getAdditionalDataHeader()));
|
||||
if (metaInfo!=null) metaInfo.addAll(Arrays.asList(informer.getAdditionalDataInfo()));
|
||||
@ -1011,12 +1016,21 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
|
||||
functionCalls = pop.getFunctionCalls();
|
||||
|
||||
if (lastIsShowFull || GraphSelectionEnum.doPlotAvgDist(lastFieldSelection)
|
||||
|| GraphSelectionEnum.doPlotMaxPopDist(lastFieldSelection)) {
|
||||
if (lastIsShowFull || GraphSelectionEnum.doPlotAvgEucDist(lastFieldSelection)
|
||||
|| GraphSelectionEnum.doPlotMaxEucDist(lastFieldSelection)) {
|
||||
double[] measures = ((Population)pop).getPopulationMeasures((InterfaceDistanceMetric)null);
|
||||
if (measures != null) {
|
||||
currentAvgPopDist = measures[0];
|
||||
currentMaxPopDist = measures[2];
|
||||
currentAvgEucDistInPop = measures[0];
|
||||
currentMaxEucDistInPop = measures[2];
|
||||
}
|
||||
}
|
||||
|
||||
if (lastIsShowFull || GraphSelectionEnum.doPlotAvgPopMetricDist(lastFieldSelection)
|
||||
|| GraphSelectionEnum.doPlotMaxPopMetricDist(lastFieldSelection)) {
|
||||
double[] measures = ((Population)pop).getPopulationMeasures();
|
||||
if (measures != null) {
|
||||
currentAvgPopDistMetric = measures[0];
|
||||
currentMaxPopDistMetric = measures[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1036,32 +1050,23 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
firstPlot = false;
|
||||
currentBestFeasibleFit=null;
|
||||
}
|
||||
if (TRACE) printToTextListener("A1\n");
|
||||
|
||||
if (pop.getSpecificData() != null) { // this is more or less deprecated. the standard population implementation will always return null. However the ES module wont
|
||||
plotSpecificData(pop, informerList);
|
||||
return;
|
||||
}
|
||||
|
||||
if (TRACE) printToTextListener("A2\n");
|
||||
collectPopData(pop);
|
||||
if (TRACE) printToTextListener("A3\n");
|
||||
|
||||
if (iterationCounter==0) {
|
||||
if (TRACE) printToTextListener("A3.1 " + currentStatHeader.length + "\n");
|
||||
|
||||
String headerLine = StringTools.concatFields(currentStatHeader, textFieldDelimiter);
|
||||
if (TRACE) printToTextListener("A3.2\n");
|
||||
if (printHeaderByVerbosity()) printToTextListener(headerLine+'\n');
|
||||
if (TRACE) printToTextListener("A3.3\n");
|
||||
}
|
||||
if (TRACE) printToTextListener("A4\n");
|
||||
|
||||
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());
|
||||
if (TRACE) printToTextListener("A5\n");
|
||||
|
||||
Pair<String,Object[]> addData = getOutputData(informerList, lastSols);
|
||||
if (doTextOutput()) { // this is where the text output is actually written
|
||||
if (printLineByVerbosity(iterationCounter)) {
|
||||
@ -1069,8 +1074,6 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
printToTextListener(addData.head()+'\n');
|
||||
}
|
||||
}
|
||||
if (TRACE) printToTextListener("A6\n");
|
||||
|
||||
currentStatObjectData = addData.tail();
|
||||
currentStatDoubleData = ToolBox.parseDoubles(currentStatObjectData);
|
||||
if (currentStatObjectData!=null) {
|
||||
@ -1078,7 +1081,6 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
} else {
|
||||
System.err.println("Warning in AbstractStatistics!");
|
||||
}
|
||||
if (TRACE) printToTextListener("A7\n");
|
||||
|
||||
if (sumDataCollection != null) {
|
||||
// Collect average data
|
||||
@ -1099,7 +1101,6 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
if (sumDataEntry != null) updateSum(sumDataEntry, currentStatDoubleData); // this adds up data of a single iteration across multiple runs
|
||||
}
|
||||
}
|
||||
if (TRACE) printToTextListener("A8\n");
|
||||
|
||||
// if (doTextOutput()) {
|
||||
// Pair<String,Double[]> addInfo = getOutputLine(informerList, lastSols);
|
||||
|
@ -12,7 +12,7 @@ import eva2.tools.StringSelection;
|
||||
public enum GraphSelectionEnum {
|
||||
// DONT change this order, or the relation to AbstractStatistics will be lost
|
||||
currentBest, meanFit, currentWorst, runBest, currentBestFeasible, runBestFeasible,
|
||||
avgPopDistance, maxPopDistance;
|
||||
avgEucPopDistance, maxEucPopDistance, avgPopMetricDist, maxPopMetricDist;
|
||||
|
||||
private static String[] toolTips = {
|
||||
"The current best fitness within the population",
|
||||
@ -21,8 +21,10 @@ public enum GraphSelectionEnum {
|
||||
"The best fitness up to the current generation",
|
||||
"The best feasible fitness within the population",
|
||||
"The best feasible fitness up to the current generation",
|
||||
"The average phenotypic distance of individuals in the population",
|
||||
"The maximum phenotypic distance of individuals in the population"
|
||||
"The average euclidean distance of individuals in the current population",
|
||||
"The maximum euclidean distance of individuals in the current population",
|
||||
"The average distance of individuals in the current population metric",
|
||||
"The maximum distance of individuals in the current population metric",
|
||||
};
|
||||
|
||||
public static String[] getInfoStrings() {
|
||||
@ -55,11 +57,19 @@ public enum GraphSelectionEnum {
|
||||
// return sel.isSelected(GraphSelectionEnum.runBestFeasible.ordinal());
|
||||
// }
|
||||
//
|
||||
public static boolean doPlotAvgDist(StringSelection sel) {
|
||||
return sel.isSelected(GraphSelectionEnum.avgPopDistance.ordinal());
|
||||
public static boolean doPlotAvgEucDist(StringSelection sel) {
|
||||
return sel.isSelected(GraphSelectionEnum.avgEucPopDistance.ordinal());
|
||||
}
|
||||
|
||||
public static boolean doPlotMaxPopDist(StringSelection sel) {
|
||||
return sel.isSelected(GraphSelectionEnum.maxPopDistance.ordinal());
|
||||
public static boolean doPlotMaxEucDist(StringSelection sel) {
|
||||
return sel.isSelected(GraphSelectionEnum.maxEucPopDistance.ordinal());
|
||||
}
|
||||
|
||||
public static boolean doPlotAvgPopMetricDist(StringSelection sel) {
|
||||
return sel.isSelected(GraphSelectionEnum.avgPopMetricDist.ordinal());
|
||||
}
|
||||
|
||||
public static boolean doPlotMaxPopMetricDist(StringSelection sel) {
|
||||
return sel.isSelected(GraphSelectionEnum.maxPopMetricDist.ordinal());
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import eva2.gui.BeanInspector;
|
||||
import eva2.gui.GenericObjectEditor;
|
||||
import eva2.server.go.InterfaceNotifyOnInformers;
|
||||
import eva2.server.go.problems.InterfaceAdditionalPopulationInformer;
|
||||
import eva2.tools.EVAERROR;
|
||||
import eva2.tools.SelectedTag;
|
||||
import eva2.tools.Serializer;
|
||||
import eva2.tools.StringSelection;
|
||||
@ -384,10 +385,18 @@ public class StatsParameter implements InterfaceStatisticsParameter, InterfaceNo
|
||||
ArrayList<String> infoFields = new ArrayList<String>();
|
||||
// parse list of header elements, show additional Strings according to names.
|
||||
for (InterfaceAdditionalPopulationInformer inf : informers) {
|
||||
headerFields.addAll(Arrays.asList(inf.getAdditionalDataHeader()));
|
||||
String[] dataHeader = inf.getAdditionalDataHeader();
|
||||
headerFields.addAll(Arrays.asList(dataHeader));
|
||||
if (infoFields.size()<headerFields.size()) { // add info strings for tool tips - fill up with null if none have been returned.
|
||||
String[] infos = inf.getAdditionalDataInfo();
|
||||
if (infos!=null) infoFields.addAll(Arrays.asList(infos));
|
||||
if (infos!=null) {
|
||||
if (infos.length!=dataHeader.length) {
|
||||
System.out.println(BeanInspector.toString(infos));
|
||||
System.out.println(BeanInspector.toString(dataHeader));
|
||||
EVAERROR.errorMsgOnce("Warning, mismatching number of headers and additional data fields for " + inf.getClass() + " ("+dataHeader.length+ " vs. " + infos.length + ").");
|
||||
}
|
||||
infoFields.addAll(Arrays.asList(infos));
|
||||
}
|
||||
while (infoFields.size()<headerFields.size()) infoFields.add(null);
|
||||
}
|
||||
// header += inf.getAdditionalDataHeader(null); // lets hope this works with a null
|
||||
|
Loading…
x
Reference in New Issue
Block a user