Ejemplo n.º 1
0
    def _getRequiredAttributes(self,
                               paramsDict,
                               threadNumber="0",
                               runDict={},
                               pointKey=''):
        '''
        '''
        phaseSpaceDict = {}
        # pointKey = 'Point T' + threadNumber + "-" + str(int(random.uniform(1, 1000)))
        # + strftime("-%d%m%Y%H%M%S", gmtime())
        phaseSpaceDict[pointKey] = paramsDict

        a_ct = 20
        b_ct = 0.2
        c_ct = 2 * math.pi

        auxSum1 = 0
        auxSum2 = 0
        d_ct = len(list(paramsDict.keys()))
        for modelParam in paramsDict.keys():
            auxSum1 += (paramsDict[modelParam])**2
            auxSum2 += math.cos(c_ct * paramsDict[modelParam])

        ackleyVal = -a_ct * math.exp(
            -b_ct * math.sqrt(auxSum1 / d_ct)) - math.exp(
                auxSum2 / d_ct) + a_ct + math.exp(1)
        phaseSpaceDict[pointKey]['fAckley'] = ackleyVal

        # Put in a pause to simulate computational complexity
        time.sleep(0.25 * randU(0, 1))
        return phaseSpaceDict
Ejemplo n.º 2
0
 def selection_one(self, population, population_fitnesses):
     spot = 0
     select_index = randU()
     for i in range(0, len(population_fitnesses)):
         if select_index > spot:
             spot += population_fitnesses[i]
         else:
             select_index = i - 1
             return population[select_index]
     return population[-1]
Ejemplo n.º 3
0
 def get_random_weight(self):
     return randU() * 10
Ejemplo n.º 4
0
 def prob_crossover(self):
     return crossover_prob > randU()
Ejemplo n.º 5
0
 def prob_mutation(self):
     return mutation_prob > randU()