(self, ga_engine)
Inserts the statistics data to database

      :param ga_engine: the GA Engine

      .. versionchanged:: 0.6
         The method now receives the *ga_engine* parameter.
Inserts the statistics data to database
Inserts the statistics data to database
def insert(self, ga_engine):
      """ Inserts the statistics data to database

      :param ga_engine: the GA Engine

      .. versionchanged:: 0.6
         The method now receives the *ga_engine* parameter.
      """
      stats = ga_engine.getStatistics()
      population = ga_engine.getPopulation()
      generation = ga_engine.getCurrentGeneration()

      c = self.getCursor()
      pstmt = "insert into " + Consts.CDefMySQLDBTable + " values (%s, %s, "
      for i in xrange(len(stats)):
         pstmt += "%s, "
      pstmt = pstmt[:-2] + ")"
      c.execute(pstmt, (self.getIdentify(), generation) + stats.asTuple())

      pstmt = "insert into " + Consts.CDefMySQLDBTablePop + " values(%s, %s, %s, %s, %s)"

      tups = []
      for i in xrange(len(population)):
         ind = population[i]
         tups.append((self.getIdentify(), generation, i, ind.fitness, ind.score))

      c.executemany(pstmt, tups)
      if (generation % self.commitFreq == 0):
         self.commit()
def insert ( self , ga_engine ) : stats = ga_engine . getStatistics ( ) population = ga_engine . getPopulation ( ) generation = ga_engine . getCurrentGeneration ( ) c = self . getCursor ( ) pstmt = "insert into " + Consts . CDefMySQLDBTable + " values (%s, %s, " for i in xrange ( len ( stats ) ) : pstmt += "%s, " pstmt = pstmt [ : - 2 ] + ")" c . execute ( pstmt , ( self . getIdentify ( ) , generation ) + stats . asTuple ( ) ) pstmt = "insert into " + Consts . CDefMySQLDBTablePop + " values(%s, %s, %s, %s, %s)" tups = [ ] for i in xrange ( len ( population ) ) : ind = population [ i ] tups . append ( ( self . getIdentify ( ) , generation , i , ind . fitness , ind . score ) ) c . executemany ( pstmt , tups ) if ( generation % self . commitFreq == 0 ) : self . commit ( )