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

Class GPProgram

    • Constructor Detail

      • GPProgram

        public GPProgram()
                  throws java.lang.Exception
        Default constructor, only for dynamic instantiation.
        Throws:
        java.lang.Exception
        Since:
        3.3.4
      • GPProgram

        public GPProgram(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)
                  throws InvalidConfigurationException
        Master constructor.
        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
        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

      • getChromosome

        public ProgramChromosome getChromosome(int a_index)
        Specified by:
        getChromosome in interface IGPProgram
        Parameters:
        a_index - the chromosome to get
        Returns:
        the ProgramChromosome with the given index
        Since:
        3.0
      • setChromosome

        public void setChromosome(int a_index,
                                  ProgramChromosome a_chrom)
        Sets the given chromosome at the given index.
        Specified by:
        setChromosome in interface IGPProgram
        Parameters:
        a_index - sic
        a_chrom - sic
        Since:
        3.0
      • growOrFull

        public void growOrFull(int a_depth,
                               boolean a_grow,
                               int a_maxNodes,
                               boolean[] a_fullModeAllowed,
                               int a_tries)
        Initialize the chromosomes within this GP program using the grow or the full method.
        Parameters:
        a_depth - the maximum depth of the chromosome to create
        a_grow - true: use grow method; false: use full method
        a_maxNodes - maximum number of nodes allowed
        a_fullModeAllowed - for each chromosome: true means full mode allowed, otherwise use grow mode
        a_tries - maximum number of tries to create a valid program
        Since:
        3.0
      • growOrFull

        public void growOrFull(java.lang.Class[][] a_argTypes,
                               CommandGene[][] a_nodeSets)
        Initialize this program by using given chromosomes.
        Parameters:
        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,
        Since:
        3.2.2
      • size

        public int size()
        Specified by:
        size in interface IGPProgram
        Returns:
        the number of chromosomes in the program
        Since:
        3.0
      • toString

        public java.lang.String toString(int a_startNode)
        Builds a string that represents the output of the GPProgram in left-hand-notion.
        Parameters:
        a_startNode - the node to start with
        Returns:
        output in left-hand notion
        Since:
        3.0
      • toStringNorm

        public java.lang.String toStringNorm(int a_startNode)
        Builds a string that represents the normalized output of the GPProgram.
        Specified by:
        toStringNorm in interface IGPProgram
        Parameters:
        a_startNode - the node to start with
        Returns:
        output in normalized notion
        Since:
        3.0
      • toStringDebug

        public java.lang.String toStringDebug()
        Builds a string that represents the debug output of the GPProgram.
        Returns:
        class names of all program chromosomes
        Since:
        3.0
      • execute_int

        public int execute_int(int a_chromosomeNum,
                               java.lang.Object[] a_args)
        Executes the given chromosome as an integer function.
        Specified by:
        execute_int in interface IGPProgram
        Parameters:
        a_chromosomeNum - the index of the chromosome to execute
        a_args - the arguments to use
        Returns:
        the integer return value
        Since:
        3.0
      • execute_float

        public float execute_float(int a_chromosomeNum,
                                   java.lang.Object[] a_args)
        Executes the given chromosome as a float function.
        Specified by:
        execute_float in interface IGPProgram
        Parameters:
        a_chromosomeNum - the index of the chromosome to execute
        a_args - the arguments to use
        Returns:
        the floar return value
        Since:
        3.0
      • execute_double

        public double execute_double(int a_chromosomeNum,
                                     java.lang.Object[] a_args)
        Executes the given chromosome as a double function.
        Specified by:
        execute_double in interface IGPProgram
        Parameters:
        a_chromosomeNum - the index of the chromosome to execute
        a_args - the arguments to use
        Returns:
        the double return value
        Since:
        3.0
      • execute_boolean

        public boolean execute_boolean(int a_chromosomeNum,
                                       java.lang.Object[] a_args)
        Executes the given chromosome as a boolean function.
        Specified by:
        execute_boolean in interface IGPProgram
        Parameters:
        a_chromosomeNum - the index of the chromosome to execute
        a_args - the arguments to use
        Returns:
        the boolean return value
        Since:
        3.2
      • execute_object

        public java.lang.Object execute_object(int a_chromosomeNum,
                                               java.lang.Object[] a_args)
        Executes the given chromosome as an object function.
        Specified by:
        execute_object in interface IGPProgram
        Parameters:
        a_chromosomeNum - the index of the chromosome to execute
        a_args - the arguments to use
        Returns:
        the object return value
        Since:
        3.0
      • execute_void

        public void execute_void(int a_chromosomeNum,
                                 java.lang.Object[] a_args)
        Executes the given chromosome as an object function.
        Specified by:
        execute_void in interface IGPProgram
        Parameters:
        a_chromosomeNum - the index of the chromosome to execute
        a_args - the arguments to use
        Since:
        3.0
      • getCommandOfClass

        public int getCommandOfClass(int a_chromosomeNum,
                                     java.lang.Class a_class)
        Searches for a chromosome that has the given class and returns its index.
        Specified by:
        getCommandOfClass in interface IGPProgram
        Parameters:
        a_chromosomeNum - the index of the chromosome to start the search with
        a_class - the class to find
        Returns:
        the index of the first chromosome found that is of a_class, or -1
        Since:
        3.0
      • compareTo

        public int compareTo(java.lang.Object a_other)
        Compares the given program to this program.
        Specified by:
        compareTo in interface java.lang.Comparable
        Parameters:
        a_other - the program against which to compare this program
        Returns:
        a negative number if this program is "less than" the given program, zero if they are equal to each other, and a positive number if this program is "greater than" the given program
        Since:
        3.0
      • clone

        public java.lang.Object clone()
        Specified by:
        clone in interface ICloneable
        Specified by:
        clone in class GPProgramBase
        Returns:
        deep clone of the object instance
        Since:
        3.2
      • getPersistentRepresentation

        public java.lang.String getPersistentRepresentation()
        Specified by:
        getPersistentRepresentation in interface IGPProgram
        Returns:
        the persistent representation of the GP program, including all chromosomes
        Since:
        3.3
      • getBusinessKey

        public java.lang.String getBusinessKey()
        Specified by:
        getBusinessKey in interface IBusinessKey
        Returns:
        hopefully unique key representing the state of the GPProgram
        Since:
        3.4

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.