def reproduction(self,ind):
        self.environment.delete(ind.drawing)   #delete the drawings of all parents (they are about to die)
        if max(ind.kernelshape) > self.max_kernel:
            self.max_kernel = max(ind.kernelshape) 
        elif min(ind.kernelshape) < self.min_kernel:
            self.min_kernel = min(ind.kernelshape)

        if not ind.male:
            male_gene=self.densloc.get_male_gene(ind.x,ind.y) 
            if male_gene!=None:          
                #b=6
                #a=((self.growthrate**(1/float(b))-1)/float(equilibrium_density))
                #mean_n_seeds=(self.growthrate)/(1+(a*(self.density.densloc_check(self.x,self.y)-1))**b)
                self.growthrate = 5               
                a=(self.growthrate-1)/float(self.equilibrium_density)
                mean_n_seeds=self.growthrate/(1+a*(self.densloc.densloc_check(ind.x,ind.y)-1))
                n_seeds=poisson(mean_n_seeds)
                offspring=[]
                for r in xrange(n_seeds):   #For all seeds check if they mutate on one of the two genes and transfer the parent traits into the new individual (+ the mutation)
                    if rnd.random()<0.5:
                        mother_allele = ind.kernelshape[0]
                    else:
                        mother_allele = ind.kernelshape[1]
                    if rnd.random()<0.5:
                        father_allele = male_gene[0][0]
                    else:
                        father_allele = male_gene[0][1]                
                    if np.random.random()>self.sexratio:
                        male=True
                    else:
                        male=False                             
                    offspring.append(individual(ind.x, ind.y,
                                                [mother_allele,
                                                 father_allele],
                                                male,
                                                male_gene[1],
                                                ind.random_gene))        
                self.individuals.extend(offspring)
            else:
                #a=((self.growthrate**(1/float(b))-1)/float(equilibrium_density))
                #mean_n_seeds=(self.growthrate)/(1+(a*(self.density.densloc_check(self.x,self.y)-1))**b)
                self.growthrate = 2.5               
                a=(self.growthrate-1)/float(self.equilibrium_density)
                mean_n_seeds=self.growthrate/(1+a*(self.densloc.densloc_check(ind.x,ind.y)-1))
                n_seeds=poisson(mean_n_seeds)
                offspring=[]
                for r in xrange(n_seeds):   #For all seeds check if they mutate on one of the two genes and transfer the parent traits into the new individual (+ the mutation)
                    mother_allele1 = ind.kernelshape[0]
                    mother_allele2 = ind.kernelshape[1]      
                    if np.random.random()>self.sexratio:
                        male=True
                    else:
                        male=False                             
                    offspring.append(individual(ind.x, ind.y,
                                                [mother_allele1,
                                                 mother_allele2],
                                                male,
                                                ind.random_gene,
                                                ind.random_gene))        
                self.individuals.extend(offspring)                
