Comparing version 0.2.1 to 0.2.2
@@ -8,3 +8,3 @@ import { Generation, GenerationConfig } from '../generation'; | ||
notification?: number; | ||
notifyIndividual?: boolean; | ||
notifyBestOnly?: boolean; | ||
} | ||
@@ -11,0 +11,0 @@ export declare class EvJs { |
@@ -20,3 +20,3 @@ "use strict"; | ||
this.iterations = config.iterations; | ||
const { size, crossover, mutation, keepFittest, select, pair, optimizeKey, fitness, mutate, mate, notification, notifyIndividual } = config; | ||
const { size, crossover, mutation, keepFittest, select, pair, optimizeKey, fitness, mutate, mate, notification, notifyBestOnly: notifyIndividual } = config; | ||
this.config = { | ||
@@ -34,3 +34,3 @@ size, | ||
notification, | ||
notifyIndividual | ||
notifyBestOnly: notifyIndividual | ||
}; | ||
@@ -69,4 +69,13 @@ } | ||
this.log(`Stats: ${statsStr}`); | ||
if (!this.config.notifyIndividual) | ||
if (this.config.notifyBestOnly) { | ||
const individual = this.generation.individuals[0]; | ||
const name = `${individual.name.first} ${individual.name.last}`; | ||
const config = individual.entity; | ||
const deviation = Math.abs(stats.mean - individual.fitness); | ||
const fitness = individual.fitness; | ||
const data = { fitness, deviation, config, name }; | ||
const json = chalk_1.default.green(JSON.stringify(data, null, 1)); | ||
this.log(`Individual: ${json}`); | ||
return this.log(''); | ||
} | ||
this.generation.individuals.forEach(individual => { | ||
@@ -73,0 +82,0 @@ const name = `${individual.name.first} ${individual.name.last}`; |
{ | ||
"name": "evjs", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Generic genetic/evolution algorithm in JS", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35669
489