@zfunction/genetics-js
Version:
Genetic and evolutionary algorithms framework for the web
60 lines (59 loc) • 2.18 kB
TypeScript
import { NumericIndividual, NumericRange } from '../base';
/**
* ## Integer individual
* Integer individual is a numeric individual
* where all the genes in the genotype are integers.
*/
export declare class IntegerIndividual extends NumericIndividual {
/**
* Constructor of the class.
* Takes the representation as
* an array of numbers or a string
* and an optional range.
* @param representation of the individual.
* @param range of the individual, if not provided
* is the default range.
*/
constructor(representation: number[] | string, range?: NumericRange);
/**
* Copy other individual into the current.
* Creates a shallow copy, with the references
* only.
* @param other individual to copy
*/
copy(other: IntegerIndividual): void;
/**
* Creates a deep copy of the other individual
* in the current.
* @param other individual to copy.
*/
deepCopy(other: IntegerIndividual): void;
/**
* Fill the genotype with the specified gene.
* @param gene we want to fill the genotype with.
* if it is not an integer it will be normalized.
* @param start position.
* @param end position.
* @throws RangeError if gene is not in range.
*/
fill(gene: number, start?: number, end?: number): void;
/**
* Creates a new genotype with the result of
* the execution of the specified callback for each
* element.
* Result of the callback will be normalized to
* an integer if it is not.
* @param callback called for each gene.
* @throws RangeError if callback result is not in range.
*/
map(callback: (gene: number, geneIndex?: number, genotype?: number[]) => number): void;
/**
* Sets the gene at specified index to
* the specified value.
* @param geneIndex index of the gene to be set.
* if it is not an integer it will be normalized.
* @param gene new value of the gene.
* @throws RangeError if gene is not in range.
*/
set(geneIndex: number, gene: number): void;
}