(self, modulo=None)
return self
reset logger, overwrite original files, `modulo`: log only every modulo call
reset logger, overwrite original files, `modulo`: log only every modulo call
reset logger overwrite original files modulo : log only every modulo call
def initialize(self, modulo=None):
        """reset logger, overwrite original files, `modulo`: log only every modulo call"""
        if modulo is not None:
            self.modulo = modulo
        try:
            es = self.es  # must have been registered
        except AttributeError:
            pass  # TODO: revise usage of es... that this can pass
            raise _Error('call register() before initialize()')

        self.counter = 0  # number of calls of add

        # write headers for output
        fn = self.name_prefix + 'fit.dat'
        strseedtime = 'seed=%d, %s' % (es.opts['seed'], time.asctime())

        try:
            with open(fn, 'w') as f:
                f.write('% # columns="iteration, evaluation, sigma, axis ratio, ' +
                        'bestever, best, median, worst objective function value, ' +
                        'further objective values of best", ' +
                        strseedtime +
                        # strftime("%Y/%m/%d %H:%M:%S", localtime()) + # just asctime() would do
                        '\n')
        except (IOError, OSError):
            print('could not open file ' + fn)

        fn = self.name_prefix + 'axlen.dat'
        try:
            f = open(fn, 'w')
            f.write('%  columns="iteration, evaluation, sigma, max axis length, ' +
                    ' min axis length, all principle axes lengths ' +
                    ' (sorted square roots of eigenvalues of C)", ' +
                    strseedtime +
                    '\n')
            f.close()
        except (IOError, OSError):
            print('could not open file ' + fn)
        finally:
            f.close()
        fn = self.name_prefix + 'stddev.dat'
        try:
            f = open(fn, 'w')
            f.write('% # columns=["iteration, evaluation, sigma, void, void, ' +
                    ' stds==sigma*sqrt(diag(C))", ' +
                    strseedtime +
                    '\n')
            f.close()
        except (IOError, OSError):
            print('could not open file ' + fn)
        finally:
            f.close()

        fn = self.name_prefix + 'xmean.dat'
        try:
            with open(fn, 'w') as f:
                f.write('% # columns="iteration, evaluation, void, void, void, xmean", ' +
                        strseedtime)
                f.write(' # scaling_of_variables: ')
                if np.size(es.gp.scales) > 1:
                    f.write(' '.join(map(str, es.gp.scales)))
                else:
                    f.write(str(es.gp.scales))
                f.write(', typical_x: ')
                if np.size(es.gp.typical_x) > 1:
                    f.write(' '.join(map(str, es.gp.typical_x)))
                else:
                    f.write(str(es.gp.typical_x))
                f.write('\n')
                f.close()
        except (IOError, OSError):
            print('could not open/write file ' + fn)

        fn = self.name_prefix + 'xrecentbest.dat'
        try:
            with open(fn, 'w') as f:
                f.write('% # iter+eval+sigma+0+fitness+xbest, ' +
                        strseedtime +
                        '\n')
        except (IOError, OSError):
            print('could not open/write file ' + fn)

        return self
def initialize ( self , modulo = None ) : if modulo is not None : self . modulo = modulo try : es = self . es # must have been registered except AttributeError : pass # TODO: revise usage of es... that this can pass raise _Error ( 'call register() before initialize()' ) self . counter = 0 # number of calls of add # write headers for output fn = self . name_prefix + 'fit.dat' strseedtime = 'seed=%d, %s' % ( es . opts [ 'seed' ] , time . asctime ( ) ) try : with open ( fn , 'w' ) as f : f . write ( '% # columns="iteration, evaluation, sigma, axis ratio, ' + 'bestever, best, median, worst objective function value, ' + 'further objective values of best", ' + strseedtime + # strftime("%Y/%m/%d %H:%M:%S", localtime()) + # just asctime() would do '\n' ) except ( IOError , OSError ) : print ( 'could not open file ' + fn ) fn = self . name_prefix + 'axlen.dat' try : f = open ( fn , 'w' ) f . write ( '%  columns="iteration, evaluation, sigma, max axis length, ' + ' min axis length, all principle axes lengths ' + ' (sorted square roots of eigenvalues of C)", ' + strseedtime + '\n' ) f . close ( ) except ( IOError , OSError ) : print ( 'could not open file ' + fn ) finally : f . close ( ) fn = self . name_prefix + 'stddev.dat' try : f = open ( fn , 'w' ) f . write ( '% # columns=["iteration, evaluation, sigma, void, void, ' + ' stds==sigma*sqrt(diag(C))", ' + strseedtime + '\n' ) f . close ( ) except ( IOError , OSError ) : print ( 'could not open file ' + fn ) finally : f . close ( ) fn = self . name_prefix + 'xmean.dat' try : with open ( fn , 'w' ) as f : f . write ( '% # columns="iteration, evaluation, void, void, void, xmean", ' + strseedtime ) f . write ( ' # scaling_of_variables: ' ) if np . size ( es . gp . scales ) > 1 : f . write ( ' ' . join ( map ( str , es . gp . scales ) ) ) else : f . write ( str ( es . gp . scales ) ) f . write ( ', typical_x: ' ) if np . size ( es . gp . typical_x ) > 1 : f . write ( ' ' . join ( map ( str , es . gp . typical_x ) ) ) else : f . write ( str ( es . gp . typical_x ) ) f . write ( '\n' ) f . close ( ) except ( IOError , OSError ) : print ( 'could not open/write file ' + fn ) fn = self . name_prefix + 'xrecentbest.dat' try : with open ( fn , 'w' ) as f : f . write ( '% # iter+eval+sigma+0+fitness+xbest, ' + strseedtime + '\n' ) except ( IOError , OSError ) : print ( 'could not open/write file ' + fn ) return self