From 8189116ea4b5db4675e31dfd04a5687d55e29262 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Tue, 6 May 2014 14:29:37 +0100 Subject: Added javadocs, made minor changes to the comments --- doc/jcgp/backend/population/Chromosome.html | 742 +++++++++++++++++++++ doc/jcgp/backend/population/Connection.html | 249 +++++++ doc/jcgp/backend/population/Gene.html | 241 +++++++ doc/jcgp/backend/population/Input.html | 361 ++++++++++ doc/jcgp/backend/population/MutableElement.html | 306 +++++++++ doc/jcgp/backend/population/Node.html | 544 +++++++++++++++ doc/jcgp/backend/population/Output.html | 447 +++++++++++++ doc/jcgp/backend/population/Population.html | 411 ++++++++++++ .../backend/population/class-use/Chromosome.html | 340 ++++++++++ .../backend/population/class-use/Connection.html | 301 +++++++++ doc/jcgp/backend/population/class-use/Gene.html | 194 ++++++ doc/jcgp/backend/population/class-use/Input.html | 187 ++++++ .../population/class-use/MutableElement.html | 228 +++++++ doc/jcgp/backend/population/class-use/Node.html | 244 +++++++ doc/jcgp/backend/population/class-use/Output.html | 202 ++++++ .../backend/population/class-use/Population.html | 265 ++++++++ doc/jcgp/backend/population/package-frame.html | 29 + doc/jcgp/backend/population/package-summary.html | 196 ++++++ doc/jcgp/backend/population/package-tree.html | 146 ++++ doc/jcgp/backend/population/package-use.html | 338 ++++++++++ 20 files changed, 5971 insertions(+) create mode 100644 doc/jcgp/backend/population/Chromosome.html create mode 100644 doc/jcgp/backend/population/Connection.html create mode 100644 doc/jcgp/backend/population/Gene.html create mode 100644 doc/jcgp/backend/population/Input.html create mode 100644 doc/jcgp/backend/population/MutableElement.html create mode 100644 doc/jcgp/backend/population/Node.html create mode 100644 doc/jcgp/backend/population/Output.html create mode 100644 doc/jcgp/backend/population/Population.html create mode 100644 doc/jcgp/backend/population/class-use/Chromosome.html create mode 100644 doc/jcgp/backend/population/class-use/Connection.html create mode 100644 doc/jcgp/backend/population/class-use/Gene.html create mode 100644 doc/jcgp/backend/population/class-use/Input.html create mode 100644 doc/jcgp/backend/population/class-use/MutableElement.html create mode 100644 doc/jcgp/backend/population/class-use/Node.html create mode 100644 doc/jcgp/backend/population/class-use/Output.html create mode 100644 doc/jcgp/backend/population/class-use/Population.html create mode 100644 doc/jcgp/backend/population/package-frame.html create mode 100644 doc/jcgp/backend/population/package-summary.html create mode 100644 doc/jcgp/backend/population/package-tree.html create mode 100644 doc/jcgp/backend/population/package-use.html (limited to 'doc/jcgp/backend/population') diff --git a/doc/jcgp/backend/population/Chromosome.html b/doc/jcgp/backend/population/Chromosome.html new file mode 100644 index 0000000..ffcb6f8 --- /dev/null +++ b/doc/jcgp/backend/population/Chromosome.html @@ -0,0 +1,742 @@ + + + + + +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.
      +
      MutableElementgetRandomMutableElement() +
      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.
        +
        +
      • +
      + + + +
        +
      • +

        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.
        +
        +
      • +
      + + + +
        +
      • +

        getInput

        +
        public Input getInput(int index)
        +
        Returns a reference to the indexed input.
        +
        +
        Parameters:
        +
        index - the input index.
        +
        Returns:
        +
        the input 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.
        +
        +
      • +
      + + + +
        +
      • +

        getRandomMutableElement

        +
        public MutableElement getRandomMutableElement()
        +
        This method is useful for mutating chromosomes. It returns any + random MutableElement 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>
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/Connection.html b/doc/jcgp/backend/population/Connection.html new file mode 100644 index 0000000..b7b5c07 --- /dev/null +++ b/doc/jcgp/backend/population/Connection.html @@ -0,0 +1,249 @@ + + + + + +Connection + + + + + + + + +
+ + + + + + + +
+ + + +
+
jcgp.backend.population
+

