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"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>JORelease</name>
|
<name>JE2Base</name>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
|
@ -122,13 +122,14 @@ public class GraphPointSet {
|
|||||||
case 1: c = Color.red; break;
|
case 1: c = Color.red; break;
|
||||||
case 2: c = Color.blue; break;
|
case 2: c = Color.blue; break;
|
||||||
case 3: c = Color.pink; 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 5: c = Color.gray; break;
|
||||||
case 6: c = Color.green; break;
|
case 6: c = Color.magenta; break;
|
||||||
case 7: c = Color.magenta; break;
|
case 7: c = Color.cyan; break;
|
||||||
case 8: c = Color.cyan; break;
|
case 8: c = Color.orange; break;
|
||||||
case 9: c = Color.darkGray; break;
|
case 9: c = Color.darkGray; break;
|
||||||
}
|
}
|
||||||
|
System.out.println("Selected " + c.toString() + " for " + k);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -27,6 +27,7 @@ public interface PopulationInterface {
|
|||||||
public double[] getBestFitness();
|
public double[] getBestFitness();
|
||||||
public double[] getWorstFitness();
|
public double[] getWorstFitness();
|
||||||
public double[] getMeanFitness();
|
public double[] getMeanFitness();
|
||||||
|
public double[] getPopulationMeasures();
|
||||||
public int getFunctionCalls();
|
public int getFunctionCalls();
|
||||||
public int getGeneration();
|
public int getGeneration();
|
||||||
/** This method returns problem specific data
|
/** This method returns problem specific data
|
||||||
|
@ -19,8 +19,6 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
|||||||
private PrintWriter resultOut;
|
private PrintWriter resultOut;
|
||||||
public final static boolean TRACE = false;
|
public final static boolean TRACE = false;
|
||||||
protected InterfaceStatisticsParameter m_StatsParams;
|
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
|
* 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[] currentBestFit;
|
||||||
protected double[] meanFitness;
|
protected double[] meanFitness;
|
||||||
protected double[] currentWorstFit;
|
protected double[] currentWorstFit;
|
||||||
|
protected double avgPopDist;
|
||||||
|
protected double maxPopDist;
|
||||||
protected IndividualInterface bestCurrentIndividual, bestIndividualAllover;
|
protected IndividualInterface bestCurrentIndividual, bestIndividualAllover;
|
||||||
|
|
||||||
|
|
||||||
@ -333,6 +333,13 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
|||||||
meanFitness = pop.getMeanFitness().clone();
|
meanFitness = pop.getMeanFitness().clone();
|
||||||
currentWorstFit = pop.getWorstIndividual().getFitness().clone();
|
currentWorstFit = pop.getWorstIndividual().getFitness().clone();
|
||||||
functionCalls = pop.getFunctionCalls();
|
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) {
|
if (meanCollection != null) {
|
||||||
// Collect average data
|
// Collect average data
|
||||||
|
@ -44,8 +44,8 @@ public interface InterfaceStatisticsParameter {
|
|||||||
|
|
||||||
public List<String[]> getPlotDescriptions();
|
public List<String[]> getPlotDescriptions();
|
||||||
|
|
||||||
public SelectedTag getPlotFitness();
|
public SelectedTag getPlotData();
|
||||||
public void setPlotFitness(SelectedTag newMethod);
|
public void setPlotData(SelectedTag newMethod);
|
||||||
|
|
||||||
public String getResultFilePrefix();
|
public String getResultFilePrefix();
|
||||||
public void SetResultFilePrefix(String x);
|
public void SetResultFilePrefix(String x);
|
||||||
|
@ -148,14 +148,15 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
|||||||
if (TRACE) System.out.println("initPlots");
|
if (TRACE) System.out.println("initPlots");
|
||||||
|
|
||||||
maybeShowProxyPrinter();
|
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++) {
|
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, 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_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)
|
// 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?
|
// 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++) {
|
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 &&
|
if (m_StatsParams.getMultiRuns() > 1 &&
|
||||||
m_StatsParams.GetuseStatPlot() == true) {
|
m_StatsParams.GetuseStatPlot() == true) {
|
||||||
String Info = m_StatsParams.GetInfoString();
|
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++) {
|
for (int i = 0; i < m_StatGraph.length; i++) {
|
||||||
m_StatGraph[i] = new Graph[((String[]) description.get(i)).length];
|
m_StatGraph[i] = new Graph[((String[]) description.get(i)).length];
|
||||||
for (int j = 0; j < m_StatGraph[i].length; j++) {
|
for (int j = 0; j < m_StatGraph[i].length; j++) {
|
||||||
@ -208,14 +209,16 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
|||||||
// Plots
|
// Plots
|
||||||
m_PlotCounter--;
|
m_PlotCounter--;
|
||||||
|
|
||||||
int fitnessplot_setting = m_StatsParams.getPlotFitness().getSelectedTag().getID();
|
int fitnessplot_setting = m_StatsParams.getPlotData().getSelectedTag().getID();
|
||||||
|
|
||||||
if (m_PlotCounter == 0) {
|
if (m_PlotCounter == 0) {
|
||||||
m_PlotCounter = m_StatsParams.GetPlotoutput();
|
m_PlotCounter = m_StatsParams.GetPlotoutput();
|
||||||
boolean doPlotBest = (fitnessplot_setting == StatsParameter.PLOT_BEST)
|
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)
|
boolean doPlotWorst = (fitnessplot_setting == StatsParameter.PLOT_WORST)
|
||||||
|| (fitnessplot_setting == StatsParameter.PLOT_BEST_AND_WORST);
|
|| (fitnessplot_setting == StatsParameter.PLOT_BEST_AND_WORST);
|
||||||
|
boolean doPlotMeasures = (fitnessplot_setting == StatsParameter.PLOT_BEST_AND_MEASURES);
|
||||||
if (doPlotBest) {
|
if (doPlotBest) {
|
||||||
plotFitnessPoint(0, 0, functionCalls, currentBestFit[0]);
|
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]);
|
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_BEST = 0;
|
||||||
public final static int PLOT_WORST = 1;
|
public final static int PLOT_WORST = 1;
|
||||||
public final static int PLOT_BEST_AND_WORST = 2;
|
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 = {
|
public final static Tag[] TAGS_PLOT_FITNESS = {
|
||||||
new Tag(PLOT_BEST, "plot best"),
|
new Tag(PLOT_BEST, "plot best fitness"),
|
||||||
new Tag(PLOT_WORST, "plot worst"),
|
new Tag(PLOT_WORST, "plot worst fitness"),
|
||||||
new Tag(PLOT_BEST_AND_WORST, "both best and worst")
|
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;
|
public final static int VERBOSITY_NONE = 0;
|
||||||
@ -94,7 +96,7 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
|||||||
*/
|
*/
|
||||||
public ArrayList<String[]> getPlotDescriptions() {
|
public ArrayList<String[]> getPlotDescriptions() {
|
||||||
ArrayList<String[]> desc = new ArrayList<String[]>();
|
ArrayList<String[]> desc = new ArrayList<String[]>();
|
||||||
switch (getPlotFitness().getSelectedTagID()) {
|
switch (getPlotData().getSelectedTagID()) {
|
||||||
case StatsParameter.PLOT_BEST_AND_WORST:
|
case StatsParameter.PLOT_BEST_AND_WORST:
|
||||||
desc.add(new String[] {"Best", "Worst"});
|
desc.add(new String[] {"Best", "Worst"});
|
||||||
break;
|
break;
|
||||||
@ -104,6 +106,9 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
|||||||
case StatsParameter.PLOT_WORST:
|
case StatsParameter.PLOT_WORST:
|
||||||
desc.add(new String[] {"Worst"});
|
desc.add(new String[] {"Worst"});
|
||||||
break;
|
break;
|
||||||
|
case StatsParameter.PLOT_BEST_AND_MEASURES:
|
||||||
|
desc.add(new String[] {"Best", "AvgDist", "MaxDist"});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return desc;
|
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);
|
return new SelectedTag(m_PlotFitness, TAGS_PLOT_FITNESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setPlotFitness(SelectedTag newMethod) {
|
public void setPlotData(SelectedTag newMethod) {
|
||||||
m_PlotFitness = newMethod.getSelectedTag().getID();
|
m_PlotFitness = newMethod.getSelectedTag().getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String plotFitnessTipText() {
|
public String plotDataTipText() {
|
||||||
return "The individual of which the fitness is plotted.";
|
return "The data to be plotted.";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user