@zfunction/genetics-js
Version:
Genetic and evolutionary algorithms framework for the web
37 lines (36 loc) • 1.29 kB
TypeScript
import { BaseIndividual } from '../../individual/base/';
import { IndividualReader, IndividualToken } from './IndividualReader';
/**
* ## Basic individual reader
* This class provides the basic implementation
* of the methods of the [[IndividualReader]]
* interface.
* @typeparam I is the type of the generated individual.
* @typeparam T is the value of the genes of the individual.
*/
export declare abstract class BaseIndividualReader<I extends BaseIndividual<T>, T> implements IndividualReader<I, T> {
/**
* Array of tokens of the individuals.
*/
abstract readonly tokenDefinition: Array<IndividualToken<T>>;
/**
* This method converts a token
* into the value of the individual
* genes.
* @param token of the individual.
* @return the value of the individual.
* @throws Error if there is an unexpected token.
*/
convertToken(token: string): T;
/**
* given an array of tokens this
* method converts into an array
* of individual values.
* @param tokens
* @return the genotype or array of
* values
*/
getGenotype(tokens: string[]): T[];
abstract read(definition: string): I;
abstract tokenize(definition: string): string[];
}