@zfunction/genetics-js
Version:
Genetic and evolutionary algorithms framework for the web
46 lines (45 loc) • 1.41 kB
TypeScript
import { MutableIndividual } from '../base/';
/**
* ## Binary individual
* A binary individual has only boolean values
* in its genotype. It could be represented by
* a string of `0` and `1` or `t` and `f`.
* ```
* let ind = new BinaryIndividual('0010100');
* console.log(ind.genotype) // [false, false, true, false, true, false, false]
* console.log(ind) // 0 0 1 0 1 0 0
* ```
*/
export declare class BinaryIndividual extends MutableIndividual<boolean> {
/**
* Constructor of the class, expects an array
* of boolean values or an string separated by
* any number of spaces, with the following tokens:
*
* * (`0` | `f` | `F`) -> `false`
* * (`1` | `t` | `T`) -> `true`
*
* Example:
* ```
* 01 0 10 01 // OK
* tf ff tf // OK
* T FTFFTF // OK
* 0 1Ff tT // OK
* ```
* @param representation of the individual.
*/
constructor(representation: string | boolean[]);
/**
* Creates a deep copy of the
* other individual in the current.
* @param other individual to copy.
*/
deepCopy(other: MutableIndividual<boolean>): void;
flip(index: number): void;
/**
* Converts a gene to string, useful for method
* `toString`.
* @param gene that we are converting.
*/
protected geneToString(gene: boolean): string;
}