com.anji.neat
Class NeatChromosomeUtility

java.lang.Object
  extended bycom.anji.neat.NeatChromosomeUtility

public class NeatChromosomeUtility
extends java.lang.Object

Utility class capturing functionality pertaining to NEAT neuron and connection genes.

Author:
Philip Tucker

Constructor Summary
NeatChromosomeUtility()
           
 
Method Summary
static java.util.Collection extractConnectionAllelesForDestNeurons(java.util.Collection connAlleles, java.util.Collection destNeuronInnovationIds)
           
static java.util.Collection extractConnectionAllelesForSrcNeurons(java.util.Collection connAlleles, java.util.Collection srcNeuronInnovationIds)
           
static java.util.List getConnectionList(java.util.Collection alleles)
          returns all connection genes in genes as List
static java.util.SortedMap getConnectionMap(java.util.Set alleles)
          returns all connections in alleles as SortedMap
static java.util.List getNeuronList(java.util.Collection alleles)
          return all neurons in genes as List
static java.util.List getNeuronList(java.util.Collection alleles, NeuronType type)
          if type == null, returns all neuron genes in genes; otherwise, returns only neuron genes of type
static java.util.SortedMap getNeuronMap(java.util.Collection alleles)
          return all neurons in alleles as SortedMap
static java.util.SortedMap getNeuronMap(java.util.Collection alleles, NeuronType type)
          if type == null, returns all neurons in alleles; otherwise, returns only neurons of type
static boolean neuronsAreConnected(java.lang.Long srcNeuronId, java.lang.Long destNeuronId, java.util.Collection connGenes)
          non-recursive starting point for recursive search
static ChromosomeMaterial newSampleChromosomeMaterial(short newNumInputs, short newNumHidden, short newNumOutputs, NeatConfiguration config, boolean fullyConnected)
          factory method to construct chromosome material for neural net with specified input and output dimension, JGAP/NEAT configuration, and amount of connectivity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NeatChromosomeUtility

public NeatChromosomeUtility()
Method Detail

newSampleChromosomeMaterial

public static ChromosomeMaterial newSampleChromosomeMaterial(short newNumInputs,
                                                             short newNumHidden,
                                                             short newNumOutputs,
                                                             NeatConfiguration config,
                                                             boolean fullyConnected)
factory method to construct chromosome material for neural net with specified input and output dimension, JGAP/NEAT configuration, and amount of connectivity

Parameters:
newNumInputs -
newNumHidden -
newNumOutputs -
config -
fullyConnected - all layers fully connected if true, not connected at all otherwise
Returns:
ChromosomeMaterial

extractConnectionAllelesForDestNeurons

public static java.util.Collection extractConnectionAllelesForDestNeurons(java.util.Collection connAlleles,
                                                                          java.util.Collection destNeuronInnovationIds)
Parameters:
connAlleles - Collection contains ConnectionA llele objects
destNeuronInnovationIds - Collection contains Long objects
Returns:
Collection containing ConnectionAllele objects, those in connAlleles whose destination neuron is in destNeuronInnovationIds

extractConnectionAllelesForSrcNeurons

public static java.util.Collection extractConnectionAllelesForSrcNeurons(java.util.Collection connAlleles,
                                                                         java.util.Collection srcNeuronInnovationIds)
Parameters:
connAlleles - Collection contains ConnectionGene objects
srcNeuronInnovationIds - Collection contains Long objects
Returns:
Collection containing ConnectionGene objects, those in connGenes whose source neuron is srcNeuronGene

getNeuronMap

public static java.util.SortedMap getNeuronMap(java.util.Collection alleles)
return all neurons in alleles as SortedMap

Parameters:
alleles - Collection contains Allele objects
Returns:
SortedMap containing key Long innovation id, value NeuronGene objects
See Also:
getNeuronMap(Collection, NeuronType)

getNeuronList

public static java.util.List getNeuronList(java.util.Collection alleles)
return all neurons in genes as List

Parameters:
alleles - Collection contains Allele objects
Returns:
List containing NeuronGene objects
See Also:
getNeuronList(Collection, NeuronType)

getNeuronMap

public static java.util.SortedMap getNeuronMap(java.util.Collection alleles,
                                               NeuronType type)
if type == null, returns all neurons in alleles; otherwise, returns only neurons of type

Parameters:
alleles - Collection contains Allele objects
type -
Returns:
SortedMap contains key Long innovation id, value NeuronGene objects

getNeuronList

public static java.util.List getNeuronList(java.util.Collection alleles,
                                           NeuronType type)
if type == null, returns all neuron genes in genes; otherwise, returns only neuron genes of type

Parameters:
alleles - Collection contains gene objects
type -
Returns:
List contains NeuronAllele objects

getConnectionMap

public static java.util.SortedMap getConnectionMap(java.util.Set alleles)
returns all connections in alleles as SortedMap

Parameters:
alleles - SortedSet contains Allele objects
Returns:
SortedMap containing key Long innovation id, value ConnectionAllele objects

getConnectionList

public static java.util.List getConnectionList(java.util.Collection alleles)
returns all connection genes in genes as List

Parameters:
alleles - Collection contains gene objects
Returns:
List containing ConnectionGene objects

neuronsAreConnected

public static boolean neuronsAreConnected(java.lang.Long srcNeuronId,
                                          java.lang.Long destNeuronId,
                                          java.util.Collection connGenes)
non-recursive starting point for recursive search

Parameters:
srcNeuronId -
destNeuronId -
connGenes -
Returns:
true if srcNeuronId and destNeuronId are connected
See Also:
NeatChromosomeUtility#neuronsAreConnected(Long, Long, Collection, Set)