Documentation of 'org.jgap.gp.impl.GPGenotype' Java class
GPGenotype
org.jgap.gp.impl

Class GPGenotype

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable, java.lang.Runnable


    public class GPGenotype
    extends java.lang.Object
    implements java.lang.Runnable, java.io.Serializable, java.lang.Comparable
    Genotype for GP Programs.
    Since:
    3.0
    See Also:
    Serialized Form
    • Constructor Detail

      • GPGenotype

        public GPGenotype(GPConfiguration a_configuration,
                          GPPopulation a_population,
                          java.lang.Class[] a_types,
                          java.lang.Class[][] a_argTypes,
                          CommandGene[][] a_nodeSets,
                          int[] a_minDepths,
                          int[] a_maxDepths,
                          int a_maxNodes)
                   throws InvalidConfigurationException
        Preferred constructor to use, if not using the static method randomInitialGenotype.
        Parameters:
        a_configuration - the configuration to use
        a_population - the initialized population to use
        a_types - the type for each chromosome, the length of the array represents the number of chromosomes
        a_argTypes - the types of the arguments to each chromosome, must be an array of arrays, the first dimension of which is the number of chromosomes and the second dimension of which is the number of arguments to the chromosome
        a_nodeSets - the nodes which are allowed to be used by each chromosome, must be an array of arrays, the first dimension of which is the number of chromosomes and the second dimension of which is the number of nodes
        a_minDepths - contains the minimum depth allowed for each chromosome
        a_maxDepths - contains the maximum depth allowed for each chromosome
        a_maxNodes - reserve space for a_maxNodes number of nodes
        Throws:
        InvalidConfigurationException
        Since:
        3.0
    • Method Detail

      • randomInitialGenotype

        public static GPGenotype randomInitialGenotype(GPConfiguration a_conf,
                                                       java.lang.Class[] a_types,
                                                       java.lang.Class[][] a_argTypes,
                                                       CommandGene[][] a_nodeSets,
                                                       int a_maxNodes,
                                                       boolean a_verboseOutput)
                                                throws InvalidConfigurationException
        Creates a genotype with initial population for the world set.
        Parameters:
        a_conf - the configuration to use
        a_types - the type of each chromosome, the length is the number of chromosomes
        a_argTypes - the types of the arguments to each chromosome, must be an array of arrays, the first dimension of which is the number of chromosomes and the second dimension of which is the number of arguments to the chromosome
        a_nodeSets - the nodes which are allowed to be used by each chromosome, must be an array of arrays, the first dimension of which is the number of chromosomes and the second dimension of which is the number of nodes. Note that it is not necessary to include the arguments of a chromosome as terminals in the chromosome's node set. This is done automatically
        a_maxNodes - reserve space for a_maxNodes number of nodes
        a_verboseOutput - true: output status information to console
        Returns:
        created genotype with initialized population
        Throws:
        InvalidConfigurationException
        Since:
        3.0
      • randomInitialGenotype

        public static GPGenotype randomInitialGenotype(GPConfiguration a_conf,
                                                       java.lang.Class[] a_types,
                                                       java.lang.Class[][] a_argTypes,
                                                       CommandGene[][] a_nodeSets,
                                                       int[] a_minDepths,
                                                       int[] a_maxDepths,
                                                       int a_maxNodes,
                                                       boolean a_verboseOutput)
                                                throws InvalidConfigurationException
        Creates a genotype with initial population for the world set.
        Parameters:
        a_conf - the configuration to use
        a_types - the type of each chromosome, the length is the number of chromosomes
        a_argTypes - the types of the arguments to each chromosome, must be an array of arrays, the first dimension of which is the number of chromosomes and the second dimension of which is the number of arguments to the chromosome
        a_nodeSets - the nodes which are allowed to be used by each chromosome, must be an array of arrays, the first dimension of which is the number of chromosomes and the second dimension of which is the number of nodes. Note that it is not necessary to include the arguments of a chromosome as terminals in the chromosome's node set. This is done automatically
        a_minDepths - array of minimum depths to use: for each chromosome one entry
        a_maxDepths - array of maximum depths to use: for each chromosome one entry
        a_maxNodes - reserve space for a_maxNodes number of nodes
        a_verboseOutput - true: output status information to console
        Returns:
        created genotype with initialized population
        Throws:
        InvalidConfigurationException
        Since:
        3.0
      • randomInitialGenotype

        public static GPGenotype randomInitialGenotype(GPConfiguration a_conf,
                                                       java.lang.Class[] a_types,
                                                       java.lang.Class[][] a_argTypes,
                                                       CommandGene[][] a_nodeSets,
                                                       int[] a_minDepths,
                                                       int[] a_maxDepths,
                                                       int a_maxNodes,
                                                       boolean[] a_fullModeAllowed,
                                                       boolean a_verboseOutput)
                                                throws InvalidConfigurationException
        Creates a genotype with a randomly created initial population.
        Parameters:
        a_conf - the configuration to use
        a_types - the type of each chromosome, the length is the number of chromosomes
        a_argTypes - the types of the arguments to each chromosome, must be an array of arrays, the first dimension of which is the number of chromosomes and the second dimension of which is the number of arguments to the chromosome
        a_nodeSets - the nodes which are allowed to be used by each chromosome, must be an array of arrays, the first dimension of which is the number of chromosomes and the second dimension of which is the number of nodes. Note that it is not necessary to include the arguments of a chromosome as terminals in the chromosome's node set. This is done automatically
        a_minDepths - array of minimum depths to use: for each chromosome one entry
        a_maxDepths - array of maximum depths to use: for each chromosome one entry
        a_maxNodes - reserve space for a_maxNodes number of nodes
        a_fullModeAllowed - array of boolean values. For each chromosome there is one value indicating whether the full mode for creating chromosome generations during evolution is allowed (true) or not (false)
        a_verboseOutput - true: output status information to console
        Returns:
        created genotype with initialized population
        Throws:
        InvalidConfigurationException
        Since:
        3.0
      • randomInitialGenotype

        public static GPGenotype randomInitialGenotype(GPConfiguration a_conf,
                                                       java.lang.Class[] a_types,
                                                       java.lang.Class[][] a_argTypes,
                                                       CommandGene[][] a_nodeSets,
                                                       int[] a_minDepths,
                                                       int[] a_maxDepths,
                                                       int a_maxNodes,
                                                       boolean[] a_fullModeAllowed,
                                                       boolean a_verboseOutput,
                                                       IPopulationCreator a_popCreator)
                                                throws InvalidConfigurationException
        Allows to use a custom mechanism for population creation.
        Parameters:
        a_conf - the configuration to use
        a_types - the type of each chromosome, the length is the number of chromosomes
        a_argTypes - the types of the arguments to each chromosome, must be an array of arrays, the first dimension of which is the number of chromosomes and the second dimension of which is the number of arguments to the chromosome
        a_nodeSets - the nodes which are allowed to be used by each chromosome, must be an array of arrays, the first dimension of which is the number of chromosomes and the second dimension of which is the number of nodes. Note that it is not necessary to include the arguments of a chromosome as terminals in the chromosome's node set. This is done automatically
        a_minDepths - array of minimum depths to use: for each chromosome one entry
        a_maxDepths - array of maximum depths to use: for each chromosome one entry
        a_maxNodes - reserve space for a_maxNodes number of nodes
        a_fullModeAllowed - array of boolean values. For each chromosome there is one value indicating whether the full mode for creating chromosome generations during evolution is allowed (true) or not (false)
        a_verboseOutput - true: output status information to console
        a_popCreator - mechanism fior creating the population
        Returns:
        GPGenotype
        Throws:
        InvalidConfigurationException
        Since:
        3.2.2
      • getStaticGPConfiguration

        public static GPConfiguration getStaticGPConfiguration()
        Returns:
        the static configuration to use with Genetic Programming
        Since:
        3.2
      • setStaticGPConfiguration

        public static void setStaticGPConfiguration(GPConfiguration a_configuration)
        Sets the static configuration to use with the Genetic Programming.
        Parameters:
        a_configuration - the static configuration to use
        Since:
        3.2
      • evolve

        public void evolve(int a_evolutions)
        Evolves the population n times.
        Parameters:
        a_evolutions - number of evolution
        Since:
        3.0
      • calcFitness

        public void calcFitness()
        Calculates the fitness value of all programs, of the best solution as well as the total fitness (sum of all fitness values).
        Since:
        3.0
      • getAllTimeBest

        public IGPProgram getAllTimeBest()
        Returns:
        the all-time best solution found
        Since:
        3.0
      • outputSolution

        public void outputSolution(IGPProgram a_best)
        Outputs the best solution until now.
        Parameters:
        a_best - the fittest ProgramChromosome
        Since:
        3.0
      • evolve

        public void evolve()
        Evolve the population by one generation. Probabilistically reproduces and crosses individuals into a new population which then overwrites the original population.
        Since:
        3.0
      • getTotalFitness

        public double getTotalFitness()
        Returns:
        the total fitness, that is the fitness over all chromosomes
        Since:
        3.0
      • run

        public void run()
        Default implementation of method to run GPGenotype as a thread.
        Specified by:
        run in interface java.lang.Runnable
        Since:
        3.0
      • getFittestProgram

        public IGPProgram getFittestProgram()
        Retrieves the GPProgram in the population with the highest fitness value.
        Returns:
        the GPProgram with the highest fitness value, or null if there are no programs in this Genotype
        Since:
        3.0
      • getFittestProgramComputed

        public IGPProgram getFittestProgramComputed()
        Retrieves the GPProgram in the population with the highest fitness value. Only considers programs for which the fitness value has already been computed.
        Returns:
        the GPProgram with the highest fitness value, or null if there are no programs with known fitness value in this Genotype
        Since:
        3.2
      • setGPConfiguration

        public void setGPConfiguration(GPConfiguration a_configuration)
        Sets the configuration to use with the Genetic Algorithm.
        Parameters:
        a_configuration - the configuration to use
        Since:
        3.0
      • equals

        public boolean equals(java.lang.Object a_other)
        Compares this entity against the specified object.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        a_other - the object to compare against
        Returns:
        true: if the objects are the same, false otherwise
        Since:
        3.0
      • compareTo

        public int compareTo(java.lang.Object a_other)
        Compares this Genotype against the specified object. The result is true if the argument is an instance of the Genotype class, has exactly the same number of programs as the given Genotype, and, for each GPProgram in this Genotype, there is an equal program in the given Genotype. The programs do not need to appear in the same order within the populations.
        Specified by:
        compareTo in interface java.lang.Comparable
        Parameters:
        a_other - the object to compare against
        Returns:
        a negative number if this genotype is "less than" the given genotype, zero if they are equal to each other, and a positive number if this genotype is "greater than" the given genotype
        Since:
        3.0
      • hashCode

        public int hashCode()
        Hashcode function for the genotype, tries to create a unique hashcode for the chromosomes within the population. The logic for the hashcode is Step Result ---- ------ 1 31*0 + hashcode_0 = y(1) 2 31*y(1) + hashcode_1 = y(2) 3 31*y(2) + hashcode_2 = y(3) n 31*y(n-1) + hashcode_n-1 = y(n) Each hashcode is a number and the binary equivalent is computed and returned.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the computed hashcode
        Since:
        3.0
      • setVerboseOutput

        public void setVerboseOutput(boolean a_verbose)
        Parameters:
        a_verbose - true: output status information to console
        Since:
        3.0
      • putVariable

        public void putVariable(Variable a_var)
        Stores a Variable.
        Parameters:
        a_var - the Variable to store
        Since:
        3.2
      • getVariable

        public Variable getVariable(java.lang.String a_varName)
        Parameters:
        a_varName - name of variable to retriebe
        Returns:
        Variable instance or null, if not found
        Since:
        3.2
      • addFittestProgram

        public void addFittestProgram(IGPProgram a_toAdd)
        Adds a GP program to this Genotype. Does nothing when given null. The injection is actually executed in method create(..) of GPPopulation.
        Parameters:
        a_toAdd - the program to add
        Since:
        3.2
      • checkErroneousPop

        public static void checkErroneousPop(GPPopulation pop,
                                             java.lang.String s)
      • checkErroneousPop

        public static void checkErroneousPop(GPPopulation a_pop,
                                             java.lang.String a_s,
                                             boolean a_clearFitness)
      • checkErroneousPop

        public static void checkErroneousPop(GPPopulation a_pop,
                                             java.lang.String a_s,
                                             boolean a_clearFitness,
                                             boolean a_active)
      • checkErroneousProg

        public static void checkErroneousProg(IGPProgram prog,
                                              java.lang.String s)
      • checkErroneousProg

        public static void checkErroneousProg(IGPProgram a_prog,
                                              java.lang.String a_s,
                                              boolean a_clearFitness)
      • checkErroneousProg

        public static void checkErroneousProg(IGPProgram a_prog,
                                              java.lang.String s,
                                              boolean a_clearFitness,
                                              boolean a_active)
      • verifyChildNodes

        public static java.util.Map<java.lang.String,CommandGene> verifyChildNodes(GPConfiguration a_conf,
                                                                                   java.lang.Class[] a_types,
                                                                                   CommandGene[][] a_nodeSets)
        Parameters:
        a_conf - GPConfiguration
        a_types - Class[]
        a_nodeSets - CommandGene[][]
        Returns:
        Map
        Since:
        3.4.4
      • verifyDepthsForNodes

        public static java.util.Map<CommandGene,int[]> verifyDepthsForNodes(GPConfiguration a_conf,
                                                                            java.lang.Class[] a_types,
                                                                            int[] a_minDepths,
                                                                            int[] a_maxDepths,
                                                                            int a_maxNodes,
                                                                            CommandGene[][] a_nodeSets)

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.