Interface Connection

+
+
+
+
    +
  • +
    +
    All Known Implementing Classes:
    +
    Input, Node
    +
    +
    +
    +
    public interface Connection
    +
    Connection declares the expected behaviour of any + part of a chromosome that can be connected to, specifically + nodes or inputs. Outputs are not connections since they + mark the end of chromosome paths. +

    + This interface provides a way to deal with connections + generically without having to specify whether they are nodes + or inputs. In this way a random connection can be picked and + dealt with more easily, facilitating mutations.
    +
    +
    Author:
    +
    Eduardo Pedroni
    +
    +
  • +
+
+
+
    +
  • + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getValue

        +
        java.lang.Object getValue()
        +
        Compute and return the value of this connection. In + the case of inputs no computation is necessary, this + simply returns the value the input is set to. In the + case of nodes, the value is computed based on the + node's function and the value of its own connections.
        +
        +
        Returns:
        +
        the connection's value.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/Gene.html b/doc/jcgp/backend/population/Gene.html new file mode 100644 index 0000000..0a2a9cf --- /dev/null +++ b/doc/jcgp/backend/population/Gene.html @@ -0,0 +1,241 @@ + + + + + +Gene + + + + + + + + +
+ + + + + + + +
+ + + +
+
jcgp.backend.population
+

Class Gene

+
+
+ +
+
    +
  • +
    +
    Direct Known Subclasses:
    +
    Input, Node, Output
    +
    +
    +
    +
    public abstract class Gene
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      Gene() 
      +
    • +
    + +
      +
    • + + +

      Method Summary

      +
        +
      • + + +

        Methods inherited from class java.lang.Object

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

      Constructor Detail

      + + + +
        +
      • +

        Gene

        +
        public Gene()
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/Input.html b/doc/jcgp/backend/population/Input.html new file mode 100644 index 0000000..1ac3b97 --- /dev/null +++ b/doc/jcgp/backend/population/Input.html @@ -0,0 +1,361 @@ + + + + + +Input + + + + + + + + +
+ + + + + + + +
+ + + +
+
jcgp.backend.population
+

Class Input

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Connection
    +
    +
    +
    +
    public class Input
    +extends java.lang.Object
    +implements Connection
    +
    This is a chromosome input. Inputs are a special + type of connection which simply return a set value. + They do not have connections and instead provide a + starting point for the chromosome's active paths.
    +
    +
    Author:
    +
    Eduardo Pedroni
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      Input(int index) +
      Initialises a new input with the current index.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      intgetIndex() 
      java.lang.ObjectgetValue() +
      Compute and return the value of this connection.
      +
      voidsetValue(java.lang.Object newValue) +
      Sets this input's value.
      +
      java.lang.StringtoString() 
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Input

        +
        public Input(int index)
        +
        Initialises a new input with the current index.
        +
        +
        Parameters:
        +
        index - the index of the new input.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        setValue

        +
        public void setValue(java.lang.Object newValue)
        +
        Sets this input's value. The new value + will now be returned by this input's + getValue() method.
        +
        +
        Parameters:
        +
        newValue - the value to set.
        +
        +
      • +
      + + + +
        +
      • +

        getIndex

        +
        public int getIndex()
        +
        +
        Returns:
        +
        the input's index.
        +
        +
      • +
      + + + +
        +
      • +

        getValue

        +
        public java.lang.Object getValue()
        +
        Description copied from interface: Connection
        +
        Compute and return the value of this connection. In + the case of inputs no computation is necessary, this + simply returns the value the input is set to. In the + case of nodes, the value is computed based on the + node's function and the value of its own connections.
        +
        +
        Specified by:
        +
        getValue in interface Connection
        +
        Returns:
        +
        the connection's value.
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public java.lang.String toString()
        +
        +
        Overrides:
        +
        toString in class java.lang.Object
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/MutableElement.html b/doc/jcgp/backend/population/MutableElement.html new file mode 100644 index 0000000..4af7b7e --- /dev/null +++ b/doc/jcgp/backend/population/MutableElement.html @@ -0,0 +1,306 @@ + + + + + +MutableElement + + + + + + + + +
+ + + + + + + +
+ + + +
+
jcgp.backend.population
+

Interface MutableElement

+
+
+
+
    +
  • +
    +
    All Known Implementing Classes:
    +
    Node, Output
    +
    +
    +
    +
    public interface MutableElement
    +
    MutableElement declares the expected behaviour of any + part of a chromosome that is mutable, more specifically + nodes or outputs. Inputs are not mutable since they don't have + connections or functions. +

    + This interface provides a way to deal with mutable elements + generically without having to specify whether they are nodes + or outputs. In this way a random mutable element can be picked and + dealt with more easily, facilitating mutations.
    +
    +
    Author:
    +
    Eduardo Pedroni
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + +
      All Methods Instance Methods Abstract Methods 
      Modifier and TypeMethod and Description
      booleancopyOf(MutableElement element) +
      Asserts if the specified element is a copy of the elements + this is called on.
      + This method returns true if and only if: + + the elements being compared are not the same instance; + the connections of the compared elements are not the same instance; + the elements have the same function (in the case of Node); + the grid position of the elements themselves are the same; + the grid position of all equivalent connections 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. +
      +
      voidsetConnection(int index, + Connection newConnection) +
      This method sets the indexed connection to the specified new connection.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        setConnection

        +
        void setConnection(int index,
        +                   Connection newConnection)
        +
        This method sets the indexed connection to the specified new connection. + Implementing classes may choose to ignore the given index (such as in the + case of outputs, which only have one connection).
        +
        +
        Parameters:
        +
        index - the connection index to set.
        +
        newConnection - the chromosome element to connect to.
        +
        +
      • +
      + + + +
        +
      • +

        copyOf

        +
        boolean copyOf(MutableElement element)
        +
        Asserts if the specified element is a copy of the elements + this is called on.
        + This method returns true if and only if: +
          +
        • the elements being compared are not the same instance;
        • +
        • the connections of the compared elements are not the same instance;
        • +
        • the elements have the same function (in the case of Node);
        • +
        • the grid position of the elements themselves are the same;
        • +
        • the grid position of all equivalent connections 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:
        +
        element - the mutable element to compare to.
        +
        Returns:
        +
        true if element is a copy of this element.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/Node.html b/doc/jcgp/backend/population/Node.html new file mode 100644 index 0000000..9e7b9a5 --- /dev/null +++ b/doc/jcgp/backend/population/Node.html @@ -0,0 +1,544 @@ + + + + + +Node + + + + + + + + +
+ + + + + + + +
+ + + +
+
jcgp.backend.population
+

