Пример #1
0
    def generateIndividual(self):
        individual = Individual()
        individual.features = []

        # HERE WE HANDLE THE SEARCH SPACE
        # for i in range(self.n):
        #     individual.features.append(random.random())

        react_temp = random.uniform(pbr_props.temperature_lower_bound,
                                    pbr_props.temperature_upper_bound)
        react_pres = random.uniform(pbr_props.pressure_lower_bound,
                                    pbr_props.pressure_upper_bound)
        react_buoh = random.uniform(pbr_props.mole_flows_lower_bound,
                                    pbr_props.mole_flows_upper_bound)
        react_acac = random.uniform(pbr_props.mole_flows_lower_bound,
                                    pbr_props.mole_flows_upper_bound)

        individual.features.append(react_temp)
        individual.features.append(react_pres)
        individual.features.append(react_buoh)
        individual.features.append(react_acac)

        individual.dominates = functools.partial(self.__dominates,
                                                 individual1=individual)
        # self.calculate_objectives(individual)
        return individual
Пример #2
0
 def generateIndividual(self):
     individual = Individual()
     individual.features = []
     for i in range(self.n):
         individual.features.append(random.uniform(self.bounds[i][0], self.bounds[i][1]))
     self.calculate_objectives(individual)
     individual.dominates = functools.partial(self.__dominates, individual1=individual)
     return individual
Пример #3
0
 def generateIndividual(self):
     
     individual = Individual()
     individual.features = []
     for i in range(30):
         individual.features.append(random.random())
     individual.dominates = functools.partial(self.__dominates, individual1=individual)
     self.calculate_objectives(individual)
     return individual
Пример #4
0
 def generate_individual(self):
     xy = CLUSTERING(self.all_data_matrix, self.individual_no)
     centroids, label, no_of_cluster = xy.kmeans(
     )  #Generate each individual using k-means clustering
     individual = Individual()
     individual.no_of_Cluster = no_of_cluster
     individual.labels = label
     #individual.BHI = self.zdt_definitions.BHI(individual)
     individual.features = []
     for sub_list in centroids:
         for feature in sub_list:
             individual.features.append(feature)
     print(individual.no_of_Cluster)
     return individual
    def generate_individual(self):
        """
        Parameters
        ----------
        
        Returns
        -------
        individual
            a new random portfolio
       
        """

        individual = Individual()
        individual.features = self.init_population(self.portfolio_size, 1,
                                                   self.Q, self.Q_rfa,
                                                   self.C)[0]
        return individual
Пример #6
0
 def generateIndividual(self, new_msr, new_rv, new_bisize, nsol_K,
                        nsol_label, nsol):
     individual = Individual()
     individual.features = []
     individual.ob1 = new_msr
     individual.ob2 = new_rv
     individual.ob3 = new_bisize
     individual.K = nsol_K
     individual.label = nsol_label
     for i in range(len(nsol)):
         individual.features.append(nsol[i])
     individual.dominates = functools.partial(self.__dominates,
                                              individual1=individual)
     self.calculate_objectives(individual)
     return individual
Пример #7
0
 def generate_individual(self):
     individual = Individual()
     individual.id = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
     individual.features = [random.uniform(*x) for x in self.variables_range]
     hyperparameters = ['criterion', 'max_depth', 'min_samples_split', 'max_leaf_nodes', 'class_weight']
     individual.features = od(zip(hyperparameters, individual.features))
     individual.features = decode(self.variables_range, **individual.features)
     individual.creation_mode = "inicialization"
     return individual
Пример #8
0
 def generateIndividual(self):
     xy = FCM(self.all_data_matrix, self.individual_no)
     center, u, d, fpc, no_of_cluster, label = xy.FuzzyCMeans(
     )  #Generate each individual using Fuzzy C means
     individual = Individual()
     individual.partition_matrix = u
     individual.distance_matrix = d
     individual.no_of_Cluster = no_of_cluster
     individual.fpc = fpc
     individual.labels = label
     #individual.BHI = self.zdt_definitions.BHI(individual)
     individual.features = []
     for sub_list in center:
         for feature in sub_list:
             individual.features.append(feature)
     #print individual.no_of_Cluster , individual.features
     individual.dominates = functools.partial(self.__dominates,
                                              individual1=individual)
     self.calculate_objectives(individual)
     return individual
Пример #9
0
 def generateIndividual(self):
     
     individual = Individual()
     individual.vardim = self.vardim
     individual.bound = self.bound
     individual.hos_opt = self.hos_opt
             
     ##-----------------初始化待优化的医院---------------##
     '''初始化随机生成染色体(多个基因的list),长度为个体的维度'''
     len = self.vardim
     rnd = np.random.random(size=len) #n维0-1之间的向量
     individual.features = np.zeros(len) #长尾为n的0维向量
     #在上限、下限之间生成染色体的值
     for i in xrange(0, len):
         individual.features[i] = int(self.bound[0, i] + (self.bound[1, i] - self.bound[0, i]) * rnd[i])
     #计算目标函数值
     self.calculate_objectives(individual)
     #进行支配非支配的计算
     individual.dominates = functools.partial(self.__dominates, individual1=individual)
     return individual
Пример #10
0
 def generate_default_individual_entropy(self):
     individual = Individual()
     individual.id = ''.join(
         random.choice(string.ascii_uppercase + string.digits)
         for _ in range(10))
     individual.features = [1, None, 2, None, None]
     hyperparameters = [
         'criterion', 'max_depth', 'min_samples_split', 'max_leaf_nodes',
         'class_weight'
     ]
     #individual.features = [1, None, 1, 0.00001, None]
     #hyperparameters = ['criterion','max_depth', 'min_samples_leaf', 'min_impurity_decrease', 'class_weight']
     individual.features = od(zip(hyperparameters, individual.features))
     individual.features = decode(self.variables_range,
                                  **individual.features)
     individual.creation_mode = "inicialization"
     return individual
Пример #11
0
 def generate_individual(self):
     individual = Individual()
     individual.features = [random.uniform(*x) for x in self.variables_range]
     return individual