Ejemplo n.º 1
0
Archivo: pop.py Proyecto: akloumann/Bot
 def InitializeRandomPop(self):
     for i in range(0, self.popSize):
         first = np.random.random_sample((c.numInputs, c.numHidden)) * 2 - 1
         second = np.random.random_sample(
             (c.numHidden, c.numOutputs)) * 2 - 1
         genome = [first, second]
         self.p[i] = INDIVIDUAL(i, genome, 0)  # age=0
Ejemplo n.º 2
0
 def InitializeUniformPop(self, genome):
     for i in range(0, self.popSize):
         self.p[i] = INDIVIDUAL(i, genome, 0)
Ejemplo n.º 3
0
          'begin\n**********************')
    parents = POPULATION(c.popSize)
    if k < num_rand:
        first = np.random.random_sample((c.numInputs, c.numHidden)) * 2 - 1
        second = np.random.random_sample((c.numHidden, c.numOutputs)) * 2 - 1
        genome = [first, second]
    else:
        filename = 'genome' + str(fit_labels[0])
        del fit_labels[0]
        pathLoad = c.pathLoad
        filename = pathLoad + filename
        g = open(filename, 'r')
        genome = pickle.load(g)
        g.close()
    # parents.InitializeUniformPop(genome)
    parents.p[k] = INDIVIDUAL(k, genome, 0)
    parents.Evaluate(envs, pp=False, pb=True)
    parents.Print()
    for i in range(0, c.numGensDivPop):
        # the POPULATION constructor creates an empty dictionary and stores the variable popSize
        children = POPULATION(c.popSize)
        # children.Print('bm')
        print()
        children.FillFrom(parents)

        print('seconds remaining', t_end - time.time())

        # print('\n0', end=' ')
        parents.Print()
        children.Evaluate(envs, pp=False, pb=True)
        # print(i, end=' ')
Ejemplo n.º 4
0
Archivo: pop.py Proyecto: akloumann/Bot
    def FillWithRandIndv(self, index):
        first = np.random.random_sample((c.numInputs, c.numHidden)) * 2 - 1
        second = np.random.random_sample((c.numHidden, c.numOutputs)) * 2 - 1

        genome = [first, second]
        self.p[index] = INDIVIDUAL(index, genome, 0)  # age=0
Ejemplo n.º 5
0
Archivo: phc.py Proyecto: akloumann/Bot
    print('**********************\nindividual num', k,
          'begin\n**********************')
    if k < num_rand:
        first = np.random.random_sample((c.numInputs, c.numHidden)) * 2 - 1
        second = np.random.random_sample((c.numHidden, c.numOutputs)) * 2 - 1
        genome = [first, second]
    else:

        filename = 'genome' + str(fit_labels[0])
        del fit_labels[0]
        pathLoad = c.pathLoad
        filename = pathLoad + filename
        g = open(filename, 'r')
        genome = pickle.load(g)
        g.close()
    parentsF.p[k] = INDIVIDUAL(k, genome)
    for e in envs.envs:
        parentsF.p[k].Start_Evaluation(envs.envs[e],
                                       pp=False,
                                       pb=True,
                                       send=True)

parentsF.Evaluate(envs, pp=False, pb=True)
parentsF.Print('population size', k)

print('################ Begin parallel hill climber ######################')

while time.time() < t_end:
    # print('############# i', i)
    print('seconds remaining', t_end - time.time())
    print('\nF', end='')