Skip to content

Commit

Permalink
Use option.populationSize instead of size variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Jan 4, 2011
1 parent e5d99ac commit 712b98b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/drivers/genetic.js
Expand Up @@ -14,7 +14,6 @@ init(function(name, initMsg) {
var bestFitness = undefined
var nextPopulation = []
var processing = false
var size = 0
var generation = 0
var jobs = 0

Expand All @@ -29,12 +28,12 @@ init(function(name, initMsg) {
population = []
if ("undefined" == typeof(options.generator)) {
population = options.population
options.populationSize = population.length
} else {
for (var i = 0; i < options.populationSize; i++) {
population.push([options.generator(i), null])
}
}
size = population.length
}

function processNext(to) {
Expand All @@ -44,7 +43,7 @@ init(function(name, initMsg) {
nextPopulation.sort(function(a, b) {
return options.compare(a[1], b[1])
})
population = nextPopulation.slice(0, size)
population = nextPopulation.slice(0, options.populationSize)
nextPopulation = []
generation++

Expand Down

0 comments on commit 712b98b

Please sign in to comment.