Beispiel #2
0
 def reproduction(self,ind):
     self.environment.delete(ind.drawing)   #delete the drawings of all parents (they are about to die)
     if not ind.male:
         male_gene=self.densloc.get_male_gene(ind.x,ind.y) 
         if male_gene!=None:          
             #b=6
             #a=((self.growthrate**(1/float(b))-1)/float(equilibrium_density))
             #mean_n_seeds=(self.growthrate)/(1+(a*(self.density.densloc_check(self.x,self.y)-1))**b)
             self.growthrate = 5               
             a=(self.growthrate-1)/float(self.equilibrium_density)
             mean_n_seeds=self.growthrate/(1+a*(self.densloc.densloc_check(ind.x,ind.y)-1))
             n_seeds=poisson(mean_n_seeds)
             offspring=[]
             for r in xrange(n_seeds):   #For all seeds check if they mutate on one of the two genes and transfer the parent traits into the new individual (+ the mutation)
                 if rnd.random()<0.5:
                     mother_allele = ind.kernelshape[0]
                 else:
                     mother_allele = ind.kernelshape[1]
                 if rnd.random()<0.5:
                     father_allele = male_gene[0][0]
                 else:
                     father_allele = male_gene[0][1]                
                 if np.random.random()>self.sexratio:
                     male=True
                 else:
                     male=False
                 offspring.append(individual(ind.x, ind.y,
                                             [mother_allele,
                                              father_allele],
                                             male,
                                             male_gene[1],
                                             ind.random_gene))        
             self.individuals.extend(offspring)
         else:
             #a=((self.growthrate**(1/float(b))-1)/float(equilibrium_density))
             #mean_n_seeds=(self.growthrate)/(1+(a*(self.density.densloc_check(self.x,self.y)-1))**b)
             self.growthrate = 2.5               
             a=(self.growthrate-1)/float(self.equilibrium_density)
             mean_n_seeds=self.growthrate/(1+a*(self.densloc.densloc_check(ind.x,ind.y)-1))
             n_seeds=poisson(mean_n_seeds)
             offspring=[]
             for r in xrange(n_seeds):   #For all seeds check if they mutate on one of the two genes and transfer the parent traits into the new individual (+ the mutation)
                 mother_allele1 = ind.kernelshape[0]
                 mother_allele2 = ind.kernelshape[1]      
                 if np.random.random()>self.sexratio:
                     male=True
                 else:
                     male=False
                 offspring.append(individual(ind.x, ind.y,
                                             [mother_allele1,
                                              mother_allele2],
                                             male,
                                             ind.random_gene,
                                             ind.random_gene))
             self.individuals.extend(offspring)
    def reproduction(self,ind):
        self.environment.delete(ind.drawing)   #delete the drawings of all parents (they are about to die)
        if ind.kernelshape > self.max_kernel:
            self.max_kernel = ind.kernelshape 
        elif ind.kernelshape < self.min_kernel:
            self.max_kernel = ind.kernelshape

        if not ind.male:
            male_gene=self.densloc.get_male_gene(ind.x,ind.y) 
            if male_gene!=None:          
                #b=6
                #a=((self.growthrate**(1/float(b))-1)/float(equilibrium_density))
                #mean_n_seeds=(self.growthrate)/(1+(a*(self.density.densloc_check(self.x,self.y)-1))**b)
                self.growthrate = 20                
                a=(self.growthrate-1)/float(self.equilibrium_density)
                mean_n_seeds=self.growthrate/(1+a*(self.densloc.densloc_check(ind.x,ind.y)-1))
                n_seeds=poisson(mean_n_seeds)
                offspring=[]
                new_gene=(ind.kernelshape+male_gene[0])/float(2)
                for r in xrange(n_seeds):   #For all seeds check if they mutate on one of the two genes and transfer the parent traits into the new individual (+ the mutation)
                    mutation=0
                    if np.random.random()<self.mutationrate:
                        mutation=np.random.uniform(-0.5,0.5)
                        if new_gene+mutation<0:
                            mutation=-mutation
                    if np.random.random()>self.sexratio:
                        male=True
                    else:
                        male=False                             
                    offspring.append(individual(ind.x, ind.y,
                                                new_gene+mutation,
                                                male,
                                                male_gene[1],
                                                ind.random_gene))        
                self.individuals.extend(offspring)
    def reproduction(self, ind):
        self.environment.delete(ind.drawing)  # delete the drawings of all parents (they are about to die)
        if ind.kernelshape > self.max_kernel:
            self.max_kernel = ind.kernelshape
        elif ind.kernelshape < self.min_kernel:
            self.max_kernel = ind.kernelshape

        if not ind.male:
            male_gene = self.densloc.get_male_gene(ind.x, ind.y)
            if male_gene != None:
                # b=6
                # a=((self.growthrate**(1/float(b))-1)/float(equilibrium_density))
                # mean_n_seeds=(self.growthrate)/(1+(a*(self.density.densloc_check(self.x,self.y)-1))**b)
                self.growthrate = 20
                a = (self.growthrate - 1) / float(self.equilibrium_density)
                mean_n_seeds = self.growthrate / (1 + a * (self.densloc.densloc_check(ind.x, ind.y) - 1))
                n_seeds = poisson(mean_n_seeds)
                offspring = []
                new_gene = (ind.kernelshape + male_gene[0]) / float(2)
                for r in xrange(
                    n_seeds
                ):  # For all seeds check if they mutate on one of the two genes and transfer the parent traits into the new individual (+ the mutation)
                    mutation = 0
                    if np.random.random() < self.mutationrate:
                        mutation = np.random.uniform(-0.5, 0.5)
                        if new_gene + mutation < 0:
                            mutation = -mutation
                    if np.random.random() > self.sexratio:
                        male = True
                    else:
                        male = False
                    offspring.append(individual(ind.x, ind.y, new_gene + mutation, male, male_gene[1], ind.random_gene))
                self.individuals.extend(offspring)
