Minor changes to StatisticsDummy, merging mk branch rev 126:127
This commit is contained in:
parent
c25ca2ebaa
commit
ad67392637
@ -409,7 +409,14 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
for (int i=0; i<mean.length; i++) mean[i] += fit[i];
|
||||
}
|
||||
|
||||
private boolean secondIsBetter(IndividualInterface indy1, IndividualInterface indy2) {
|
||||
/**
|
||||
* Compare two individual interfaces and return true if the second one is dominant.
|
||||
*
|
||||
* @param indy1
|
||||
* @param indy2
|
||||
* @return true if the second individual is dominant, else false
|
||||
*/
|
||||
public static boolean secondIsBetter(IndividualInterface indy1, IndividualInterface indy2) {
|
||||
if (indy1 == null) return true;
|
||||
if (indy2 == null) return false;
|
||||
if (indy1 instanceof AbstractEAIndividual) return ((AbstractEAIndividual)indy2).isDominatingDebConstraints((AbstractEAIndividual)indy1);
|
||||
|
@ -2,6 +2,7 @@ package eva2.server.stat;
|
||||
|
||||
import eva2.server.go.IndividualInterface;
|
||||
import eva2.server.go.PopulationInterface;
|
||||
import eva2.server.go.individuals.AbstractEAIndividual;
|
||||
import eva2.server.go.problems.InterfaceAdditionalPopulationInformer;
|
||||
|
||||
/**
|
||||
@ -14,13 +15,16 @@ import eva2.server.go.problems.InterfaceAdditionalPopulationInformer;
|
||||
public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListener {
|
||||
boolean consoleOut = false;
|
||||
StatsParameter sParams = null;
|
||||
AbstractEAIndividual bestCurrentIndividual, bestIndividualAllover;
|
||||
|
||||
public StatisticsDummy() {
|
||||
bestIndividualAllover = null;
|
||||
sParams = new StatsParameter();
|
||||
sParams.setOutputVerbosityK(StatsParameter.VERBOSITY_NONE);
|
||||
}
|
||||
|
||||
public StatisticsDummy(boolean doConsoleOut) {
|
||||
bestIndividualAllover = null;
|
||||
sParams = new StatsParameter();
|
||||
sParams.setOutputVerbosityK(StatsParameter.VERBOSITY_NONE);
|
||||
consoleOut = doConsoleOut;
|
||||
@ -30,8 +34,12 @@ public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListen
|
||||
System.err.println("addTextListener not provided!");
|
||||
}
|
||||
|
||||
public void createNextGenerationPerformed(PopulationInterface Pop,
|
||||
public void createNextGenerationPerformed(PopulationInterface pop,
|
||||
InterfaceAdditionalPopulationInformer informer) {
|
||||
bestCurrentIndividual = (AbstractEAIndividual)pop.getBestIndividual();
|
||||
if ((bestIndividualAllover == null) || (AbstractStatistics.secondIsBetter(bestIndividualAllover, bestCurrentIndividual))) {
|
||||
bestIndividualAllover = bestCurrentIndividual;
|
||||
}
|
||||
}
|
||||
|
||||
public void createNextGenerationPerformed(double[] bestfit,
|
||||
@ -39,13 +47,12 @@ public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListen
|
||||
}
|
||||
|
||||
public double[] getBestFitness() {
|
||||
System.err.println("getBestFitness not provided!");
|
||||
return null;
|
||||
if (bestIndividualAllover != null) return bestCurrentIndividual.getFitness();
|
||||
else return null;
|
||||
}
|
||||
|
||||
public IndividualInterface getBestSolution() {
|
||||
System.err.println("getBestSolution not provided!");
|
||||
return null;
|
||||
return bestIndividualAllover;
|
||||
}
|
||||
|
||||
public InterfaceStatisticsParameter getStatisticsParameter() {
|
||||
@ -62,7 +69,9 @@ public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListen
|
||||
}
|
||||
|
||||
public void startOptPerformed(String InfoString, int runnumber,
|
||||
Object params) {}
|
||||
Object params) {
|
||||
bestIndividualAllover = null;
|
||||
}
|
||||
|
||||
public void stopOptPerformed(boolean normal, String stopMessage) {}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user