Class AbstractGeneticAlgorithm.GeneticAlgorithmJob<T extends AbstractGeneticAlgorithm>

    • Field Detail

      • m_Weights

        protected int[] m_Weights
        the weights of the chromosomes (0 = turned off, 1 = turned on).
      • m_Fitness

        protected Double m_Fitness
        the current fitness.
      • m_Chromosome

        protected int m_Chromosome
        the chromosome index.
    • Constructor Detail

      • GeneticAlgorithmJob

        public GeneticAlgorithmJob​(T g,
                                   int chromosome,
                                   int[] w)
        Initializes the job.
        Parameters:
        g - the algorithm object this job belongs to
        chromosome - the chromsome index
        w - the initial weights
    • Method Detail

      • getWeights

        public int[] getWeights()
        Returns the current weights of the attributes.
        Returns:
        the weights
      • getChromosome

        public int getChromosome()
        Returns the chromosome index.
        Returns:
        the index
      • getFitness

        public Double getFitness()
        Returns the fitness.
        Returns:
        the fitness
      • weightsToString

        public String weightsToString()
        Turns the weights into a string representation.
        Returns:
        the weights as string
      • weightsToString

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

        public abstract void calcNewFitness()
        Calculates the new fitness.
      • preProcessCheck

        protected String preProcessCheck()
        Checks whether all pre-conditions have been met.
        Specified by:
        preProcessCheck in class AbstractJob
        Returns:
        null if everything is OK, otherwise an error message
      • process

        protected void process()
                        throws Exception
        Does the actual execution of the job.
        Specified by:
        process in class AbstractJob
        Throws:
        Exception - if fails to execute job
      • postProcessCheck

        protected String postProcessCheck()
        Checks whether all post-conditions have been met.
        Specified by:
        postProcessCheck in class AbstractJob
        Returns:
        always null
      • cleanUp

        public void cleanUp()
        Cleans up data structures, frees up memory. Sets the weights and the genetic algorithm to null.
        Specified by:
        cleanUp in interface CleanUpHandler
        Specified by:
        cleanUp in interface Job
        Overrides:
        cleanUp in class AbstractJob
      • toString

        public String toString()
        Returns a string representation of the job.
        Specified by:
        toString in class AbstractJob
        Returns:
        a string representation