Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ec.cgp.representation
Class VectorSpeciesCGP

    java.lang.Object
      ec.Species
          ec.vector.VectorSpecies
              ec.cgp.representation.VectorSpeciesCGP

All Implemented Interfaces:
  ec.Prototype, ec.Setup, java.io.Serializable, java.lang.Cloneable

Direct Known Subclasses:
  FloatVectorSpecies, IntegerVectorSpecies

    public abstract class VectorSpeciesCGP

extends ec.vector.VectorSpecies

The CGPVectorSpecies handles much of the behavior and representation of Cartesian Genetic Programs. It is here that the phenotype/genotype mappings and various representational constraints are imposed.

Author:
  David Oranchak, doranchak@gmail.com, http://oranchak.com
See Also:
  Serialized Form

Field Summary
`static int` | `GENE_ARGUMENT` Gene position that represents a function argument
`static int` | `GENE_FUNCTION` Gene position that represents a function reference
`static int` | `GENE_OUTPUT` Gene position that represents an output node
`int` | `maxArity` Max arity of the function set
`int` | `numFunctions` Number of functions in the function set.
`int` | `numInputs` Number of input nodes.
`int` | `numNodes` Number of function call nodes comprising the CGP.
`int` | `numOutputs` Number of output nodes
`static java.lang.String` | `P_FUNCTIONS`
`static java.lang.String` | `P_MAX_ARITY`
`static java.lang.String` | `P_NUM_FUNCTIONS`
`static java.lang.String` | `P_NUM_INPUTS`
`static java.lang.String` | `P_NUM_NODES`
`static java.lang.String` | `P_NUM_OUTPUTS`
`static java.lang.String` | `P_VECTORSPECIES` configuration names used in the parameter files

Fields inherited from class ec.vector.VectorSpecies
`C_ANY_POINT, C_ONE_POINT, C_TWO_POINT, chunksize, crossoverProbability, crossoverType, genomeSize, mutationProbability, P_CHUNKSIZE, P_CROSSOVERPROB, P_CROSSOVERTYPE, P_GENOMESIZE, P_MUTATIONPROB, V_ANY_POINT, V_ONE_POINT, V_TWO_POINT`

Fields inherited from class ec.Species
`f_prototype, i_prototype, P_FITNESS, P_INDIVIDUAL, P_PIPE, pipe_prototype`

Constructor Summary
`VectorSpeciesCGP()`

Method Summary
`int` | `computeMaxGene(int position, float[] genome)` Computes max possible gene value for the given position.
`int` | `computeMaxGene(int position, int[] genome)` Computes max possible gene value for the given position.
`ec.util.Parameter` | `defaultBase()` Returns the default base for this prototype.
`int` | `function(int position, float[] genome)` Determine the function number from the given genome and position (int version).
`int` | `function(int position, int[] genome)` Determine the function number from the given genome and position (float version).
`(package private) int` | `functionSub(int position)` Computation shared by both function(position, genome) methods.
`int` | `interpretFloat(int pos, float[] genome)` Interprets float at position pos based on max possible int represented by that position.
`int` | `nodeNumber(int position, float[] genome)` Determine the node number from the given genome position.
`int` | `nodeNumber(int position, int[] genome)` Determine the node number from the given genome position.
`int` | `numGenes()` Computes the total number of gene values needed for all function and output nodes (a gene in this sense is a single element of the underlying genome vector)
`int` | `phenotype(int position, float[] genome)` From the given genome position, determine the phenotype (float version)
`int` | `phenotype(int position, int[] genome)` From the given genome position, determine the phenotype (int version)
`static java.lang.String` | `phenotypeDescription(int phenotype)` Get a simple description of the given phenotype
`int` | `positionFromNodeNumber(int nodeNumber)` Determine the start position of the given node number.
`void` | `setup(ec.EvolutionState state, ec.util.Parameter base)` The default version of setup(...) loads requested pipelines and calls setup(...) on them and normalizes their probabilities.
`java.lang.String` | `toString()`

Methods inherited from class ec.vector.VectorSpecies
`newIndividual`

Methods inherited from class ec.Species
`clone, newIndividual, newIndividual`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### GENE_OUTPUT

    public static final int GENE_OUTPUT

  Gene position that represents an output node

  See Also:
    Constant Field Values

### GENE_FUNCTION

    public static final int GENE_FUNCTION

  Gene position that represents a function reference

  See Also:
    Constant Field Values

### GENE_ARGUMENT

    public static final int GENE_ARGUMENT

  Gene position that represents a function argument

  See Also:
    Constant Field Values

### P_VECTORSPECIES

    public static final java.lang.String P_VECTORSPECIES

  configuration names used in the parameter files

  See Also:
    Constant Field Values

