Class AbstractClassifierBasedGeneticAlgorithmWithSecondEvaluation

  • All Implemented Interfaces:
    adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.option.OptionHandler, adams.core.Pausable, adams.core.Randomizable, adams.core.ShallowCopySupporter<adams.opt.genetic.AbstractGeneticAlgorithm>, adams.core.SizeOfHandler, adams.core.Stoppable, adams.core.StoppableWithFeedback, adams.core.ThreadLimiter, adams.event.GeneticFitnessChangeNotifier, Serializable
    Direct Known Subclasses:
    DarkLord, Hermione

    public abstract class AbstractClassifierBasedGeneticAlgorithmWithSecondEvaluation
    extends AbstractClassifierBasedGeneticAlgorithm
    Ancestor for genetic algorithms that offer a second evaluation using a different seed value. The fitness value of the first evaluation only gets added if it the best one so far and the evaluation with the second seed value also generates the best value so far (using a second set of stored results).
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_UseSecondEvaluation

        protected boolean m_UseSecondEvaluation
        whether to use second evaluation with different seed.
      • m_SecondFolds

        protected int m_SecondFolds
        the number of folds for cross-validation (second evaluation).
      • m_SecondCrossValidationSeed

        protected int m_SecondCrossValidationSeed
        the cross-validation seed (second evaluation).
      • m_SecondStoredResults

        public Hashtable<String,​Double> m_SecondStoredResults
        the cache for results (second evaluation).
      • m_SecondBestFitness

        protected double m_SecondBestFitness
        the best fitness so far (second evaluation).
      • m_SecondBestSetup

        protected Object m_SecondBestSetup
        the best setup so far (second evaluation).
      • m_SecondBestWeights

        protected int[] m_SecondBestWeights
        the best weights/bits so far (second evaluation).
    • Constructor Detail

      • AbstractClassifierBasedGeneticAlgorithmWithSecondEvaluation

        public AbstractClassifierBasedGeneticAlgorithmWithSecondEvaluation()
    • Method Detail

      • initialize

        protected void initialize()
        Initializes the members.
        Overrides:
        initialize in class adams.opt.genetic.AbstractGeneticAlgorithm
      • setUseSecondEvaluation

        public void setUseSecondEvaluation​(boolean value)
        Sets whether to use the second evaluation.
        Parameters:
        value - true if to use second evaluation
      • getUseSecondEvaluation

        public boolean getUseSecondEvaluation()
        Returns whether to use the second evaluation.
        Returns:
        true if to use second evaluation
      • useSecondEvaluationTipText

        public String useSecondEvaluationTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setSecondFolds

        public void setSecondFolds​(int value)
        Sets the number of folds to use in cross-validation (second evaluation).
        Parameters:
        value - the number of folds
      • getSecondFolds

        public int getSecondFolds()
        Returns the number of folds to use in cross-validation (second evaluation).
        Returns:
        the number of folds
      • secondFoldsTipText

        public String secondFoldsTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setSecondCrossValidationSeed

        public void setSecondCrossValidationSeed​(int value)
        Sets the seed value to use for cross-validation (second evaluation).
        Parameters:
        value - the seed to use
      • getSecondCrossValidationSeed

        public int getSecondCrossValidationSeed()
        Returns the current seed value for cross-validation (second evaluation).
        Returns:
        the seed value
      • secondCrossValidationSeedTipText

        public String secondCrossValidationSeedTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • addSecondResult

        protected void addSecondResult​(String key,
                                       Double val)
        Adds a result to the cache (second evaluation).
        Parameters:
        key - the key of the result
        val - the value to add
      • getSecondResult

        protected Double getSecondResult​(String key)
        Returns a value from the cache (second evaluation).
        Parameters:
        key - the key of the result
        Returns:
        the result or null if not present
      • isSecondBetterFitness

        public boolean isSecondBetterFitness​(double fitness)
        Checks whether the fitness is better (second evaluation).
        Parameters:
        fitness - the new fitness
        Returns:
        true if the new fitness is better
      • setSecondNewFitness

        public boolean setSecondNewFitness​(double fitness,
                                           Object setup,
                                           int chromosome,
                                           int[] weights)
        Sets a fitness and keep it if better (second evaluation).
        Parameters:
        fitness - the new fitness
        setup - the new setup
        chromosome - the chromosome responsible
        weights - the new weights
        Returns:
        true if the new fitness was better