def evaluate(self,gene): dev = (gene.bounds[1]-gene.bounds[0]) * self.dev_width new = gene.bounds[1] # while not (gene.bounds[0] <= new < gene.bounds[1]): # new = prng.normal(gene.value(),dev) # new = prng.normal(gene.value(),dev) #get the _value explicitly so mutator will work for log_float also new = prng.normal(gene._value,dev) if new > gene.bounds[1]: new = gene.bounds[1] if new < gene.bounds[0]: new = gene.bounds[0] return new
def evaluate(self,gene): """ return a new value from the genes allele set """ size = len(gene.allele_set) if size == 1: return gene.allele_set[0] w = self.dev_width * size old = gene.index() new = -1; f = -1 while not (0 <= new < size): f = prng.normal(old,w) new = round(f) if(old == new and f > new): new = new + 1 if(old == new and f < new): new = new - 1 return gene.allele_set[int(new)]