### P_NUM_NODES

    public static final java.lang.String P_NUM_NODES

See Also:
  Constant Field Values

### P_NUM_INPUTS

    public static final java.lang.String P_NUM_INPUTS

See Also:
  Constant Field Values

### P_NUM_OUTPUTS

    public static final java.lang.String P_NUM_OUTPUTS

See Also:
  Constant Field Values

### P_NUM_FUNCTIONS

    public static final java.lang.String P_NUM_FUNCTIONS

See Also:
  Constant Field Values

### P_MAX_ARITY

    public static final java.lang.String P_MAX_ARITY

See Also:
  Constant Field Values

### P_FUNCTIONS

    public static final java.lang.String P_FUNCTIONS

See Also:
  Constant Field Values

### numNodes

    public int numNodes

  Number of function call nodes comprising the CGP. Does not include output nodes.

### numInputs

    public int numInputs

  Number of input nodes. Includes any automatically-managed constants (see CGPProblem).

### numOutputs

    public int numOutputs

  Number of output nodes

### numFunctions

    public int numFunctions

  Number of functions in the function set.

### maxArity

    public int maxArity

  Max arity of the function set

Constructor Detail

### VectorSpeciesCGP

    public VectorSpeciesCGP()

Method Detail

### numGenes

    public int numGenes()

  Computes the total number of gene values needed for all function and output nodes (a gene in this sense is a single element of the underlying genome vector)

### function

    public int function(int position,
                        float[] genome)

  Determine the function number from the given genome and position (int version).

### function

    public int function(int position,
                        int[] genome)

  Determine the function number from the given genome and position (float version).

### functionSub

    int functionSub(int position)

  Computation shared by both function(position, genome) methods. Returns function position that corresponds to the given position.

### phenotype

    public int phenotype(int position,
                         int[] genome)

  From the given genome position, determine the phenotype (int version)

### phenotype

    public int phenotype(int position,
                         float[] genome)

  From the given genome position, determine the phenotype (float version)

### interpretFloat

    public int interpretFloat(int pos,
                              float[] genome)

  Interprets float at position pos based on max possible int represented by that position.

### computeMaxGene

    public int computeMaxGene(int position,
                              int[] genome)

  Computes max possible gene value for the given position. Min gene value is assumed to always be zero. The max value depends on the phenotype of the given position.

### computeMaxGene

    public int computeMaxGene(int position,
                              float[] genome)

  Computes max possible gene value for the given position. Min gene value is assumed to always be zero. The max value depends on the phenotype of the given position.

### nodeNumber

    public int nodeNumber(int position,
                          int[] genome)

  Determine the node number from the given genome position. Function arguments refer to node numbers. Inputs are numbered from [0, numInputs - 1]. Function nodes are numbered from [numInputs, numInputs + numNodes - 1]. Output nodes are numbered from [numInputs + numNodes, numInputs + numNodes + numOuputs - 1].

### nodeNumber

    public int nodeNumber(int position,
                          float[] genome)

  Determine the node number from the given genome position. Function arguments refer to node numbers. Inputs are numbered from [0, numInputs - 1]. Function nodes are numbered from [numInputs, numInputs + numNodes - 1]. Output nodes are numbered from [numInputs + numNodes, numInputs + numNodes + numOuputs - 1].

### positionFromNodeNumber

    public int positionFromNodeNumber(int nodeNumber)

  Determine the start position of the given node number. WARNING: do not call this with a nodeNumber < numInputs, because the inputs are not represented in the genome.

### defaultBase

    public ec.util.Parameter defaultBase()

  Description copied from interface: `ec.Prototype`
  Returns the default base for this prototype. This should generally be implemented by building off of the static base() method on the DefaultsForm object for the prototype's package. This should be callable during setup(...).

  Specified by:
    `defaultBase` in interface `ec.Prototype`
  Overrides:
    `defaultBase` in class `ec.vector.VectorSpecies`

### setup

    public void setup(ec.EvolutionState state,
                      ec.util.Parameter base)

  Description copied from class: `ec.Species`
  The default version of setup(...) loads requested pipelines and calls setup(...) on them and normalizes their probabilities. If your individual prototype might need to know special things about the species (like parameters stored in it), then when you override this setup method, you'll need to set those parameters BEFORE you call super.setup(...), because the setup(...) code in Species sets up the prototype.

  Specified by:
    `setup` in interface `ec.Prototype`
  Specified by:
    `setup` in interface `ec.Setup`
  Overrides:
    `setup` in class `ec.vector.VectorSpecies`
  See Also:
    `Prototype.setup(EvolutionState,Parameter)`

### phenotypeDescription

    public static java.lang.String phenotypeDescription(int phenotype)

  Get a simple description of the given phenotype

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD