Class GeneticAlgorithm

  • All Implemented Interfaces:
    CleanUpHandler, Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, 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
    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_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.
        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.
        reset in class AbstractGeneticAlgorithm
      • getResult

        protected Double getResult​(String key)
        Returns a value from the cache.
        key - the key of the result
        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.
        weights - the weights to turn into a string
        the weights as string
      • calcNewFitness

        public double calcNewFitness​(FitnessFunction ff,
                                     int[] weights)
        Calculates the new fitness.
      • setBits

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

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

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

        public static void main​(String[] args)