Permalink
Browse files

preserve sum when inverting scores

  • Loading branch information...
1 parent c208ec1 commit 8bd290c07beff27fc1149c252b96a596d1096106 @scottcheng committed Feb 13, 2013
Showing with 2 additions and 3 deletions.
  1. +2 −3 lib/genetic/Task.js
View
@@ -173,12 +173,11 @@ Task.prototype.reproduction = function (callback) {
}
, function (callback) {
// invert scores, if we minimize fitness
- var maxScore = Math.abs(self.statistics.maxScore)
+ var avg = self.statistics.avg
if (self.minimize) {
async.forEach(self.parents
, function (item, cb) {
- item.score*=-1
- item.score+=maxScore
+ item.score = avg * 2 - item.score
process.nextTick(function () {cb()})
}
, function (err) {

0 comments on commit 8bd290c

Please sign in to comment.