Options
All
  • Public
  • Public/Protected
  • All
Menu

Class NEATPopulation

Hierarchy

Index

Constructors

constructor

  • new NEATPopulation(populationSize: number, options: { c1?: undefined | number; c2?: undefined | number; c3?: undefined | number; inputSize?: undefined | number; outputSize?: undefined | number; populationStagnationLimit?: undefined | number; speciesDistanceThreshold?: undefined | number; speciesStagnationLimit?: undefined | number; survivorRate?: undefined | number; template?: Network | undefined }): NEATPopulation
  • Parameters

    • populationSize: number
    • options: { c1?: undefined | number; c2?: undefined | number; c3?: undefined | number; inputSize?: undefined | number; outputSize?: undefined | number; populationStagnationLimit?: undefined | number; speciesDistanceThreshold?: undefined | number; speciesStagnationLimit?: undefined | number; survivorRate?: undefined | number; template?: Network | undefined }
      • Optional c1?: undefined | number
      • Optional c2?: undefined | number
      • Optional c3?: undefined | number
      • Optional inputSize?: undefined | number
      • Optional outputSize?: undefined | number
      • Optional populationStagnationLimit?: undefined | number
      • Optional speciesDistanceThreshold?: undefined | number
      • Optional speciesStagnationLimit?: undefined | number
      • Optional survivorRate?: undefined | number
      • Optional template?: Network | undefined

    Returns NEATPopulation

Properties

Protected generation

generation: number

Private highScore

highScore: number

Protected networks

networks: Network[]

Protected Readonly populationSize

populationSize: number

Private species

species: Species[]

Private stagnation

stagnation: number

Static c1

c1: number

Static c2

c2: number

Static c3

c3: number

Static connCounter

connCounter: number

Static connIDs

connIDs: Map<number, number>

Static distanceThreshold

distanceThreshold: number

Static nodeCounter

nodeCounter: number

Static nodeIDs

nodeIDs: Map<number, number>

Static Private populationStagnationLimit

populationStagnationLimit: number

Static Private speciesStagnationLimit

speciesStagnationLimit: number

Static Private survivorRate

survivorRate: number

Methods

Protected breed

Protected calculateScores

  • Calculate scores of every network in population.

    There are 3 ways here:

    1. User provides his own fitness function which accepts a network array and dataset (if defined)
    2. User provides a dataset
    3. User sets the scores of all networks on it's own

    Parameters

    • Optional fitnessFunction: fitnessFunction

      the fitness function provided by the user

    • Optional dataset: datasetType

      the dataset provided by the user

    • Optional loss: lossType

      the loss function

    Returns void

Private createConnIDsFromTemplate

  • createConnIDsFromTemplate(template: Network): Map<number, number>

Protected createNetworks

  • createNetworks(template?: Network, inputSize?: undefined | number, outputSize?: undefined | number): Network[]
  • Create networks to initialize this population

    Parameters

    • Optional template: Network

      the template which gets copied for the whole population if provided

    • Optional inputSize: undefined | number

      if no template is given creating new networks with this input size

    • Optional outputSize: undefined | number

      if no template is given creating new networks with this output size

    Returns Network[]

Private createNodeIDsFromTemplate

  • createNodeIDsFromTemplate(template: Network): Map<number, number>

Private cullSpecies

  • cullSpecies(killRate: number): void
  • Removing a percentage of bad networks from each species

    Parameters

    • killRate: number

      the percentage of kills in each species

    Returns void

evolve

getBest

getRandom

Private killBadSpecies

  • killBadSpecies(): void

Private killStalePopulation

  • killStalePopulation(): void

Private killStaleSpecies

  • killStaleSpecies(): void

Protected log

  • log(): void

Protected mutate

  • mutate(mutations: Mutation[], mutationRate: number, mutationAmount: number, options: { activations: ActivationType[]; elitists: number; maxConnections: number; maxGates: number; maxNodes: number }): void
  • Mutate the population.

    Parameters

    • mutations: Mutation[]

      Sets allowed mutation methods for evolution, a random mutation method will be chosen from the array when mutation occurs. Optional, but default methods are non-recurrent.

    • mutationRate: number

      Sets the mutation rate. If set to 0.3, 30% of the new population will be mutated.

    • mutationAmount: number

      If mutation occurs (randomNumber < mutationRate), sets amount of times a mutation method will be applied to the network.

    • options: { activations: ActivationType[]; elitists: number; maxConnections: number; maxGates: number; maxNodes: number }

      more options relevant for the mutation functions

      • activations: ActivationType[]
      • elitists: number
      • maxConnections: number
      • maxGates: number
      • maxNodes: number

    Returns void

Private reproduce

  • Reproduce the population

    1. Add the champion to the new population if species size is greater than or equal 5
    2. Calculate number of children breed by each species
    3. Breed children
    4. Fill up the population
    5. Overwrite old population

    Parameters

    Returns Network[]

Protected sortNetworks

  • sortNetworks(): void

Private sortSpecies

  • sortSpecies(): void

Private speciate

  • speciate(): void

Private sumOfAvgAdjustedFitnessScores

  • sumOfAvgAdjustedFitnessScores(): number

Generated using TypeDoc