@zfunction/genetics-js
Version:
Genetic and evolutionary algorithms framework for the web
60 lines (59 loc) • 2.18 kB
TypeScript
import { BaseGenerator, GeneratorParams } from '../base';
import { BinaryIndividual } from './../../individual/binary';
/**
* ## BinaryGeneratorParams
* Params of the BinaryGenerator.
*/
export interface BinaryGeneratorParams extends GeneratorParams {
/**
* Chance or probability of generating a gene
* with the value `true`.
*/
chance: number;
}
/**
* ## BinaryGenerator
* Generator of binary individuals.
*/
export declare class BinaryGenerator extends BaseGenerator<BinaryIndividual, BinaryGeneratorParams, boolean> {
/**
* Throws an exception if chance is not in
* range [0.0 - 1.0].
* @param chance that is going to be tested.
* @throws RangeError if chance is not in range.
*/
protected static checkChance(chance: number): void;
/**
* Generates an individual with the specified
* params.
* @param length of the individual.
* @param chance of a generated gene to be `true`.
* By default is `0.5`.
* @param engine (of `random-js`) that is going to be used.
* @return The [[BinaryIndividual]] with the generated genotype.
* @throws RangeError if `length` is not greater than `0`.
* @throws RangeError if `chance` is not in range [0.0 - 1.0].
*/
generate(length: number, chance?: number, engine?: import("random-js").Engine): BinaryIndividual;
/**
* Generates a gene with the specified params.
* @param params of the generator.
* @return the generated gene.
*/
generateGene(params: BinaryGeneratorParams): boolean;
/**
* Generates an individual with the specified
* params.
* @param params of the generator.
* @return The [[BinaryIndividual]] with the generated genotype.
* @throws RangeError if `chance` is not in range [0.0 - 1.0].
* @throws RangeError if `length` is not greater than `0`.
*/
generateWith(params: BinaryGeneratorParams): BinaryIndividual;
/**
* Construct a [[BinaryIndividual]] given
* a genotype.
* @param genotype
*/
construct(genotype: boolean[]): BinaryIndividual;
}