Documentation of 'org.jgap.BaseGene' Java class
BaseGene
org.jgap

Class BaseGene

    • Field Detail

      • S_APPLICATION_DATA

        public static final java.lang.String S_APPLICATION_DATA
        Constants for toString()
        See Also:
        Constant Field Values
      • DELTA

        public static final double DELTA
        Delta, useful for comparing doubles and floats.
        See Also:
        Constant Field Values
    • Method Detail

      • getAllele

        public java.lang.Object getAllele()
        Retrieves the allele value represented by this Gene.
        Specified by:
        getAllele in interface Gene
        Returns:
        the allele value of this Gene
        Since:
        1.0
      • hashCode

        public int hashCode()
        Retrieves the hash code value for a Gene. Override if another hashCode() implementation is necessary or more appropriate than this default implementation.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        this Gene's hash code
        Since:
        1.0
      • cleanup

        public void cleanup()
        Executed by the genetic engine when this Gene instance is no longer needed and should perform any necessary resource cleanup. If you need a special cleanup, override this method.
        Specified by:
        cleanup in interface Gene
        Since:
        1.0
      • toString

        public java.lang.String toString()
        Retrieves a string representation of this Gene's value that may be useful for display purposes.
        Specified by:
        toString in interface Gene
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of this Gene's value
        Since:
        1.0
      • size

        public int size()
        Specified by:
        size in interface Gene
        Returns:
        the size of the gene, i.e the number of atomic elements. Always 1 for non-composed Gene types. Override for composed Gene types
        Since:
        1.0
      • equals

        public boolean equals(java.lang.Object a_other)
        Compares this Gene with the given object and returns true if the other object is a Gene of the same type and has the same value (allele) as this Gene. Otherwise it returns false.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        a_other - the object to compare to this Gene for equality
        Returns:
        true if this Gene is equal to the given object, false otherwise
        Since:
        1.1
      • getEnergy

        public double getEnergy()
        Specified by:
        getEnergy in interface Gene
        Returns:
        energy of the gene
        Since:
        2.3
      • setEnergy

        public void setEnergy(double a_energy)
        Sets the energy of the gene
        Specified by:
        setEnergy in interface Gene
        Parameters:
        a_energy - the energy to set
        Since:
        2.3
      • setApplicationData

        public void setApplicationData(java.lang.Object a_newData)
        This sets the application-specific data that is attached to this Gene. Attaching application-specific data may be useful for some applications when it comes time to distinguish a Gene from another. JGAP ignores this data functionally.
        Specified by:
        setApplicationData in interface Gene
        Parameters:
        a_newData - the new application-specific data to attach to this Gene
        Since:
        2.4
      • getApplicationData

        public java.lang.Object getApplicationData()
        Retrieves the application-specific data that is attached to this Gene. Attaching application-specific data may be useful for some applications when it comes time to distinguish a Gene from another. JGAP ignores this data functionally.
        Specified by:
        getApplicationData in interface Gene
        Returns:
        the application-specific data previously attached to this Gene, or null if there is no data attached
        Since:
        2.4
      • setCompareApplicationData

        public void setCompareApplicationData(boolean a_doCompare)
        Should we also consider the application data when comparing? Default is "false" as "true" means a Gene is losing its identity when application data is set differently!
        Specified by:
        setCompareApplicationData in interface Gene
        Parameters:
        a_doCompare - true: consider application data in method compareTo
        Since:
        2.4
      • setConstraintChecker

        public void setConstraintChecker(IGeneConstraintChecker a_constraintChecker)
        Sets the constraint checker to be used for this gene whenever method setAllele(Object) is called.
        Specified by:
        setConstraintChecker in interface Gene
        Parameters:
        a_constraintChecker - the constraint checker to be set
        Since:
        2.5 (moved from CompositeGene, where it was since 2.0)
      • getConstraintChecker

        public IGeneConstraintChecker getConstraintChecker()
        Returns:
        IGeneConstraintChecker the constraint checker to be used whenever method setAllele(Object) is called.
        Since:
        2.5 (moved from CompositeGene, where it was since 2.0)
      • newGene

        public Gene newGene()
        Provides implementation-independent means for creating new Gene instances. The new instance that is created and returned should be setup with any implementation-dependent configuration that this Gene instance is setup with (aside from the actual value, of course). For example, if this Gene were setup with bounds on its value, then the Gene instance returned from this method should also be setup with those same bounds. This is important, as the JGAP core will invoke this method on each Gene in the sample Chromosome in order to create each new Gene in the same respective gene position for a new Chromosome.
        Specified by:
        newGene in interface Gene
        Returns:
        a new Gene instance of the same type and with the same setup as this concrete Gene
        Since:
        2.6 (since 1.0 in IntegerGene)
      • getBusinessKey

        public java.lang.String getBusinessKey()
        Specified by:
        getBusinessKey in interface IBusinessKey
        Returns:
        business key
      • getUniqueID

        public java.lang.String getUniqueID()
        Specified by:
        getUniqueID in interface IUniqueKey
        Returns:
        unique ID of the gene, which allows to distinct this instance from others, in the best case worldwide
        Since:
        3.5
      • setUniqueIDTemplate

        public void setUniqueIDTemplate(java.lang.String a_templateID,
                                        int a_index)
        A template is a gene that is the logical predecessor of the current gene. A template can occur in mutation or crossing over. In the latter case can be at least two template genes. This is why in this setter method the parameter a_index exists.
        Specified by:
        setUniqueIDTemplate in interface IUniqueKey
        Parameters:
        a_templateID - the unique ID of the template
        a_index - the index of the template, e.g. in crossing over for the second candidate gene this is 2
        Since:
        3.5
      • getUniqueIDTemplate

        public java.lang.String getUniqueIDTemplate(int a_index)
        Specified by:
        getUniqueIDTemplate in interface IUniqueKey
        Parameters:
        a_index - the index of the template to retrieve the key for
        Returns:
        String
        Since:
        3.5

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.