def grad_cap(self,prerounding=False): if not prerounding: mt_cap = self.biennial_cap(c.INTERMEDIATE,mt=True).cap() + self.biennial_cap(c.ADVANCED, mt=True).cap() no_mt_cap = self.biennial_cap(c.INTERMEDIATE,mt=False).cap() + self.biennial_cap(c.ADVANCED, mt=False).cap() #print(mt_cap/2) #print(no_mt_cap/2) return max(mt_cap,no_mt_cap)/2 else: mt_cap_i = common.round(self.biennial_cap(c.INTERMEDIATE,mt=True).cap(),1) mt_cap_a = common.round(self.biennial_cap(c.ADVANCED, mt=True).cap(),1) mt_cap = (mt_cap_i+mt_cap_a)/2 no_mt_cap_i = common.round(self.biennial_cap(c.INTERMEDIATE,mt=False).cap(),1) no_mt_cap_a = common.round(self.biennial_cap(c.ADVANCED, mt=False).cap(),1) no_mt_cap = (no_mt_cap_i+no_mt_cap_a)/2 return max(no_mt_cap,mt_cap)
def es_mutate_individual(individual, steps, minmax): data = individual[0] new_data = [] mutated_idx = random.randint(0,len(data)) for idx,value in enumerate(data): if mutated_idx == idx: new_value = value + (steps[idx] * common.gaussian(0,1)) else: new_value = value new_data.append(common.round(new_value)) return (new_data, steps)
def es_mutate_population(population, steps, minmax): data = population[0] new_data = [] #mutation_idx = random.randint(0, len(population)) for idx,value in enumerate(data): new_value = value + (steps[idx] * common.gaussian(0,1)) # Make sure mutated value no over passes max limit # We're not using negative values new_value = new_value % minmax[1] new_data.append(common.round(abs(new_value))) return (new_data, steps)
def es_mutate_individual(individual, steps, minmax): data = individual[0] new_data = [] mutated_idx = random.randint(0, len(data)) for idx, value in enumerate(data): if mutated_idx == idx: new_value = value + (steps[idx] * common.gaussian(0, 1)) else: new_value = value new_data.append(common.round(new_value)) return (new_data, steps)
def es_mutate_population(population, steps, minmax): data = population[0] new_data = [] #mutation_idx = random.randint(0, len(population)) for idx, value in enumerate(data): new_value = value + (steps[idx] * common.gaussian(0, 1)) # Make sure mutated value no over passes max limit # We're not using negative values new_value = new_value % minmax[1] new_data.append(common.round(abs(new_value))) return (new_data, steps)