Class: Individual

Individual

new Individual(options)

Genetic algorithm individual

Parameters:
Name Type Description
options object

Individual options

Properties
Name Type Description
minLength number

The minimum number of genes

maxLength number

The maximum number of genes

geneFactory function

A function that returns a random gene

Properties:
Name Type Description
body Array.<object>

An array of genes that represent a single chromosome

fitness number

The individuals fitness rating

options object

Individual options

Source:

Methods

copy() → {Individual}

Creates a deep copy of the individual

Source:
Returns:

A copy of the Individual instance

Type
Individual

createNew() → {Individual}

Creates a deep copy of the individual and then re initialises

Source:
Returns:

A new individual based on the current individual

Type
Individual

initialise() → {Individual}

Re creates the individuals body with randomly generated genes

Source:
Returns:

Reference to current object for chaining

Type
Individual

isFixedLength() → {boolean}

Determine whether the individual body length can change (i.e. minLength === maxLength)

Source:
Returns:

A true value if the indiviuals body is of fixed length, otherwise false

Type
boolean

mutate() → {Individual}

Mutates the individual by swapping a single gene with a randomly created gene

Source:
Returns:

Reference to current object for chaining

Type
Individual

validateRequiredOptions() → {Individual}

Validates the individuals current options

Source:
Throws:
An exception will occur if a required option is missing
Returns:

Reference to current object for chaining

Type
Individual