From 4f26361eb08aa09334d1eea0a124110c20d809ce Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sat, 18 Oct 2014 15:21:45 +0200 Subject: Moved javadocs to a different repository for hosting, updated README --- doc/jcgp/backend/population/Chromosome.html | 742 ---------------------------- 1 file changed, 742 deletions(-) delete mode 100644 doc/jcgp/backend/population/Chromosome.html (limited to 'doc/jcgp/backend/population/Chromosome.html') diff --git a/doc/jcgp/backend/population/Chromosome.html b/doc/jcgp/backend/population/Chromosome.html deleted file mode 100644 index bdd49f4..0000000 --- a/doc/jcgp/backend/population/Chromosome.html +++ /dev/null @@ -1,742 +0,0 @@ - - - - - -Chromosome - - - - - - - - -
- - - - - - - -
- - - -
-
jcgp.backend.population
-

Class Chromosome

-
-
- -
-
    -
  • -
    -
    All Implemented Interfaces:
    -
    java.lang.Comparable<Chromosome>
    -
    -
    -
    -
    public class Chromosome
    -extends java.lang.Object
    -implements java.lang.Comparable<Chromosome>
    -
    This class encapsulates a CGP chromosome. -

    - A chromosome contains a matrix of nodes and arrays of inputs and outputs. - These elements are all interconnected, and actually form the chromosome - network itself. Individual nodes can be retrieved using getNode() - which requires the row and column to be specified. The same works for - inputs and outputs using the associated getters, in which case only the - index is necessary. -

    - In evolutionary computation it is often necessary to make copies of - chromosomes; this can be accomplished in JCGP in two ways. The recommended - way to do this is using copyChromosome() in Population, but alternatively - it can be done by using the Chromosome copy constructor and specifying the - object to copy from, or by using the copyGenes() method. -

    - To illustrate this, given two chromosomes, chr1 and chr2, the following code: -

    - - chr1.copyGenes(chr2); -

    - will modify all of chr1's connections and functions to match those of chr2, without - creating a new instance. In contrast, -

    - - chr1 = new Chromosome(chr2); -

    - creates a new instance of chromosome which is identical to chr2 and assigns it to chr1, - meaning any old references to chr1 that are not updated will still refer to a chromosome - that is not identical to chr2. In practice, the most reliable way is to use the copy method - in Population. Assuming chr1 and chr2 are indexed 1 and 2 in population respectively, -

    - population.copyChromosome(2, 1); -

    - will copy chr2 into chr1 without creating new instances or requiring access to the underlying - chromosome array. Chromosome offers a variety of methods to compare chromosomes as well, - such as compareGenesTo() and compareActiveGenesTo(). Comparable is implemented - to compare fitness value, meaning compareTo() returns a value depending the relative fitness - of the compared chromosomes. -

    - In order to set the chromosome's input values for decoding, setInputs() should be used. A few - utility methods are provided in order to retrieve random elements from the chromosome, which are used - internally to initialise with random connections but also externally by mutators when performing - mutations.
    -
    -
    Author:
    -
    Eduardo Pedroni
    -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Summary

      - - - - - - - - - - - -
      Constructors 
      Constructor and Description
      Chromosome(Chromosome clone) -
      Copy constructor.
      -
      Chromosome(Resources resources) -
      Initialise a chromosome with the specified parameters.
      -
      -
    • -
    - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      booleancompareActiveGenesTo(Chromosome chromosome) -
      Does the same as compareGenesto() but only looks - at the active portion of the chromosome.
      -
      booleancompareGenesTo(Chromosome chromosome) -
      Performs a deep comparison between this chromosome and the provided one.
      -
      intcompareTo(Chromosome o) 
      voidcopyGenes(Chromosome clone) -
      Creates a deep copy of the specified chromosome in the - this instance.
      -
      java.util.ArrayList<Node>getActiveNodes() -
      This method computes a list of active nodes (if necessary) and returns it.
      -
      doublegetFitness() 
      InputgetInput(int index) -
      Returns a reference to the indexed input.
      -
      NodegetNode(int row, - int column) -
      Returns a reference to any node, addressed by row and column.
      -
      OutputgetOutput(int index) -
      Returns a reference to the indexed output.
      -
      ConnectiongetRandomConnection() -
      This method will pick a completely random connection, independently - of levels back, including inputs.
      -
      ConnectiongetRandomConnection(int column) -
      Returns a random allowed connection respecting levels back.
      - This method may always pick inputs, as they can be picked - regardless of the column.
      -
      MutablegetRandomMutable() -
      This method is useful for mutating chromosomes.
      -
      ResourcesgetResources() 
      voidprintNodes() -
      Iterates through the nodes and prints all connections and functions.
      -
      voidrecomputeActiveNodes() -
      This causes the list of active nodes to be recomputed lazily (once it is actually requested).
      -
      voidreinitialiseConnections() -
      Sets random connections and functions across the entire - chromosome.
      -
      voidsetFitness(double newFitness) -
      Sets the fitness of the chromosome.
      -
      voidsetInputs(java.lang.Object... values) -
      Loops through the inputs and sets the specified values, - so that evaluations can be performed.
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        Chromosome

        -
        public Chromosome(Resources resources)
        -
        Initialise a chromosome with the specified parameters. Random valid connections - are created upon initialisation.
        -
        -
        Parameters:
        -
        resources - the experiment's resources.
        -
        -
      • -
      - - - -
        -
      • -

        Chromosome

        -
        public Chromosome(Chromosome clone)
        -
        Copy constructor. - - Initialise a new chromosome with the exact same connections as a given instance of Chromosome.
        -
        -
        Parameters:
        -
        clone - the chromosome to be copied.
        -
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        reinitialiseConnections

        -
        public void reinitialiseConnections()
        -
        Sets random connections and functions across the entire - chromosome. This method can be used more than once for - each instance, if entirely random chromosomes are desired.
        -
      • -
      - - - -
        -
      • -

        copyGenes

        -
        public void copyGenes(Chromosome clone)
        -
        Creates a deep copy of the specified chromosome in the - this instance. In practice, this iterates through the - entire chromosome making equivalent connections and - setting functions to the same values as those in the - specified chromosome. It also sets the fitness of the - copy to the same value as the original. -
        - It is assumed that both chromosomes have the same - topology; while this method will still run if that is not - the case, the effects might be undesirable and null pointer - access might occur.
        -
        -
        Parameters:
        -
        clone - the chromosome to clone.
        -
        -
      • -
      - - - -
        -
      • -

        getInput

        -
        public Input getInput(int index)
        -
        Returns a reference to the indexed input.
        -
        -
        Parameters:
        -
        index - the input index.
        -
        Returns:
        -
        the input reference.
        -
        -
      • -
      - - - -
        -
      • -

        getNode

        -
        public Node getNode(int row,
        -                    int column)
        -
        Returns a reference to any node, addressed by row and column.
        -
        -
        Parameters:
        -
        row - the row of the node.
        -
        column - the column of the node.
        -
        Returns:
        -
        the addressed node.
        -
        -
      • -
      - - - -
        -
      • -

        getOutput

        -
        public Output getOutput(int index)
        -
        Returns a reference to the indexed output.
        -
        -
        Parameters:
        -
        index - the output index.
        -
        Returns:
        -
        the output reference.
        -
        -
      • -
      - - - -
        -
      • -

        getFitness

        -
        public double getFitness()
        -
        -
        Returns:
        -
        the fitness of the chromosome.
        -
        -
      • -
      - - - -
        -
      • -

        setFitness

        -
        public void setFitness(double newFitness)
        -
        Sets the fitness of the chromosome. This method - should be used by the experiment problem when the - population is evaluated in order to assign a fitness - to each individual.
        -
        -
        Parameters:
        -
        newFitness - the fitness to assign.
        -
        -
      • -
      - - - -
        -
      • -

        setInputs

        -
        public void setInputs(java.lang.Object... values)
        -
        Loops through the inputs and sets the specified values, - so that evaluations can be performed. If the number of - elements in the array of values does not match the - number of inputs exactly, an exception is thrown.
        -
        -
        Parameters:
        -
        values - the values the input should take.
        -
        -
      • -
      - - - -
        -
      • -

        getRandomMutable

        -
        public Mutable getRandomMutable()
        -
        This method is useful for mutating chromosomes. It returns any - random Mutable out of the chromosome with equal - probability.
        -
        -
        Returns:
        -
        a random element that can be mutated - node or output.
        -
        -
      • -
      - - - -
        -
      • -

        getRandomConnection

        -
        public Connection getRandomConnection(int column)
        -
        Returns a random allowed connection respecting levels back.
        - This method may always pick inputs, as they can be picked - regardless of the column.
        -
        -
        Parameters:
        -
        column - the column to use as reference.
        -
        Returns:
        -
        a random connection.
        -
        -
      • -
      - - - -
        -
      • -

        getRandomConnection

        -
        public Connection getRandomConnection()
        -
        This method will pick a completely random connection, independently - of levels back, including inputs. It is useful for setting outputs.
        -
        -
        Returns:
        -
        a random connection regardless of levels back.
        -
        -
      • -
      - - - -
        -
      • -

        recomputeActiveNodes

        -
        public void recomputeActiveNodes()
        -
        This causes the list of active nodes to be recomputed lazily (once it is actually requested).
        -
      • -
      - - - -
        -
      • -

        getActiveNodes

        -
        public java.util.ArrayList<Node> getActiveNodes()
        -
        This method computes a list of active nodes (if necessary) and returns it.
        -
        -
        Returns:
        -
        the list of active nodes.
        -
        -
      • -
      - - - -
        -
      • -

        compareGenesTo

        -
        public boolean compareGenesTo(Chromosome chromosome)
        -
        Performs a deep comparison between this chromosome and the provided one. - This is done on a gene-by-gene basis. - - This method returns true if and only if: -
          -
        • the chromosomes being compared are not the same instance;
        • -
        • the connections of the compared chromosomes are not the same instance;
        • -
        • the grid position of the chromosome's elements are the same;
        • -
        -

        - The relationship computed by this method is: -
          -
        • symmetric: a.copyOf(b) == b.copyOf(a);
        • -
        • not reflexive: a.copyOf(a) returns false;
        • -
        • not transitive: if a.copyOf(b) is true and b.copyOf(c) is true, a.copyOf(c) is - not necessarily true since it is possible that a == c.
        • -
        -
        -
        Parameters:
        -
        chromosome - the chromosome to compare to.
        -
        Returns:
        -
        true if it is a copy of this chromosome, but not the same chromosome.
        -
        -
      • -
      - - - -
        -
      • -

        compareActiveGenesTo

        -
        public boolean compareActiveGenesTo(Chromosome chromosome)
        -
        Does the same as compareGenesto() but only looks - at the active portion of the chromosome.
        -
        -
        Parameters:
        -
        chromosome - the chromosome to compare to.
        -
        Returns:
        -
        true if the two active portions are identical.
        -
        -
      • -
      - - - -
        -
      • -

        printNodes

        -
        public void printNodes()
        -
        Iterates through the nodes and prints all connections and functions. - This is intended for debugging purposes only and does not print to the - GUI console.
        -
      • -
      - - - -
        -
      • -

        getResources

        -
        public Resources getResources()
        -
        -
        Returns:
        -
        a reference to the resources based on which the chromosome was built.
        -
        -
      • -
      - - - -
        -
      • -

        compareTo

        -
        public int compareTo(Chromosome o)
        -
        -
        Specified by:
        -
        compareTo in interface java.lang.Comparable<Chromosome>
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - -
- - - - - - - -
- - - - -- cgit v1.2.3