Package ec.neat

Class NEATSpecies

All Implemented Interfaces:
Prototype, Setup, Serializable, Cloneable

public class NEATSpecies extends GeneVectorSpecies
NEATSpecies is a GeneVectorSpecies which implements NEAT algorithm. The class has several important methods. The breedNewPopulation(...) will first use the methods in this class to determined the expected offsprings for each of the subspecies, then call the reproduce of each subspecies to reproduce new individuals. After one individual is created, we call speciate(...) in this class to assign it to a subspecies, this could lead to creation of new subspecies.

NEATSpecies must be used in combination with NEATBreeder, which will call it at appropriate times to reproduce new individuals for next generations. It must also be used in combination with NEATInitializer, which will use it to generate the initial population.

Parameters

r
base.weight-mut-power
Floating-point value (default is 2.5)
Mutation power of the link weights
base.disjoint-coeff
Floating-point value (default is 1.0)
Coefficient for disjoint gene in compatibility computation
base.excess-coeff
Floating-point value (default is 1.0)
Coefficient for excess genes in compatibility computation
base.mutdiff-coeff
Floating-point value (default is 0.4)
Coefficient for mutational difference genes in compatibility computation
base.compat-thresh
Floating-point value (default is 3.0)
Compatible threshold to determine if two individual are compatible
base.age-significance
Floating-point value (default is 1.0)
How much does age matter?
base.survival-thresh
Floating-point value (default is 0.2)
Percent of ave fitness for survival
base.mutate-only-prob
Floating-point value (default is 0.25)
Probability of a non-mating reproduction
base.mutate-link-weight-prob
Floating-point value (default is 0.9)
Probability of doing link weight mutate
base.mutate-toggle-enable-prob
Floating-point value (default is 0.0)
Probability of changing the enable status of gene
base.mutate-gene-reenable-prob
Floating-point value (default is 0.0)
Probability of reenable a disabled gene
base.mutate-add-node-prob
Floating-point value (default is 0.03)
Probability of doing add-node mutation
base.mutate-add-link-prob
Floating-point value (default is 0.05)
Probability of doing add-link mutation
base.interspecies-mate-prob
Floating-point value (default is 0.001)
Probability of doing interspecies crossover
base.mate-multipoint-prob
Floating-point value (default is 0.6)
Probability of doing multipoint crossover
base.mate-multipoint-avg-prob
Floating-point value (default is 0.4)
Probability of doing multipoint crossover with averaging two genes
base.mate-singlepoint-prob
Floating-point value (default is 0.0)
Probability of doing single point crossover (not in used in this implementation, always set to 0)
base.mate-only-prob
Floating-point value (default is 0.2)
Probability of mating without mutation
base.recur-only-prob
Floating-point value (default is 0.2)
Probability of forcing selection of ONLY links that are naturally recurrent
base.dropoff-age
Integer (default is 15)
Age where Species starts to be penalized
base.new-link-tries
Integer (default is 20)
Number of tries mutateAddLink will attempt to find an open link
base.new-node-tries
Integer (default is 20)
Number of tries mutateAddNode will attempt to build a valid node.
base.add-node-max-genome-length
Integer (default is 15)
For genomes this size or larger, mutateAddNode will do a pure random split when adding the node.
base.babies-stolen
Integer (default is 0)
The number of babies to siphen off to the champions
base.node
Classname, = ec.neat.NEATNode
Class of node in a network
base.subspecies
Classname, = ec.neat.NEATSubspecies
Class of subspecies in the species
base.innovation
Classname, = ec.neat.NEATInnovation
Class of innovation in the species

Default Base
neat.species

Parameter bases