Class Node

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Connection, MutableElement
    +
    +
    +
    +
    public class Node
    +extends java.lang.Object
    +implements MutableElement, Connection
    +
    Nodes make up the main part of the chromosome, + where the actual functions are evolved. Each node + contains a function and a number of connections. + The node outputs the result of performing its function + on the values of its connections. Nodes therefore + implement both MutableElement and Connection + since they can be mutated but also connected to. + Nodes are constructed with a fixed number of connections + (determined by the maximum arity of the function set) + and must be reinstantiated if the experiment arity + changes.
    +
    +
    Author:
    +
    Eduardo Pedroni
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      Node(Chromosome chromosome, + int row, + int column, + int arity) +
      Constructs a new instance of Node with the + specified parameters.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      booleancopyOf(MutableElement element) +
      Asserts if the specified element is a copy of the elements + this is called on.
      + This method returns true if and only if: + + the elements being compared are not the same instance; + the connections of the compared elements are not the same instance; + the elements have the same function (in the case of Node); + the grid position of the elements themselves are the same; + the grid position of all equivalent connections 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. +
      +
      intgetColumn() 
      ConnectiongetConnection(int index) 
      FunctiongetFunction() 
      intgetRow() 
      java.lang.ObjectgetValue() +
      Compute and return the value of this connection.
      +
      voidinitialise(Function newFunction, + Connection... newConnections) +
      Initialises the node with the specified values.
      +
      voidsetConnection(int index, + Connection newConnection) +
      This method sets the indexed connection to the specified new connection.
      +
      voidsetFunction(Function newFunction) +
      Sets the node function.
      +
      java.lang.StringtoString() 
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Node

        +
        public Node(Chromosome chromosome,
        +            int row,
        +            int column,
        +            int arity)
        +
        Constructs a new instance of Node with the + specified parameters. Nodes must contain their + own row and column for ease of copying.
        +
        +
        Parameters:
        +
        chromosome - the chromosome this node belongs to.
        +
        row - the node's row.
        +
        column - the node's column.
        +
        arity - the maximum arity of the experiment.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        setFunction

        +
        public void setFunction(Function newFunction)
        +
        Sets the node function.
        +
        +
        Parameters:
        +
        newFunction - the new function to set.
        +
        +
      • +
      + + + +
        +
      • +

        initialise

        +
        public void initialise(Function newFunction,
        +                       Connection... newConnections)
        +
        Initialises the node with the specified values. + The number of connections passed as argument must + be exactly the same as the experiment arity, or + an IllegalArgumentException will be thrown.
        +
        +
        Parameters:
        +
        newFunction - the node function to set.
        +
        newConnections - the node connections to set.
        +
        +
      • +
      + + + +
        +
      • +

        getColumn

        +
        public int getColumn()
        +
        +
        Returns:
        +
        this node's column.
        +
        +
      • +
      + + + +
        +
      • +

        getRow

        +
        public int getRow()
        +
        +
        Returns:
        +
        this node's row.
        +
        +
      • +
      + + + +
        +
      • +

        getFunction

        +
        public Function getFunction()
        +
        +
        Returns:
        +
        this node's function.
        +
        +
      • +
      + + + +
        +
      • +

        getConnection

        +
        public Connection getConnection(int index)
        +
        +
        Parameters:
        +
        index - the connection to return.
        +
        Returns:
        +
        the indexed connection.
        +
        +
      • +
      + + + +
        +
      • +

        copyOf

        +
        public boolean copyOf(MutableElement element)
        +
        Description copied from interface: MutableElement
        +
        Asserts if the specified element is a copy of the elements + this is called on.
        + This method returns true if and only if: +
          +
        • the elements being compared are not the same instance;
        • +
        • the connections of the compared elements are not the same instance;
        • +
        • the elements have the same function (in the case of Node);
        • +
        • the grid position of the elements themselves are the same;
        • +
        • the grid position of all equivalent connections 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.
        • +
        +
        +
        Specified by:
        +
        copyOf in interface MutableElement
        +
        Parameters:
        +
        element - the mutable element to compare to.
        +
        Returns:
        +
        true if element is a copy of this element.
        +
        +
      • +
      + + + +
        +
      • +

        getValue

        +
        public java.lang.Object getValue()
        +
        Description copied from interface: Connection
        +
        Compute and return the value of this connection. In + the case of inputs no computation is necessary, this + simply returns the value the input is set to. In the + case of nodes, the value is computed based on the + node's function and the value of its own connections.
        +
        +
        Specified by:
        +
        getValue in interface Connection
        +
        Returns:
        +
        the connection's value.
        +
        +
      • +
      + + + +
        +
      • +

        setConnection

        +
        public void setConnection(int index,
        +                          Connection newConnection)
        +
        Description copied from interface: MutableElement
        +
        This method sets the indexed connection to the specified new connection. + Implementing classes may choose to ignore the given index (such as in the + case of outputs, which only have one connection).
        +
        +
        Specified by:
        +
        setConnection in interface MutableElement
        +
        Parameters:
        +
        index - the connection index to set.
        +
        newConnection - the chromosome element to connect to.
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public java.lang.String toString()
        +
        +
        Overrides:
        +
        toString in class java.lang.Object
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/Output.html b/doc/jcgp/backend/population/Output.html new file mode 100644 index 0000000..38033e2 --- /dev/null +++ b/doc/jcgp/backend/population/Output.html @@ -0,0 +1,447 @@ + + + + + +Output + + + + + + + + +
+ + + + + + + +
+ + + +
+
jcgp.backend.population
+

Class Output

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    MutableElement
    +
    +
    +
    +
    public class Output
    +extends java.lang.Object
    +implements MutableElement
    +
    This is a chromosome output. Outputs are a special + type of mutable element with a single connection. It + returns the value of its single connection, but it + may not be connected to - it terminates a chromosome + active connection path.
    +
    +
    Author:
    +
    Eduardo Pedroni
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      Output(Chromosome chromosome, + int index) +
      Makes a new instance of Output with the + specified arguments.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      java.lang.Objectcalculate() 
      booleancopyOf(MutableElement m) +
      Asserts if the specified element is a copy of the elements + this is called on.
      + This method returns true if and only if: + + the elements being compared are not the same instance; + the connections of the compared elements are not the same instance; + the elements have the same function (in the case of Node); + the grid position of the elements themselves are the same; + the grid position of all equivalent connections 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. +
      +
      voidgetActiveNodes(java.util.ArrayList<Node> activeNodes) 
      intgetIndex() 
      ConnectiongetSource() 
      voidsetConnection(int index, + Connection newConnection) +
      When mutating an output, the index parameter + is simply ignored and the output source is + set.
      +
      java.lang.StringtoString() 
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Output

        +
        public Output(Chromosome chromosome,
        +              int index)
        +
        Makes a new instance of Output with the + specified arguments.
        +
        +
        Parameters:
        +
        chromosome - the chromosome this output belongs to.
        +
        index - the output index.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        calculate

        +
        public java.lang.Object calculate()
        +
        +
        Returns:
        +
        the value of the output's source.
        +
        +
      • +
      + + + +
        +
      • +

        getIndex

        +
        public int getIndex()
        +
      • +
      + + + +
        +
      • +

        getSource

        +
        public Connection getSource()
        +
      • +
      + + + +
        +
      • +

        getActiveNodes

        +
        public void getActiveNodes(java.util.ArrayList<Node> activeNodes)
        +
      • +
      + + + + + + + +
        +
      • +

        copyOf

        +
        public boolean copyOf(MutableElement m)
        +
        Description copied from interface: MutableElement
        +
        Asserts if the specified element is a copy of the elements + this is called on.
        + This method returns true if and only if: +
          +
        • the elements being compared are not the same instance;
        • +
        • the connections of the compared elements are not the same instance;
        • +
        • the elements have the same function (in the case of Node);
        • +
        • the grid position of the elements themselves are the same;
        • +
        • the grid position of all equivalent connections 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.
        • +
        +
        +
        Specified by:
        +
        copyOf in interface MutableElement
        +
        Parameters:
        +
        m - the mutable element to compare to.
        +
        Returns:
        +
        true if element is a copy of this element.
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public java.lang.String toString()
        +
        +
        Overrides:
        +
        toString in class java.lang.Object
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/Population.html b/doc/jcgp/backend/population/Population.html new file mode 100644 index 0000000..b28fd28 --- /dev/null +++ b/doc/jcgp/backend/population/Population.html @@ -0,0 +1,411 @@ + + + + + +Population + + + + + + + + +
+ + + + + + + +
+ + + +
+
jcgp.backend.population
+

