UNPKG

genetic-search

Version:

Multiprocessing genetic algorithm implementation library

80 lines (79 loc) 3.12 kB
import type { BaseGenome, GenomeStats, GenomeStatsManagerInterface, PhenomeRow, Population, GenerationPhenomeMatrix, GenerationFitnessColumn, GenomeOrigin, StatSummary, GroupedStatSummary, PopulationSummaryManagerInterface, PopulationSummary, RangeStatSummary } from "./types"; /** * A manager for the statistics of a population of genomes. * * This class implements the [[GenomeStatsManagerInterface]] interface. * * @category Statistics */ export declare class GenomeStatsManager implements GenomeStatsManagerInterface<BaseGenome> { init(population: Population<BaseGenome>, origin: GenomeOrigin): void; update(population: Population<BaseGenome>, phenomeMatrix: GenerationPhenomeMatrix, fitnessColumn: GenerationFitnessColumn): void; initItem(genome: BaseGenome, origin: GenomeOrigin, parents?: BaseGenome[]): GenomeStats; /** * Updates the statistics of a genome. * * @param genome The genome to update. * @param phenome The phenome of the genome. * @param fitness The fitness of the genome. * * @returns The updated genome statistics. */ protected updateItem(genome: BaseGenome, phenome: PhenomeRow, fitness: number): GenomeStats; } /** * A manager for the population summary. * * This class implements the [[PopulationSummaryManagerInterface]] interface. * It is used to manage the population summary, which is a summary of the * statistics of a population of genomes. * * @category Statistics */ export declare class PopulationSummaryManager implements PopulationSummaryManagerInterface<BaseGenome> { /** * The summary of the fitness of the population. */ protected fitnessSummary: StatSummary; /** * The summary of the fitness of the population, grouped by origin. */ protected groupedFitnessSummary: GroupedStatSummary; /** * The summary of the age of the population. */ protected ageSummary: RangeStatSummary; /** * The ID of the best genome in the population. */ protected bestGenomeId: number | undefined; /** * The number of generations since the best genome has changed. */ protected stagnationCounter: number; /** * Constructs a new population summary manager. */ constructor(); get(): PopulationSummary; getRounded(precision: number): PopulationSummary; update(sortedPopulation: Population<BaseGenome>): void; /** * Updates the summary of the population. * * @param sortedStatsCollection The sorted collection of genome statistics. */ protected updateSummary(sortedStatsCollection: GenomeStats[]): void; /** * Updates the grouped summary of the population. * * @param sortedStatsCollection The sorted collection of genome statistics. */ protected updateGroupedSummary(sortedStatsCollection: GenomeStats[]): void; /** * Updates the summary of the age of the population. * * @param sortedStatsCollection The sorted collection of genome statistics. */ protected updateAgeSummary(sortedStatsCollection: GenomeStats[]): void; }