@zfunction/genetics-js
Version:
Genetic and evolutionary algorithms framework for the web
36 lines (35 loc) • 1.19 kB
TypeScript
import { BinaryIndividual } from '../../individual/binary/';
import { BaseIndividualReader, IndividualToken } from '../base/';
/**
* ## Binary reader
* This class provides an implementation
* of a reader which is able to read [[BinaryIndividual]]
* the format of this individuals is the following:
* ```
* 001001001 // OK
* tfftttfft // OK
* TFTFTTFFT // OK
* tfTTF0101 // OK (Mixed case)
* 0 0 f 1T // OK (mixed case with spaces)
* ```
*/
export declare class BinaryReader extends BaseIndividualReader<BinaryIndividual, boolean> {
readonly tokenDefinition: Array<IndividualToken<boolean>>;
/**
* Reads a definition and converts
* into an individual.
* @param definition of the individual.
* @return the read individual.
* @throws Error if there is an unexpected token.
*/
read(definition: string): BinaryIndividual;
/**
* Tokenize a string into several
* tokens. It separates the tokens
* by whitespaces, tabulars and return
* carriage.
* @param definition of the individual.
* @return the tokenized string.
*/
tokenize(definition: string): string[];
}