Class Population

+
+
+ +
+
    +
  • +
    +
    +
    public class Population
    +extends java.lang.Object
    +
    This class primarily holds a collection of chromosomes. In addition, + it provides a few utility methods for manipulating and copying + chromosomes, useful for evolutionary strategies. +

    + copyChromosome() is used to create copies of chromosomes, + though it is also possible to create a new instance of population + directly from a seed chromosome using the right constructor. +

    + For convenience, a random chromosome can be retrieved using + getRandomChromosome(), which is guaranteed to use the + experiment's specified seed. If an entirely random population + is needed, reinitialise() should be used to randomise + all chromosomes without creating a new instance of Population.
    +
    +
    Author:
    +
    Eduardo Pedroni
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      Population(Chromosome parent, + Resources resources) +
      Initialise a population of copies of the given chromosome.
      +
      Population(Resources resources) +
      Initialise a random population according to the parameters specified + in the resources.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      voidcopyChromosome(int source, + int target) +
      Copy a chromosome into a different position.
      +
      Chromosomeget(int index) +
      Returns the indexed chromosome.
      +
      ChromosomegetRandomChromosome() 
      voidreinitialise() +
      Loop through all chromosomes and randomise all connections + and functions.
      +
      voidsort() +
      Sorts the population in ascending order of fitness quality.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

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

      Constructor Detail

      + + + +
        +
      • +

        Population

        +
        public Population(Resources resources)
        +
        Initialise a random population according to the parameters specified + in the resources.
        +
        +
        Parameters:
        +
        resources - the experiment's resources.
        +
        +
      • +
      + + + +
        +
      • +

        Population

        +
        public Population(Chromosome parent,
        +                  Resources resources)
        +
        Initialise a population of copies of the given chromosome.
        +
        +
        Parameters:
        +
        parent - the chromosome to use as a model.
        +
        resources - a reference to the experiment's resources.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        get

        +
        public Chromosome get(int index)
        +
        Returns the indexed chromosome.
        +
        +
        Parameters:
        +
        index - the chromosome to return.
        +
        Returns:
        +
        the indexed chromosome.
        +
        +
      • +
      + + + +
        +
      • +

        getRandomChromosome

        +
        public Chromosome getRandomChromosome()
        +
        +
        Returns:
        +
        a random chromosome from this population.
        +
        +
      • +
      + + + +
        +
      • +

        copyChromosome

        +
        public void copyChromosome(int source,
        +                           int target)
        +
        Copy a chromosome into a different position. + After this returns, the target chromosome has + identical connections and functions to the source + one, though they are separate instances. + + This method does nothing if source == target.
        +
        +
        Parameters:
        +
        source - the chromosome to copy from.
        +
        target - the chromosome to copy to.
        +
        +
      • +
      + + + +
        +
      • +

        reinitialise

        +
        public void reinitialise()
        +
        Loop through all chromosomes and randomise all connections + and functions.
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public void sort()
        +
        Sorts the population in ascending order of fitness quality. + What this means is that the best fitness chromosome will be + in the last position, even though it might have the lowest + fitness value. Fitness orientation as specified in the resources + is respected.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/class-use/Chromosome.html b/doc/jcgp/backend/population/class-use/Chromosome.html new file mode 100644 index 0000000..4245432 --- /dev/null +++ b/doc/jcgp/backend/population/class-use/Chromosome.html @@ -0,0 +1,340 @@ + + + + + +Uses of Class jcgp.backend.population.Chromosome + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
