Class GeneticAlgorithm

  • All Implemented Interfaces:
    adams.core.CleanUpHandler, adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.option.OptionHandler, adams.core.SizeOfHandler, Serializable, Comparable

    public class GeneticAlgorithm
    extends PackDataGeneticAlgorithm
    Morticia (GEX).

    Valid options are:

    -D (property: debug)
             If set to true, scheme may output additional info to the console.
     
    -num-chrom <int> (property: numChrom)
             The number of chromosomes, ie, the population size.
             default: 50
     
    -num-iter <int> (property: numIterations)
             The number of iterations to perform.
             default: 10000000
     
    -seed <int> (property: seed)
             The seed value for the random number generator.
             default: 1
     
    -favor-zeroes (property: favorZeroes)
             Whether to favor 0s instead of 1s.
     
    -best <java.lang.String> (property: bestRange)
             The range of the best attributes.
             default: -none-
     
    -max-train <int> (property: maxTrainTime)
             The maximum number of seconds to training time (0 = unlimited time).
             default: 0
     
    -notify <int> (property: notificationInterval)
             The time interval in seconds after which notification events about changes
              in the fitness can be sent (-1 = never send notifications; 0 = whenever
              a change occurs).
             default: -1
     
    Version:
    $Revision$
    Author:
    Dale (dale at cs dot waikato dot ac dot nz), FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_bits

        protected int m_bits
      • m_zerocount

        protected int m_zerocount
      • m_fitnessfn

        protected adams.opt.optimise.FitnessFunction m_fitnessfn
      • m_LastNotificationTime

        protected Long m_LastNotificationTime
        the timestamp the last notification got sent.
    • Constructor Detail

      • GeneticAlgorithm

        public GeneticAlgorithm()
        The default constructor.
    • Method Detail

      • addResult

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

        public void reset()
        Resets the genetic algorihtm. Derived classes must call this method in set-methods of parameters to assure the invalidation of previously generated data.
        Overrides:
        reset in class AbstractGeneticAlgorithm
      • getResult

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

        protected void clearResults()
        Clears all currently stored results.
      • weightsToString

        public String weightsToString​(int[] weights)
        Turns the weights into a string representation.
        Parameters:
        weights - the weights to turn into a string
        Returns:
        the weights as string
      • calcNewFitness

        public double calcNewFitness​(adams.opt.optimise.FitnessFunction ff,
                                     int[] weights)
        Calculates the new fitness.
      • checkBest

        public void checkBest​(Double fitness,
                              adams.opt.optimise.OptData vars,
                              adams.opt.optimise.FitnessFunction ff,
                              int zerocount)
      • globalInfo

        public String globalInfo()
        Returns a string describing the object.
        Specified by:
        globalInfo in interface adams.core.GlobalInfoSupporter
        Specified by:
        globalInfo in class adams.core.option.AbstractOptionHandler
        Returns:
        a description suitable for displaying in the gui
      • defineOptions

        public void defineOptions()
        Adds options to the internal list of options.
        Specified by:
        defineOptions in interface adams.core.option.OptionHandler
        Overrides:
        defineOptions in class AbstractGeneticAlgorithm
      • setBits

        public void setBits​(int value)
        Bits per gene.
        Parameters:
        value - the number of bits.
      • getBits

        public int getBits()
        Gets the number of bits.
        Returns:
        the number of bits
      • bitsTipText

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

        public adams.opt.optimise.OptData optimise​(adams.opt.optimise.OptData datadef,
                                                   adams.opt.optimise.FitnessFunction fitness)
        Specified by:
        optimise in class adams.opt.optimise.AbstractOptimiser
      • cleanUp

        public void cleanUp()
        Cleans up data structures, frees up memory.
        Specified by:
        cleanUp in interface adams.core.CleanUpHandler
        Overrides:
        cleanUp in class adams.opt.optimise.AbstractOptimiser
      • main

        public static void main​(String[] args)