Methods
-
alphabet() → {string}
-
Returns a random letter in the alphabet, including uppercase characters and whitespace
- Source:
Returns:
A random letter in the alphabet
- Type
- string
-
arrayEqual(a, b) → {boolean}
-
Compares two arrays by each element
Parameters:
Name Type Description aarray The first array to compare
barray The second array to compare
- Source:
Returns:
True if the provided arrays are equal, otherwise false
- Type
- boolean
-
binaryNumber() → {number}
-
Returns a random binary number
- Source:
Returns:
A random binary number
- Type
- number
-
binaryString() → {number}
-
Returns a random binary string
- Source:
Returns:
A random binary string
- Type
- number
-
createCalculation(registerSet, index) → {RegisterReference}
-
Returns a new calculation register reference
Parameters:
Name Type Description registerSetRegisterSet A register set instance
indexnumber Optional user specified index
Returns:
A new calculation register reference
- Type
- RegisterReference
-
createConstant(registerSet, index) → {RegisterReference}
-
Returns a new constant register reference
Parameters:
Name Type Description registerSetRegisterSet A register set instance
indexnumber Optional user specified index
Returns:
A new constant register reference
- Type
- RegisterReference
-
createInput(registerSet, index) → {RegisterReference}
-
Returns a new input register reference
Parameters:
Name Type Description registerSetRegisterSet A register set instance
indexnumber Optional user specified index
Returns:
A new input register reference
- Type
- RegisterReference
-
createOutput(registerSet, index) → {RegisterReference}
-
Returns a new output register reference
Parameters:
Name Type Description registerSetRegisterSet A register set instance
indexnumber Optional user specified index
Returns:
A new output register reference
- Type
- RegisterReference
-
formatString(stringVar, argsArray) → {string}
-
Replaces each tag in the provided string with its corresponding parameter element
Parameters:
Name Type Description stringVarstring String to convert
argsArrayarray An array of arguments
- Source:
Returns:
Converted string
- Type
- string
-
fpEqual(a, b) → {boolean}
-
Performs floating point comparison between two numbers with an epsilon of 0.00001
Parameters:
Name Type Description anumber The first number to compare
bnumber The second number to compare
- Source:
Returns:
True if the provided numbers are equal, otherwise false
- Type
- boolean
-
inherits()
-
Calls nodes util.inherits function
- Source:
-
linearNode(A) → {LinearGPNode}
-
Returns a random linear node for linear genetic programming
Parameters:
Name Type Description ALinearIndividual linear individual to create a node for
- Source:
Returns:
A random linear node
- Type
- LinearGPNode
-
onePointFixed(individuals) → {Array.<Individual>}
-
Performs one point fixed crossover
Parameters:
Name Type Description individualsArray.<Individual> An array containing two individuals
- Source:
Returns:
An array containing two offspring
- Type
- Array.<Individual>
-
onePointVariable(individuals) → {Array.<Individual>}
-
Performs one point variable crossover
Parameters:
Name Type Description individualsArray.<Individual> An array containing two individuals
- Source:
Returns:
An array containing two offspring
- Type
- Array.<Individual>
-
randBetween(min, max)
-
Returns a random whole number between a specified range
Parameters:
Name Type Description minnumber Minimum value (inclusive)
maxnumber Maximum value (exclusive)
- Source:
Returns:
A random whole number between a specified range
-
random()
-
Returns a random number between 0 and 1
- Source:
Returns:
A random number between 0 and 1
-
random(individuals, options)
-
Returns two randomly selected individuals
Parameters:
Name Type Description individualsArray.<Individual> An array of individuals
optionsobject Population options
- Source:
-
randomNumber() → {number}
-
Returns a random number between 0 and 1
- Source:
Returns:
A random number between 0 and 1
- Type
- number
-
rank(individuals, options)
-
Returns two individuals using the rank selection algorithm
Parameters:
Name Type Description individualsArray.<Individual> An array of individuals
optionsobject Population options
- Source:
-
rouletteWheel(individuals, options)
-
Returns two individuals using the roulette wheel selection algorithm
Parameters:
Name Type Description individualsArray.<Individual> An array of individuals
optionsobject Population options
- Source:
-
selectRandom(from)
-
Returns a randomly selected element from an array
Parameters:
Name Type Description fromarray An array to select an element from
- Source:
Returns:
A randomly selected element from the provided array
-
swapGenes(indvidualA, indvidualB, index)
-
Swaps genes between two individuals at the specified index
Parameters:
Name Type Description indvidualAIndividual The first individual
indvidualBIndividual The second individual
indexnumber Body array index to swap genes at
- Source:
-
tournament(individuals, options)
-
Returns two individuals using the tournament selection algorithm
Parameters:
Name Type Description individualsArray.<Individual> An array of individuals
optionsobject Population options
- Source:
-
twoPointFixed(individuals) → {Array.<Individual>}
-
Performs two point fixed crossover
Parameters:
Name Type Description individualsArray.<Individual> An array containing two individuals
- Source:
Returns:
An array containing two offspring
- Type
- Array.<Individual>
-
twoPointVariable(individuals) → {Array.<Individual>}
-
Performs two point variable crossover
Parameters:
Name Type Description individualsArray.<Individual> An array containing two individuals
- Source:
Returns:
An array containing two offspring
- Type
- Array.<Individual>
-
uniform(individuals) → {Array.<Individual>}
-
Performs uniform crossover
Parameters:
Name Type Description individualsArray.<Individual> An array containing two individuals
- Source:
Returns:
An array containing two offspring
- Type
- Array.<Individual>
-
validateFixedLength(individuals)
-
Throws an exception if any individuals are not fixed length
Parameters:
Name Type Description individualsArray.<Individual> An array of individuals to validate
- Source:
Throws:
An exception is thrown if any individuals are not fixed length -
validateMinimumLength(individuals)
-
Throws an exception if any individuals have less than two genes
Parameters:
Name Type Description individualsArray.<Individual> An array of individuals to validate
- Source:
Throws:
An exception is thrown if any individuals have less than two genes -
validateVariableLength(individuals)
-
Throws an exception if any individuals are fixed length
Parameters:
Name Type Description individualsArray.<Individual> An array of individuals to validate
- Source:
Throws:
An exception is thrown if any individuals are fixed length