Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Population

Hierarchy

Index

Constructors

Protected constructor

  • new Population(populationSize: number, options: { inputSize?: undefined | number; outputSize?: undefined | number; template?: Network | undefined }): Population
  • Parameters

    • populationSize: number
    • options: { inputSize?: undefined | number; outputSize?: undefined | number; template?: Network | undefined }
      • Optional inputSize?: undefined | number
      • Optional outputSize?: undefined | number
      • Optional template?: Network | undefined

    Returns Population

Properties

Protected generation

generation: number

Protected networks

networks: Network[]

Protected Readonly populationSize

populationSize: number

Methods

Protected Abstract 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

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[]

evolve

getBest

getRandom

Protected log

  • log(): void

Protected Abstract 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

Protected sortNetworks

  • sortNetworks(): void

Generated using TypeDoc