Beispiel #5
0
 def reproduction(self, equilibrium_density, mutationrate, generalists):
     self.density.add_gendispersal_allele(self.kernelshape)
     self.environment.delete(
         self.drawing
     )  #delete the drawings of all parents (they are about to die)
     if not self.male_sex:
         male_gene = self.density.get_male_gene(self.x, self.y)
         if male_gene != None:
             self.generalists = generalists
             #b=6
             #a=((self.growthrate**(1/float(b))-1)/float(equilibrium_density))
             #mean_n_seeds=(self.growthrate)/(1+(a*(self.density.densloc_check(self.x,self.y)-1))**b)
             a = (self.growthrate - 1) / float(equilibrium_density)
             mean_n_seeds = self.growthrate / (
                 1 + a * (self.density.densloc_check(self.x, self.y) - 1))
             n_seeds = poisson(mean_n_seeds)
             offspring = []
             new_gene = (self.kernelshape + male_gene) / float(2)
             for r in xrange(
                     n_seeds
             ):  #For all seeds check if they mutate on one of the two genes and transfer the parent traits into the new individual (+ the mutation)
                 mutation = 0
                 if np.random.random() < mutationrate:
                     mutation = np.random.uniform(-0.5, 0.5)
                     if new_gene + mutation < 0:
                         mutation = -mutation
                 anchestor_info = self.anchestor_info[:]
                 offspring.append(
                     Generalist(self.x, self.y, self.max_y,
                                new_gene + mutation, self.environment,
                                self.density, anchestor_info,
                                self.sexratio))
             self.generalists.extend(offspring)
 def reproduction(self,equilibrium_density,mutationrate,generalists):
     self.generalists=generalists
     self.density.add_gendispersal_allele(self.kernelshape)
     #self.environment.delete(self.drawing)   #delete the drawings of all parents (they are about to die)
     #b=6
     #a=((self.growthrate**(1/float(b))-1)/float(equilibrium_density))
     #mean_n_seeds=(self.growthrate)/(1+(a*(self.density.densloc_check(self.x,self.y)-1))**b)
     a=(self.growthrate-1)/float(equilibrium_density)
     mean_n_seeds=self.growthrate/(1+a*(self.density.densloc_check(self.x,self.y)-1))
     n_seeds=poisson(mean_n_seeds)
     offspring=[]
     for r in xrange(n_seeds):   #For all seeds check if they mutate on one of the two genes and transfer the parent traits into the new individual (+ the mutation)
         mutation=0
         if random()<mutationrate:
             mutation=uniform(-0.5,0.5)
             if self.kernelshape+mutation<0:
                 mutation=-mutation
         anchestor_info=self.anchestor_info[:]
         offspring.append(Generalist(self.x, self.y,self.kernelshape+mutation,self.environment,self.density,anchestor_info))        
     self.generalists.extend(offspring)
Beispiel #7
0
#f=fits.open(c.psffile)
#c.psf = f[0].data
#f.close()        
# normalise the psf
#c.psf = c.psf/c.psf.sum()

# Initialise the arrays that will form the N Tuple for minimization
#x = np.zeros(c.nxpts*c.nypts)
#y = np.arange(c.nxpts*c.nypts)
#xerr = np.zeros(c.nxpts*c.nypts)
#yerr = np.zeros(c.nxpts*c.nypts)

numra.seed(11198205, 120980)# Set random number seed

# compute errors assuming poisson fluctuations in electrons
zerr = np.sqrt((abs(numra.poisson(z)-z)*c.gain)**2.0+c.rdnoise**2.0)

# Populate x and y arrays
#k = 0
#for i in range(c.nxpts) :
 #   for j in range(c.nypts) :
  #      y[k] = j
   #     x[k] = i
    #    k += 1

