From 9ab769275c5150cb8096f864c0986a305c6b5691 Mon Sep 17 00:00:00 2001 From: Marcel Kronfeld Date: Wed, 22 Sep 2010 11:58:35 +0000 Subject: [PATCH] Solution object from AbstractStatistics is now a data array. --- .../go/individuals/AbstractEAIndividual.java | 24 +++++++++++++++++++ .../problems/AbstractOptimizationProblem.java | 8 ++++--- src/eva2/server/stat/AbstractStatistics.java | 8 +++++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/eva2/server/go/individuals/AbstractEAIndividual.java b/src/eva2/server/go/individuals/AbstractEAIndividual.java index 33441f9c..a4e283c0 100644 --- a/src/eva2/server/go/individuals/AbstractEAIndividual.java +++ b/src/eva2/server/go/individuals/AbstractEAIndividual.java @@ -911,6 +911,30 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. return getDefaultDataString(individual, ","); } + /** + * This method returns the default data object of an individual containing the + * individuals solution representation. + * + * @param individual + * @return + */ + public static Object getDefaultDataObject(IndividualInterface individual) { + if (individual instanceof InterfaceDataTypeBinary) { + return ((InterfaceDataTypeBinary)individual).getBinaryData().clone(); + } else if (individual instanceof InterfaceDataTypeInteger) { + return ((InterfaceDataTypeInteger)individual).getIntegerData().clone(); + } else if (individual instanceof InterfaceDataTypeDouble) { + return ((InterfaceDataTypeDouble)individual).getDoubleData().clone(); + } else if (individual instanceof InterfaceDataTypePermutation) { + return ((InterfaceDataTypePermutation)individual).getPermutationData()[0].clone(); + } else if (individual instanceof InterfaceDataTypeProgram) { + return ((InterfaceDataTypeProgram)individual).getProgramDataWithoutUpdate().clone(); + } else { + System.err.println("error in AbstractEAIndividual.getDefaultDataObject: type " + individual.getClass() + " not implemented"); + return individual; + } + } + /** * This method creates a default String representation for a number Individual interfaces * containing the genotype. diff --git a/src/eva2/server/go/problems/AbstractOptimizationProblem.java b/src/eva2/server/go/problems/AbstractOptimizationProblem.java index c4fee742..76bad71c 100644 --- a/src/eva2/server/go/problems/AbstractOptimizationProblem.java +++ b/src/eva2/server/go/problems/AbstractOptimizationProblem.java @@ -265,7 +265,9 @@ implements InterfaceOptimizationProblem /*, InterfaceParamControllable*/, Serial * @return String */ public Object[] getAdditionalFileStringValue(PopulationInterface pop) { - String solStr = AbstractEAIndividual.getDefaultDataString(pop.getBestIndividual()); + Object solObj; +// solObj = AbstractEAIndividual.getDefaultDataString(pop.getBestIndividual()); + solObj = AbstractEAIndividual.getDefaultDataObject(pop.getBestIndividual()); if (this instanceof InterfaceInterestingHistogram) { int fitCrit=0; SolutionHistogram hist = ((InterfaceInterestingHistogram)this).getHistogram(); @@ -277,8 +279,8 @@ implements InterfaceOptimizationProblem /*, InterfaceParamControllable*/, Serial } Population sols = PostProcess.clusterBestUpdateHistogram((Population)maybeFiltered, this, hist, fitCrit, getDefaultAccuracy()); } - return new Object[]{solStr, hist, hist.getScore()}; - } else return new Object[]{solStr}; + return new Object[]{solObj, hist, hist.getScore()}; + } else return new Object[]{solObj}; } /** diff --git a/src/eva2/server/stat/AbstractStatistics.java b/src/eva2/server/stat/AbstractStatistics.java index ae9fabe5..b9bcec48 100644 --- a/src/eva2/server/stat/AbstractStatistics.java +++ b/src/eva2/server/stat/AbstractStatistics.java @@ -36,6 +36,9 @@ import eva2.tools.math.Mathematics; * list of Objects assembled in the getOutputValues method. This allows all simple data types which are * provided by the external informer instances to be handled uniformly to the internally collected data, and * thus they can be plotted and text-dumped in the same manner. + * Basic fields are identified by the enum GraphSelectionEnum and are available independently of additional + * informer instances. + * * Depending on the field selection state and the informers, the list of data fields is dynamically altered, * however changes during a multi-run are ignored, since the potential of inconsistencies is too high. * @@ -641,12 +644,12 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter List metaStrings = getOutputMetaInfo(informerList); return metaStrings.toArray( new String[metaStrings.size()]); } - /** * Collect the names of data fields which are collected internally.This must correspond to the * method {@link #getSimpleOutputValues()}. - * + * Basic fields are identified by the enum GraphSelectionEnum and are available independently of additional + * informer instances. * @see #getSimpleOutputValues() * @return */ @@ -665,6 +668,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter /** * Collect the info strings of data fields collected internally. This must correspond to * the method {@link #getSimpleOutputValues()}. + * Basic meta info is defined by the enum GraphSelectionEnum. * * @see #getSimpleOutputValues() * @return