new Population(options)
Genetic algorithm population
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
options |
object | Population options Properties
|
- Source:
Properties:
| Name | Type | Description |
|---|---|---|
options |
object | Population options |
Methods
-
crossover() → {Population}
-
Performs crossover using the crossoverStrategy function defined in the population options
- Source:
Returns:
Reference to current object for chaining
- Type
- Population
-
evaluateFitness() → {Population}
-
Calculates the fitness of each individual where the fitness value is null
- Source:
Returns:
Reference to current object for chaining
- Type
- Population
-
filterNanFitness() → {Population}
-
Subsitutes an individuals fitness to positive or negative infinity if it isNaN
- Source:
Returns:
Reference to current object for chaining
- Type
- Population
-
getAverageFitness() → {number}
-
Calculate the average fitness of all individuals in the population (exluding infinite values)
- Source:
Returns:
Average fitness of the population
- Type
- number
-
getFittestIndividuals(numIndividualsopt) → {Array.<Individual>}
-
Returns a specified number of individuals with the best fitness rating in the population
Parameters:
Name Type Attributes Default Description numIndividualsnumber <optional>
1 The number of individuals to return
- Source:
Returns:
An array of the fittest individuals in the population
- Type
- Array.<Individual>
-
initialise() → {Population}
-
Creates a randomly generated population of individuals
- Source:
Returns:
Reference to current object for chaining
- Type
- Population
-
mutate() → {Population}
-
Mutates the population based on the mutationRate property in each individuals options
- Source:
Returns:
Reference to current object for chaining
- Type
- Population
-
setDefaultOptionsIfNotProvided() → {Population}
-
Sets default values for options that have not been defined
- Source:
Returns:
Reference to current object for chaining
- Type
- Population
-
step() → {Population}
-
Applies a single iteration of crossover and mutation to the population
- Source:
Returns:
Reference to current object for chaining
- Type
- Population
-
train(numGenerations) → {Population}
-
Trains the population over a specified number of generations
Parameters:
Name Type Description numGenerationsnumber The number of generations to train the population over
- Source:
Returns:
Reference to current object for chaining
- Type
- Population
-
validateRequiredOptions() → {Population}
-
Throws an exception if a required option is missing
- Source:
Throws:
An exception is thrown if a required option is missingReturns:
Reference to current object for chaining
- Type
- Population