merging rev 114 from mk-branch - added possibility to plot population measures
This commit is contained in:
parent
3310571776
commit
7697d00bf7
2
.project
2
.project
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>JORelease</name>
|
||||
<name>JE2Base</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
|
@ -122,13 +122,14 @@ public class GraphPointSet {
|
||||
case 1: c = Color.red; break;
|
||||
case 2: c = Color.blue; break;
|
||||
case 3: c = Color.pink; break;
|
||||
case 4: c = Color.orange; break;
|
||||
case 4: c = Color.green; break;
|
||||
case 5: c = Color.gray; break;
|
||||
case 6: c = Color.green; break;
|
||||
case 7: c = Color.magenta; break;
|
||||
case 8: c = Color.cyan; break;
|
||||
case 6: c = Color.magenta; break;
|
||||
case 7: c = Color.cyan; break;
|
||||
case 8: c = Color.orange; break;
|
||||
case 9: c = Color.darkGray; break;
|
||||
}
|
||||
System.out.println("Selected " + c.toString() + " for " + k);
|
||||
return c;
|
||||
}
|
||||
/**
|
||||
|
@ -27,6 +27,7 @@ public interface PopulationInterface {
|
||||
public double[] getBestFitness();
|
||||
public double[] getWorstFitness();
|
||||
public double[] getMeanFitness();
|
||||
public double[] getPopulationMeasures();
|
||||
public int getFunctionCalls();
|
||||
public int getGeneration();
|
||||
/** This method returns problem specific data
|
||||
|
@ -19,8 +19,6 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
private PrintWriter resultOut;
|
||||
public final static boolean TRACE = false;
|
||||
protected InterfaceStatisticsParameter m_StatsParams;
|
||||
// protected String startDate;
|
||||
// protected long startTime;
|
||||
|
||||
/**
|
||||
* Keep track of all intermediate fitness values, best, avg. and worst, averaging over all runs
|
||||
@ -48,6 +46,8 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
protected double[] currentBestFit;
|
||||
protected double[] meanFitness;
|
||||
protected double[] currentWorstFit;
|
||||
protected double avgPopDist;
|
||||
protected double maxPopDist;
|
||||
protected IndividualInterface bestCurrentIndividual, bestIndividualAllover;
|
||||
|
||||
|
||||
@ -333,6 +333,13 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
meanFitness = pop.getMeanFitness().clone();
|
||||
currentWorstFit = pop.getWorstIndividual().getFitness().clone();
|
||||
functionCalls = pop.getFunctionCalls();
|
||||
if (m_StatsParams.getPlotData().getSelectedTag().getID() == StatsParameter.PLOT_BEST_AND_MEASURES) {
|
||||
double[] measures = pop.getPopulationMeasures();
|
||||
if (measures != null) {
|
||||
avgPopDist = measures[0];
|
||||
maxPopDist = measures[2];
|
||||
}
|
||||
}
|
||||
|
||||
if (meanCollection != null) {
|
||||
// Collect average data
|
||||
|
@ -44,8 +44,8 @@ public interface InterfaceStatisticsParameter {
|
||||
|
||||
public List<String[]> getPlotDescriptions();
|
||||
|
||||
public SelectedTag getPlotFitness();
|
||||
public void setPlotFitness(SelectedTag newMethod);
|
||||
public SelectedTag getPlotData();
|
||||
public void setPlotData(SelectedTag newMethod);
|
||||
|
||||
public String getResultFilePrefix();
|
||||
public void SetResultFilePrefix(String x);
|
||||
|
@ -148,14 +148,15 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
if (TRACE) System.out.println("initPlots");
|
||||
|
||||
maybeShowProxyPrinter();
|
||||
int graphCount = description.size();
|
||||
|
||||
m_FitnessFrame = new GraphWindow[description.size()];
|
||||
m_FitnessFrame = new GraphWindow[graphCount];
|
||||
for (int i = 0; i < m_FitnessFrame.length; i++) {
|
||||
// m_FitnessFrame[i] = GraphWindow.getInstance(m_MainAdapterClient, m_GraphInfoString + " " + i + " " + " on " + m_MyHostName + ", VM " + EvAServer.m_NumberOfVM, "function calls", "fitness");
|
||||
m_FitnessFrame[i] = GraphWindow.getInstance(m_MainAdapterClient, "Optimization " + i + " " + " on " + m_MyHostName + ", VM " + EvAServer.m_NumberOfVM, "function calls", "fitness");
|
||||
}
|
||||
|
||||
m_FitnessGraph = new Graph[description.size()][];
|
||||
m_FitnessGraph = new Graph[graphCount][];
|
||||
// contains one graph for every value to be plotted (best / worst / best+worst)
|
||||
// TODO Im really not sure why this is a 2-dimensional array. shouldnt one be enough?
|
||||
for (int i = 0; i < m_FitnessGraph.length; i++) {
|
||||
@ -173,7 +174,7 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
if (m_StatsParams.getMultiRuns() > 1 &&
|
||||
m_StatsParams.GetuseStatPlot() == true) {
|
||||
String Info = m_StatsParams.GetInfoString();
|
||||
m_StatGraph = new Graph[description.size()][];
|
||||
m_StatGraph = new Graph[graphCount][];
|
||||
for (int i = 0; i < m_StatGraph.length; i++) {
|
||||
m_StatGraph[i] = new Graph[((String[]) description.get(i)).length];
|
||||
for (int j = 0; j < m_StatGraph[i].length; j++) {
|
||||
@ -208,14 +209,16 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
// Plots
|
||||
m_PlotCounter--;
|
||||
|
||||
int fitnessplot_setting = m_StatsParams.getPlotFitness().getSelectedTag().getID();
|
||||
int fitnessplot_setting = m_StatsParams.getPlotData().getSelectedTag().getID();
|
||||
|
||||
if (m_PlotCounter == 0) {
|
||||
m_PlotCounter = m_StatsParams.GetPlotoutput();
|
||||
boolean doPlotBest = (fitnessplot_setting == StatsParameter.PLOT_BEST)
|
||||
|| (fitnessplot_setting == StatsParameter.PLOT_BEST_AND_WORST);
|
||||
|| (fitnessplot_setting == StatsParameter.PLOT_BEST_AND_WORST)
|
||||
|| (fitnessplot_setting == StatsParameter.PLOT_BEST_AND_MEASURES);
|
||||
boolean doPlotWorst = (fitnessplot_setting == StatsParameter.PLOT_WORST)
|
||||
|| (fitnessplot_setting == StatsParameter.PLOT_BEST_AND_WORST);
|
||||
boolean doPlotMeasures = (fitnessplot_setting == StatsParameter.PLOT_BEST_AND_MEASURES);
|
||||
if (doPlotBest) {
|
||||
plotFitnessPoint(0, 0, functionCalls, currentBestFit[0]);
|
||||
}
|
||||
@ -228,6 +231,10 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
}
|
||||
plotFitnessPoint(0, (doPlotBest ? 1 : 0) , functionCalls, currentWorstFit[0]);
|
||||
}
|
||||
if (doPlotMeasures) {
|
||||
plotFitnessPoint(0, 1, functionCalls, avgPopDist);
|
||||
plotFitnessPoint(0, 2, functionCalls, maxPopDist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,10 +32,12 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
||||
public final static int PLOT_BEST = 0;
|
||||
public final static int PLOT_WORST = 1;
|
||||
public final static int PLOT_BEST_AND_WORST = 2;
|
||||
public final static int PLOT_BEST_AND_MEASURES = 3;
|
||||
public final static Tag[] TAGS_PLOT_FITNESS = {
|
||||
new Tag(PLOT_BEST, "plot best"),
|
||||
new Tag(PLOT_WORST, "plot worst"),
|
||||
new Tag(PLOT_BEST_AND_WORST, "both best and worst")
|
||||
new Tag(PLOT_BEST, "plot best fitness"),
|
||||
new Tag(PLOT_WORST, "plot worst fitness"),
|
||||
new Tag(PLOT_BEST_AND_WORST, "both best and worst"),
|
||||
new Tag(PLOT_BEST_AND_MEASURES, "both best and population measures")
|
||||
};
|
||||
|
||||
public final static int VERBOSITY_NONE = 0;
|
||||
@ -94,7 +96,7 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
||||
*/
|
||||
public ArrayList<String[]> getPlotDescriptions() {
|
||||
ArrayList<String[]> desc = new ArrayList<String[]>();
|
||||
switch (getPlotFitness().getSelectedTagID()) {
|
||||
switch (getPlotData().getSelectedTagID()) {
|
||||
case StatsParameter.PLOT_BEST_AND_WORST:
|
||||
desc.add(new String[] {"Best", "Worst"});
|
||||
break;
|
||||
@ -104,6 +106,9 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
||||
case StatsParameter.PLOT_WORST:
|
||||
desc.add(new String[] {"Worst"});
|
||||
break;
|
||||
case StatsParameter.PLOT_BEST_AND_MEASURES:
|
||||
desc.add(new String[] {"Best", "AvgDist", "MaxDist"});
|
||||
break;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
@ -241,22 +246,22 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public SelectedTag getPlotFitness() {
|
||||
public SelectedTag getPlotData() {
|
||||
return new SelectedTag(m_PlotFitness, TAGS_PLOT_FITNESS);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setPlotFitness(SelectedTag newMethod) {
|
||||
public void setPlotData(SelectedTag newMethod) {
|
||||
m_PlotFitness = newMethod.getSelectedTag().getID();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String plotFitnessTipText() {
|
||||
return "The individual of which the fitness is plotted.";
|
||||
public String plotDataTipText() {
|
||||
return "The data to be plotted.";
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user