diff --git a/package.json b/package.json index dea38df..d5cf34a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "genetic-search", - "version": "4.2.0", + "version": "4.2.1", "description": "Multiprocessing genetic algorithm implementation library", "license": "MIT", "repository": { diff --git a/src/cache.ts b/src/cache.ts index 63202fd..8c16ff8 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -1,7 +1,7 @@ import { GenomeMetricsRow, MetricsCacheInterface } from "./types"; export class DummyMetricsCache implements MetricsCacheInterface { - ready(_: number): GenomeMetricsRow | undefined { + getReady(_: number): GenomeMetricsRow | undefined { return undefined; } @@ -35,7 +35,7 @@ export class SimpleMetricsCache implements MetricsCacheInterface { : defaultValue; } - ready(genomeId: number): GenomeMetricsRow | undefined { + getReady(genomeId: number): GenomeMetricsRow | undefined { return this.cache.has(genomeId) ? this.get(genomeId) : undefined; } @@ -75,7 +75,7 @@ export class AverageMetricsCache implements MetricsCacheInterface { return row.map((x) => x / count); } - ready(): GenomeMetricsRow | undefined { + getReady(): GenomeMetricsRow | undefined { return undefined; } diff --git a/src/strategies.ts b/src/strategies.ts index 055cc14..26ebc63 100644 --- a/src/strategies.ts +++ b/src/strategies.ts @@ -42,7 +42,7 @@ export abstract class BaseMetricsStrategy< } public async run(population: Population, cache: MetricsCacheInterface): Promise { - const resultsMap = new Map(population.map((genome) => [genome.id, cache.ready(genome.id)])); + const resultsMap = new Map(population.map((genome) => [genome.id, cache.getReady(genome.id)])); const genomesToRun = population.filter((genome) => resultsMap.get(genome.id) === undefined); const newResults = await this.execTasks(genomesToRun.map((genome) => this.createTaskInput(genome))); diff --git a/src/types.ts b/src/types.ts index 5785531..2cb87ee 100644 --- a/src/types.ts +++ b/src/types.ts @@ -94,7 +94,7 @@ export interface IdGeneratorInterface { } export interface MetricsCacheInterface { - ready(genomeId: number): GenomeMetricsRow | undefined; + getReady(genomeId: number): GenomeMetricsRow | undefined; get(genomeId: number, defaultValue?: GenomeMetricsRow): GenomeMetricsRow | undefined; set(genomeId: number, metrics: GenomeMetricsRow): void; clear(excludeGenomeIds: number[]): void;