jcgp.backend.population.Chromosome

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/class-use/Connection.html b/doc/jcgp/backend/population/class-use/Connection.html new file mode 100644 index 0000000..72f2fb4 --- /dev/null +++ b/doc/jcgp/backend/population/class-use/Connection.html @@ -0,0 +1,301 @@ + + + + + +Uses of Interface jcgp.backend.population.Connection + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Interface
jcgp.backend.population.Connection

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/class-use/Gene.html b/doc/jcgp/backend/population/class-use/Gene.html new file mode 100644 index 0000000..d042783 --- /dev/null +++ b/doc/jcgp/backend/population/class-use/Gene.html @@ -0,0 +1,194 @@ + + + + + +Uses of Class jcgp.backend.population.Gene + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
jcgp.backend.population.Gene

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/class-use/Input.html b/doc/jcgp/backend/population/class-use/Input.html new file mode 100644 index 0000000..61c38ce --- /dev/null +++ b/doc/jcgp/backend/population/class-use/Input.html @@ -0,0 +1,187 @@ + + + + + +Uses of Class jcgp.backend.population.Input + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
jcgp.backend.population.Input

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/class-use/MutableElement.html b/doc/jcgp/backend/population/class-use/MutableElement.html new file mode 100644 index 0000000..77bf35f --- /dev/null +++ b/doc/jcgp/backend/population/class-use/MutableElement.html @@ -0,0 +1,228 @@ + + + + + +Uses of Interface jcgp.backend.population.MutableElement + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Interface
jcgp.backend.population.MutableElement

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/class-use/Node.html b/doc/jcgp/backend/population/class-use/Node.html new file mode 100644 index 0000000..6dd76ee --- /dev/null +++ b/doc/jcgp/backend/population/class-use/Node.html @@ -0,0 +1,244 @@ + + + + + +Uses of Class jcgp.backend.population.Node + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
jcgp.backend.population.Node

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/class-use/Output.html b/doc/jcgp/backend/population/class-use/Output.html new file mode 100644 index 0000000..19bd12a --- /dev/null +++ b/doc/jcgp/backend/population/class-use/Output.html @@ -0,0 +1,202 @@ + + + + + +Uses of Class jcgp.backend.population.Output + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
jcgp.backend.population.Output

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/class-use/Population.html b/doc/jcgp/backend/population/class-use/Population.html new file mode 100644 index 0000000..d98d156 --- /dev/null +++ b/doc/jcgp/backend/population/class-use/Population.html @@ -0,0 +1,265 @@ + + + + + +Uses of Class jcgp.backend.population.Population + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
jcgp.backend.population.Population

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/package-frame.html b/doc/jcgp/backend/population/package-frame.html new file mode 100644 index 0000000..f000a2f --- /dev/null +++ b/doc/jcgp/backend/population/package-frame.html @@ -0,0 +1,29 @@ + + + + + +jcgp.backend.population + + + + + +

jcgp.backend.population

+
+

Interfaces

+ +

Classes

+ +
+ + diff --git a/doc/jcgp/backend/population/package-summary.html b/doc/jcgp/backend/population/package-summary.html new file mode 100644 index 0000000..ac0ec7b --- /dev/null +++ b/doc/jcgp/backend/population/package-summary.html @@ -0,0 +1,196 @@ + + + + + +jcgp.backend.population + + + + + + + + +
+ + + + + + + +
+ + +
+

Package jcgp.backend.population

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/package-tree.html b/doc/jcgp/backend/population/package-tree.html new file mode 100644 index 0000000..d436925 --- /dev/null +++ b/doc/jcgp/backend/population/package-tree.html @@ -0,0 +1,146 @@ + + + + + +jcgp.backend.population Class Hierarchy + + + + + + + + +
+ + + + + + + +
+ + +
+

Hierarchy For Package jcgp.backend.population

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +

Interface Hierarchy

+ +
+ +
+ + + + + + + +
+ + + + diff --git a/doc/jcgp/backend/population/package-use.html b/doc/jcgp/backend/population/package-use.html new file mode 100644 index 0000000..0c65c85 --- /dev/null +++ b/doc/jcgp/backend/population/package-use.html @@ -0,0 +1,338 @@ + + + + + +Uses of Package jcgp.backend.population + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Package
jcgp.backend.population

+
+
+ +
+ +
+ + + + + + + +
+ + + + -- cgit v1.2.3