Skip to content

Commit

Permalink
Refacroting release
Browse files Browse the repository at this point in the history
  • Loading branch information
Smoren committed Nov 13, 2024
1 parent ebd2046 commit 3d3d743
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "genetic-search",
"version": "4.2.0",
"version": "4.2.1",
"description": "Multiprocessing genetic algorithm implementation library",
"license": "MIT",
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions src/cache.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GenomeMetricsRow, MetricsCacheInterface } from "./types";

export class DummyMetricsCache implements MetricsCacheInterface {
ready(_: number): GenomeMetricsRow | undefined {
getReady(_: number): GenomeMetricsRow | undefined {
return undefined;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -75,7 +75,7 @@ export class AverageMetricsCache implements MetricsCacheInterface {
return row.map((x) => x / count);
}

ready(): GenomeMetricsRow | undefined {
getReady(): GenomeMetricsRow | undefined {
return undefined;
}

Expand Down
2 changes: 1 addition & 1 deletion src/strategies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export abstract class BaseMetricsStrategy<
}

public async run(population: Population<TGenome>, cache: MetricsCacheInterface): Promise<GenerationMetricsMatrix> {
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)));
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export interface IdGeneratorInterface<TGenome extends BaseGenome> {
}

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;
Expand Down

0 comments on commit 3d3d743

Please sign in to comment.