new Individual(options)
Genetic algorithm individual
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | Individual options Properties
|
- Source:
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 |
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 missingReturns:
Reference to current object for chaining
- Type
- Individual