Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add more debug messages

  • Loading branch information...
commit f2b253ab48696285f61d0e2347d39e6659474fa2 1 parent 7f11e2d
@Eyjafjallajokull authored
Showing with 7 additions and 2 deletions.
  1. +4 −0 genetics/genome.py
  2. +3 −2 genetics/population.py
View
4 genetics/genome.py
@@ -5,6 +5,7 @@
import random
import copy
import lib.config as config
+import lib.log as log
class Genome(object):
fitnessMachine = BaseFitnessMachine
@@ -45,6 +46,7 @@ def _createWithCrossover(self, genomeA, genomeB):
self.data = copy.deepcopy(genomeA.data)
genomeSize = len(genomeA.data) if len(genomeA.data) < len(genomeB.data) else len(genomeB.data)
crossoverObjectCount = int(math.ceil(genomeSize * config.config['ga']['crossoverObjectCountMultiplier']))
+ log.debug('%s crossover objects=%d' % (self.serial, crossoverObjectCount))
if crossoverObjectCount < genomeSize:
for i in random.sample(xrange(0, genomeSize), crossoverObjectCount):
self.data[i] = copy.deepcopy(genomeB.data[i])
@@ -102,6 +104,8 @@ def _mutate(self):
pointCount = config.config['ga']['mutationPointCount']
coordinateCount = config.config['ga']['mutationCoordinateCount']
randomizeMultiplier = config.config['ga']['mutationRandomizeMultiplier']
+ log.debug('%s mutation: objects=%d points=%d coords=%d rand=%d' %
+ (self.serial, objectCount, pointCount, coordinateCount, randomizeMultiplier))
for object in random.sample(xrange(0,len(self.data)), objectCount):
pointsToMutate = random.sample([0,1,2], pointCount)
for point in pointsToMutate:
View
5 genetics/population.py
@@ -35,6 +35,7 @@ def load(self):
for file in genomeFiles:
genome = pickle.load(open(file))
self.genomes.append(genome)
+ log.info('loaded %d genomes' % len(self.genomes))
def initialize(self):
do('rm -f %s* tmp* cache*' % config.config['main']['populationRamPath'])
@@ -43,7 +44,7 @@ def initialize(self):
genome = self.genomeType()
genome.create()
self.genomes.append(genome)
- log.info('created population of %d genomes' % config.config['ga']['populationSize'])
+ log.info('initialized population of %d genomes' % config.config['ga']['populationSize'])
def step(self):
log.info('SUNRISE %d generation' % self.generation)
@@ -61,7 +62,7 @@ def step(self):
log.info('best genome %s-%d; average fitness %d'
% (bestGenome.serial, bestGenome.fitness,
reduce(lambda avg, g: avg + g.fitness, self.genomes, 0) / len(self.genomes)))
-
+ log.debug('genomeSize=%d' % config.config['ga']['genomeSize'])
parents = self.selection()
self.crossover(parents)
log.info('%d s' % int(time() - start))
Please sign in to comment.
Something went wrong with that request. Please try again.