# Generate the N-Tuple for the input data. Hippodraw needs it in this form

#from hippo import NTuple
#nt = NTuple () # empty one
#nt.addColumn ( 'x', x )
#nt.addColumn ( 'y', y )
Beispiel #8
0
    def reproduction(self, ind):
        self.environment.delete(
            ind.drawing
        )  #delete the drawings of all parents (they are about to die)
        if max(ind.kernelshape) > self.max_kernel:
            self.max_kernel = max(ind.kernelshape)
        elif min(ind.kernelshape) < self.min_kernel:
            self.max_kernel = min(ind.kernelshape)

        if not ind.male:
            male_gene = self.densloc.get_male_gene(ind.x, ind.y)
            if male_gene != None:
                #b=6
                #a=((self.growthrate**(1/float(b))-1)/float(equilibrium_density))
                #mean_n_seeds=(self.growthrate)/(1+(a*(self.density.densloc_check(self.x,self.y)-1))**b)
                self.growthrate = 5
                a = (self.growthrate - 1) / float(self.equilibrium_density)
                mean_n_seeds = self.growthrate / (
                    1 + a * (self.densloc.densloc_check(ind.x, ind.y) - 1))
                n_seeds = poisson(mean_n_seeds)
                offspring = []
                for r in xrange(
                        n_seeds
                ):  #For all seeds check if they mutate on one of the two genes and transfer the parent traits into the new individual (+ the mutation)
                    #sample a new father for each offspring (already selected for the first one)
                    if r > 0:
                        male_gene = self.densloc.get_male_gene(ind.x, ind.y)
                    if rnd.random() < 0.5:
                        mother_allele = ind.kernelshape[0]
                    else:
                        mother_allele = ind.kernelshape[1]
                    if rnd.random() < 0.5:
                        father_allele = male_gene[0][0]
                    else:
                        father_allele = male_gene[0][1]
                    mutation1 = 0
                    if np.random.random() < self.mutationrate:
                        mutation1 = np.random.uniform(-0.5, 0.5)
                        if mother_allele + mutation1 < 0:
                            mutation1 = -mutation1
                    mutation2 = 0
                    if np.random.random() < self.mutationrate:
                        mutation2 = np.random.uniform(-0.5, 0.5)
                        if father_allele + mutation2 < 0:
                            mutation2 = -mutation2
                    if np.random.random() > self.sexratio:
                        male = True
                    else:
                        male = False
                    offspring.append(
                        individual(ind.x, ind.y, [
                            mother_allele + mutation1,
                            father_allele + mutation2
                        ], male, male_gene[1], ind.random_gene))
                self.individuals.extend(offspring)
            else:
                #a=((self.growthrate**(1/float(b))-1)/float(equilibrium_density))
                #mean_n_seeds=(self.growthrate)/(1+(a*(self.density.densloc_check(self.x,self.y)-1))**b)
                self.growthrate = 2.5
                a = (self.growthrate - 1) / float(self.equilibrium_density)
                mean_n_seeds = self.growthrate / (
                    1 + a * (self.densloc.densloc_check(ind.x, ind.y) - 1))
                n_seeds = poisson(mean_n_seeds)
                offspring = []
                for r in xrange(
                        n_seeds
                ):  #For all seeds check if they mutate on one of the two genes and transfer the parent traits into the new individual (+ the mutation)
                    mother_allele1 = ind.kernelshape[0]
                    mother_allele2 = ind.kernelshape[1]
                    mutation1 = 0
                    if np.random.random() < self.mutationrate:
                        mutation1 = np.random.uniform(-0.5, 0.5)
                        if mother_allele1 + mutation1 < 0:
                            mutation1 = -mutation1
                    mutation2 = 0
                    if np.random.random() < self.mutationrate:
                        mutation2 = np.random.uniform(-0.5, 0.5)
                        if mother_allele2 + mutation2 < 0:
                            mutation2 = -mutation2
                    if np.random.random() > self.sexratio:
                        male = True
                    else:
                        male = False
                    offspring.append(
                        individual(ind.x, ind.y, [
                            mother_allele1 + mutation1,
                            mother_allele2 + mutation2
                        ], male, ind.random_gene, ind.random_gene))
                self.individuals.extend(offspring)