▉ΝβκS 发表于 2014-7-25 11:43

penna模型论文以及代码

无性繁殖Penna模型一、 设计思路(包括规则说明 参数设定)       1. 模型规则:生物体由基因构成,基因可以分类,最简单的分类方式为两类,以好坏界定,用0,1表示,构成方式为有限长串结构..规则:(1) 死亡机制:    老死:B     活到B岁(最大年龄),下一步死亡疾病:        活到当前年龄,累计的“疾病”次数达到 Tc次,下一时刻死亡环境压力:    每个个体以概率  http://s9.sinaimg.cn/mw690/003rPRaSzy6K3t6c44g38&690 (Verhulst因子) 生存 (2) 繁殖机制:最低繁殖年龄:R   每个个体活到R岁时,开始繁殖,繁殖时,采用拷贝加突变的方式形成子代突变:M   突变强度为M,此处为M个位置  个数:b   每次繁殖b个子代; 二、 代码(关键部分加注释)#include #include #include int i,j,t;double x,y;FILE *fp;#define GeneSize 32#define N0 1000 #define Nmax 100000#define TIME 1000#define ReproductionAge 8#define T 2struct {int Gene;//int Age;int BadGeneNum;int LiveOrDie;//活着是0;死的是1}Agent;         //定义结构体数组表示每个个体int Nt=N0;void Intial()            //初始化函数{for(i=0;i{Agent.Age=0;Agent.BadGeneNum=0;for (j=0;j{x=rand();y=x/32767;if(y<0.01)         //初始基因串随机给出,坏基因比例0.01            {Agent.Gene=1;}else            {Agent.Gene=0;}
}        if (i{Agent.LiveOrDie=0;}else{Agent.LiveOrDie=1;}}}void Age(int i)                //年龄机制函数{if (Agent.Gene.Age]==1)Agent.BadGeneNum++;Agent.Age++;}void Die(int i)                  //死亡机制函数{double v;v=(double)rand()/RAND_MAX;if (Agent.BadGeneNum>=T){    Nt-=1;    Agent.LiveOrDie==1;}else if (v<((double)Nt/Nmax)){Nt-=1;    Agent.LiveOrDie==1;}else if (Agent.Age>=GeneSize){Nt-=1;    Agent.LiveOrDie==1;    }}void Reproduction(int i){k=0;int z1,z2;z1=rand()2;z2=rand()2;while(Agent.LiveOrDie==0)    //将b个原本死亡的格子变活,b=1k=k++;Agent.Age=0;                //对新生的个体赋予年龄值    Agent.BadGeneNum=0;for (j=0;j{   Agent.Gene=Agent.Gene;   if( Agent.Gene==1)    Agent.Gene=0;   else    Agent.Gene=1;   if( Agent.Gene==0)    Agent.Gene=1;   else    Agent.Gene=0;}    Nt=Nt+1;Agent.LiveOrDie=0;}                                       //z1,z2突变位置void main(){ srand((unsigned)time(NULL));Intial();  //初始化       //时间步迭代fp=fopen("penna.txt","w"); for(t=0;t{for (i=0;i{if (Agent.LiveOrDie==0){Age(i);//年龄加1;更新坏基因数Die(i);//判断死亡1.坏基因致死,2.环境压力致死.3老死}}for (j=0;j{if (Agent.LiveOrDie==0 && Agent.Age>=ReproductionAge){Reproduction(j);}}
fprintf(fp,"%d\t",Nt); } }三、 结果及分析(包括图及分析)(1)对P(B=32, 105, 2, 8, 1, M)最大年龄B=32岁,最大种群数Nmax=105,疾病次数Tc=2,最低繁殖年龄R=8,每次繁殖子代个数b=1,突变:M=0,t=1000;100,种群规模随时间的变化图http://s7.sinaimg.cn/mw690/003rPRaSzy6K3teJ1vo36&690图一    M=2,t=1000;   
http://s13.sinaimg.cn/mw690/003rPRaSzy6K3tiBmiwec&690图二     M=2,t=100
http://s9.sinaimg.cn/mw690/003rPRaSzy6K3tlJmw828&690

               图三    M=2,t=1000;                               http://s10.sinaimg.cn/mw690/003rPRaSzy6K3tniCgx99&690
                                                                     图四    M=2,t=1000;                                                                       
(2) 对P(32, 105, 4, R, 1, 2) R取2、4、6作稳定后的年龄结构图。由(1)知,t=200以后种群数量已经稳定,所以考虑t=200时的年龄组成即可。http://s9.sinaimg.cn/mw690/003rPRaSzy6K3tslly0c8&690                                        图五  R=2,t=200年龄结构图        http://s2.sinaimg.cn/mw690/003rPRaSzy6K3twmTmNd1&690               
                    图六 R=4,t=200年龄结构图http://s12.sinaimg.cn/mw690/003rPRaSzy6K3txKaW7fb&690                                 图七  R=6,t=200年龄结构图

页: [1]
查看完整版本: penna模型论文以及代码