See Also:
  • Field Details

    • P_SPECIES

      public static final String P_SPECIES
      See Also:
    • P_NODE

      public static final String P_NODE
      See Also:
    • P_NETWORK

      public static final String P_NETWORK
      See Also:
    • P_SUBSPECIES

      public static final String P_SUBSPECIES
      See Also:
    • P_INNOVATION

      public static final String P_INNOVATION
      See Also:
    • P_WEIGHT_MUT_POWER

      public static final String P_WEIGHT_MUT_POWER
      See Also:
    • P_DISJOINT_COEFF

      public static final String P_DISJOINT_COEFF
      See Also:
    • P_EXCESS_COEFF

      public static final String P_EXCESS_COEFF
      See Also:
    • P_MUT_DIFF_COEFF

      public static final String P_MUT_DIFF_COEFF
      See Also:
    • P_COMPAT_THRESH

      public static final String P_COMPAT_THRESH
      See Also:
    • P_AGE_SIGNIFICANCE

      public static final String P_AGE_SIGNIFICANCE
      See Also:
    • P_SURVIVIAL_THRESH

      public static final String P_SURVIVIAL_THRESH
      See Also:
    • P_MUTATE_ONLY_PROB

      public static final String P_MUTATE_ONLY_PROB
      See Also:
    • P_MUTATE_TOGGLE_ENABLE_PROB

      public static final String P_MUTATE_TOGGLE_ENABLE_PROB
      See Also:
    • P_MUTATE_GENE_REENABLE_PROB

      public static final String P_MUTATE_GENE_REENABLE_PROB
      See Also:
    • P_MUTATE_ADD_NODE_PROB

      public static final String P_MUTATE_ADD_NODE_PROB
      See Also:
    • P_INTERSPECIES_MATE_PROB

      public static final String P_INTERSPECIES_MATE_PROB
      See Also:
    • P_MATE_MULTIPOINT_PROB

      public static final String P_MATE_MULTIPOINT_PROB
      See Also:
    • P_MATE_MULTIPOINT_AVG_PROB

      public static final String P_MATE_MULTIPOINT_AVG_PROB
      See Also:
    • P_MATE_SINGLE_POINT_PROB

      public static final String P_MATE_SINGLE_POINT_PROB
      See Also:
    • P_MATE_ONLY_PROB

      public static final String P_MATE_ONLY_PROB
      See Also:
    • P_RECUR_ONLY_PROB

      public static final String P_RECUR_ONLY_PROB
      See Also:
    • P_DROPOFF_AGE

      public static final String P_DROPOFF_AGE
      See Also:
    • P_NEW_NODE_TRIES

      public static final String P_NEW_NODE_TRIES
      See Also:
    • P_BABIES_STOLEN

      public static final String P_BABIES_STOLEN
      See Also:
    • P_MAX_NETWORK_DEPTH

      public static final String P_MAX_NETWORK_DEPTH
      See Also:
    • P_ADD_NODE_MAX_GENOME_LENGTH

      public static final String P_ADD_NODE_MAX_GENOME_LENGTH
      See Also:
    • nodePrototype

      public NEATNode nodePrototype
      The prototypical node for individuals in this species.
    • networkPrototype

      public NEATNetwork networkPrototype
      The prototypical network.
    • subspeciesPrototype

      public NEATSubspecies subspeciesPrototype
      The prototypical subspecies for individuals in this species.
    • innovationPrototype

      public NEATInnovation innovationPrototype
      The prototypical innovation for individuals in this species.
    • currNodeId

      public int currNodeId
      Current node id that is available.
    • highestFitness

      public double highestFitness
      Used for delta coding, stagnation detector.
    • highestLastChanged

      public int highestLastChanged
      Used for delta coding, If too high, leads to delta coding.
    • weightMutationPower

      public double weightMutationPower
      The Mutation power of the link's weights.
    • disjointCoeff

      public double disjointCoeff
      Coefficient for disjoint gene in compatibility computation.
    • excessCoeff

      public double excessCoeff
      Coefficient for excess genes in compatibility computation.
    • mutDiffCoeff

      public double mutDiffCoeff
      Coefficient for mutational difference genes in compatibility computation.
    • compatThreshold

      public double compatThreshold
      Compatible threshold to determine if two individual are compatible.
    • ageSignificance

      public double ageSignificance
      How much does age matter?
    • survivalThreshold

      public double survivalThreshold
      Percent of ave fitness for survival.
    • mutateOnlyProb

      public double mutateOnlyProb
      Probility of a non-mating reproduction.
    • mutateLinkWeightsProb

      public double mutateLinkWeightsProb
      Probability of doing link weight mutate.
    • mutateToggleEnableProb

      public double mutateToggleEnableProb
      Probability of changing the enable status of gene.
    • mutateGeneReenableProb

      public double mutateGeneReenableProb
      Probability of reenable a disabled gene.
    • mutateAddNodeProb

      public double mutateAddNodeProb
      Probability of doing add-node mutation.
    • mutateAddLinkProb

      public double mutateAddLinkProb
      Probability of doing add-link mutation.
    • interspeciesMateRate

      public double interspeciesMateRate
      Probability of doing interspecies crossover.
    • mateMultipointProb

      public double mateMultipointProb
      Probability of doing multipoint crossover.
    • mateMultipointAvgProb

      public double mateMultipointAvgProb
      Probability of doing multipoint crossover with averaging two genes.
    • mateSinglepointProb

      public double mateSinglepointProb
      Probability of doing single point crossover (not in used in this implementation, always set to 0).
    • mateOnlyProb

      public double mateOnlyProb
      Probability of mating without mutation.
    • recurOnlyProb

      public double recurOnlyProb
      Probability of forcing selection of ONLY links that are naturally recurrent.
    • dropoffAge

      public int dropoffAge
      Age where Species starts to be penalized.
    • newLinkTries

      public int newLinkTries
      Number of tries mutateAddLink will attempt to find an open link.
    • newNodeTries

      public int newNodeTries
      Number of tries mutateAddNode will attempt to build a new node.
    • babiesStolen

      public int babiesStolen
      The number of babies to siphen off to the champions.
    • maxNetworkDepth

      public int maxNetworkDepth
      how deep a node can be in the network, measured by number of parents
    • addNodeMaxGenomeLength

      public int addNodeMaxGenomeLength
      Beyond this genome length, mutateAddNode does a pure random split rather than a bias.
    • base

      public Parameter base
    • subspecies

      public ArrayList<NEATSubspecies> subspecies
      A list of the all the subspecies.
    • innovations

      public HashMap<NEATInnovation,NEATInnovation> innovations
      A Hashmap for easy tracking the innovation within species.
  • Constructor Details

    • NEATSpecies

      public NEATSpecies()
  • Method Details

    • setup

      public void setup(EvolutionState state, Parameter base)
      Description copied from class: 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 Prototype
      Specified by:
      setup in interface Setup
      Overrides:
      setup in class GeneVectorSpecies
      See Also:
    • defaultBase

      public Parameter defaultBase()
      Description copied from interface: 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 Prototype
      Overrides:
      defaultBase in class VectorSpecies
    • nextInnovationNumber

      public int nextInnovationNumber()
    • setInnovationNumber

      public void setInnovationNumber(int num)
    • speciate

      public void speciate(EvolutionState state, Individual ind)
      Assign the individual into a species, if not found, create a new one
    • spawnWithTemplate

      public NEATIndividual spawnWithTemplate(EvolutionState state, NEATSpecies species, int thread, NEATIndividual ind)
      Spawn a new individual with given individual as template.
    • compatibility

      public double compatibility(NEATIndividual a, NEATIndividual b)
      This function gives a measure of compatibility between two Genomes by computing a linear combination of 3 characterizing variables of their compatibilty. The 3 variables represent PERCENT DISJOINT GENES, PERCENT EXCESS GENES, MUTATIONAL DIFFERENCE WITHIN MATCHING GENES. So the formula for compatibility is: disjointCoeff*numDisjoint+excessCoeff*numExcess+mutdiffCoeff*numMatching.
    • countOffspring

      public void countOffspring(EvolutionState state, int subpop)
      Determine the offsprings for all the subspecies.
    • breedNewPopulation

      public void breedNewPopulation(EvolutionState state, int subpop, int thread)
      Breed a new generation of population, this is done by first figure the expected offsprings for each subspecies, and then calls each subspecies to reproduce.
    • deltaCoding

      public void deltaCoding(EvolutionState state, int subpop, ArrayList<NEATSubspecies> sortedSubspecies)
      Perform a delta coding.
    • populationStagnation

      public void populationStagnation(EvolutionState state, int subpop, ArrayList<NEATSubspecies> sortedSubspecies)
      Determine if the whole subpopulation get into stagnation.
    • stealBabies

      public void stealBabies(EvolutionState state, int thread, int subpop, ArrayList<NEATSubspecies> sortedSubspecies)
      Steal the babies from champion subspecies.
    • newIndividual

      public Individual newIndividual(EvolutionState state, int thread, ArrayList<NEATNode> nodes, ArrayList<Gene> genes)
      Create a new individual with given nodes and genes
    • hasInnovation

      public boolean hasInnovation(NEATInnovation inno)
    • getInnovation

      public NEATInnovation getInnovation(NEATInnovation inno)
    • addInnovation

      public void addInnovation(NEATInnovation inno)
    • clearEvaluationFlag

      public void clearEvaluationFlag(ArrayList<Individual> individuals)
      Clear the evaluation flag in each individual. This is important if a evaluation individual mutated.
base.species species (the subpopulations' species)