UNPKG

@zfunction/genetics-js

Version:

Genetic and evolutionary algorithms framework for the web

42 lines (41 loc) 1.61 kB
import { BaseIndividual } from './../../individual/base'; import { GeneratorParams } from './GeneratorParams'; import { IndividualGenerator } from './IndividualGenerator'; /** * ## BaseIndividualGenerator * This class provides with the basic features of a * individual generator. */ declare abstract class BaseIndividualGenerator<I extends BaseIndividual<T>, Params extends GeneratorParams, T> implements IndividualGenerator<I, Params, T> { /** * Checks if a given individual length is in range. * @param length that is going to be evaluated. * @return `true` is length is greater than zero and `false` * otherwise. */ protected static lengthIsInRange(length: number): boolean; /** * Throws an exception if length is not in range. * @param length that is going to be checked. * @throws RangeError if length is not in range. */ protected static checkLength(length: number): void; /** * Generates the genotype given the params * of the generator. * @param params of the generator. */ generateGenotype(params: Params): T[]; /** * Generates an individual given some * params. * @param params for the generator. * @throws RangeError if length of the params * is not in range. */ generateWith(params: Params): I; abstract construct(genotype: T[], params: Params): I; abstract generate(...args: any[]): I; abstract generateGene(params: Params, index: number): T; } export { BaseIndividualGenerator as BaseGenerator };