亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? scs.cpp

?? 這是一個基于遺傳算法的人工生命模擬 AL_GA.C
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
 child2->c[j]=mutation(parent1->c[j],pmutation,nmutation);
 child1->c[j]=mutation(parent2->c[j],pmutation,nmutation);
 j=j+1;
}
j=0;
while(j<sitecross)
{
 child1->c[j]=mutation(parent1->c[j],pmutation,nmutation);
 child2->c[j]=mutation(parent2->c[j],pmutation,nmutation);
 j=j+1;
}
inheritance=avg(parent1->strength,parent2->strength);
child1->strength=inheritance;child1->matchflag=0;
child1->ebid=0.0;child1->bid=0.0;
child1->specificity=counterspecificity(child1->c,nposition);
child2->strength=inheritance;child2->matchflag=0;
child2->ebid=0.0;child2->bid=0.0;
child2->specificity=counterspecificity(child2->c,nposition);
}

int worstofn(struct poptype *population, int n)
{
int j,worst,candidate;
float worststrength;
worst=rnd(0, population->nclassifier-1);
worststrength=population->classifier[worst].strength;
if(n>0)
{
   for(j=1;j<=n-1;j++)
 {
  candidate=rnd(0,population->nclassifier-1);
  if(worststrength>population->classifier[candidate].strength)
    {
    worst=candidate;
    worststrength=population->classifier[worst].strength;
    }
 }
}
return(worst);
}

int matchcount(struct classtype *classifier1,struct classtype *classifier2,int nposition)
{
int tempcount,j;
   if(classifier1->a==classifier2->a)
     tempcount=1;
   else
     tempcount=0;
  for(j=0;j<=nposition-1;j++)
     if( classifier1->c[j]==classifier2->c[j])    tempcount=tempcount+1;
   return(tempcount);    
}

int crowding(struct classtype *child,struct poptype *population,int &crowdingfactor,int crowdingsubpop)
{
int popmember,j,match,matchfmax,mostsimilar;
matchfmax=-1;  mostsimilar=0;
if(crowdingfactor<1)  crowdingfactor=1;
for(j=0;j<=crowdingfactor-1;j++)
{
   popmember=worstofn(population,crowdingsubpop);
   match=matchcount(child,&population->classifier[popmember],population->nposition);
   if(match>matchfmax)
    {
     matchfmax=match;
     mostsimilar=popmember;
    }
 }
return(mostsimilar);
}

void statistics(struct poptype *population)
{
 int j;
 population->fmaxstrength=population->classifier[0].strength;
 population->fminstrength=population->classifier[0].strength;
 population->sumstrength=population->classifier[0].strength;
j=1;
while(j<=population->nclassifier-1)
  {
  population->fmaxstrength=fmax(population->fmaxstrength,population->classifier[j].strength);
  population->fminstrength=fmin(population->fminstrength,population->classifier[j].strength);
  population->sumstrength=population->sumstrength+population->classifier[j].strength;
  j++;
  }
  population->avgstrength=population->sumstrength/population->nclassifier;
}

void ga(struct grecord *garec,struct poptype *population)
{
int j;
struct classtype *child;
int nbytes;
child=(struct classtype *)malloc(2*sizeof(struct classtype));
nbytes=population->nposition*sizeof(int);
child[0].c = (int *) malloc(nbytes);
child[1].c = (int *) malloc(nbytes);

statistics(population);
for(j=0;j<=garec->nselect-1;j++)
  {
   garec->mating[j].mate1=select(population);
   garec->mating[j].mate2=select(population);
   crossover(&population->classifier[garec->mating[j].mate1],&population->classifier[garec->mating[j].mate1],&child[0],&child[1], garec->pcrossover,
              garec->pmutation,garec->mating[j].sitecross,population->nposition,garec->ncrossover,garec->nmutation);
  
   garec->mating[j].mort1=crowding(&child[0],population,garec->crowdingfactor,garec->crowdingsubpop);
   population->sumstrength=population->sumstrength-population->classifier[garec->mating[j].mort1].strength+child[0].strength;
   population->classifier[garec->mating[j].mort1]=child[0];
   garec->mating[j].mort2=crowding(&child[1],population,garec->crowdingfactor,garec->crowdingsubpop);
   population->sumstrength=population->sumstrength-population->classifier[garec->mating[j].mort2].strength+child[1].strength;
   population->classifier[garec->mating[j].mort2]=child[1];
  }
}

void reportga(struct grecord *garec,struct poptype *population )
{
  int j;
 skip(1);
 rep<<"           遺傳算法報告: "<<endl;
 rep<<" --------------------------------------------"<<endl;
 rep<<"  對數   父1   父2  交叉位置  子1   子2  "<<endl;
 rep<<" ---------------------------------------------"<<endl;
   for(j=0; j<=garec->nselect-1;j++)
   {
   rep<<setw(6)<<j<<setw(6)<< garec->mating[j].mate1;
   rep<<setw(6)<<garec->mating[j].mate2<<setw(6)<<garec->mating[j].sitecross;
   rep<<setw(6)<<garec->mating[j].mort1<<setw(6)<<garec->mating[j].mort2<<endl;
   }
 rep<<" 統計數據: "<<endl;
 rep<<"----------------------"<<endl;
 rep<<" 平均權值 ="<<population->avgstrength<<endl;
 rep<<" 最大權值 ="<<population->fmaxstrength<<endl;
 rep<<" 最小權值 ="<<population->fminstrength<<endl;
 rep<<" 權值和   ="<<population->sumstrength<<endl;
 rep<<" 交叉數目 ="<<garec->ncrossover<<endl;
 rep<<" 變異數目 ="<<garec->nmutation<<endl;
}

float rndreal(float lo ,float hi)    /*在浮點數lo和hi之間產生一個隨機實數*/
{
    return((float)(rand()/32767. * (hi - lo)) + lo);
}

void initrandomnormaldeviate()      /* 隨機標準差的初始化 */
{
    rndcalcflag = 1;
}

double randomnormaldeviate()        /* 產生隨機標準差 */
{
    double t, rndx1;
    if(rndcalcflag)
    {   rndx1 = sqrt(- 2.0*log((double) rand()/32767.));
        t = 6.2831853072 * (double) rand()/32767.;
        rndx2 = rndx1 * sin(t);
        rndcalcflag = 0;
        return(rndx1 * cos(t));
    }
    else
    {
        rndcalcflag = 1;
        return(rndx2);
    }
}


float noise(float mu ,float sigma)    /* 產生具有給定均值和標準均方差的隨機數 */
{
    return((float)(randomnormaldeviate()*sigma) + mu);
}

void skip(int skipcount)
{
    int j;
    for (j = 1; j <= skipcount; j++) rep<<endl;
}

int flip(float prob)             /* 以一定概率產生0或1 */
{
    if(prob==1.0)
        return(1);
    else
        return((rand()/32767. <= prob));
}

int rnd(int low,int high) /*在整數low和high之間產生一個隨機整數*/
{
    int i;
      if(low >= high)
        i = low;
    else
    {
        i = (int)(rand()/32767. * (high - low + 1)) + low;
        if(i > high) i = high;
    }
    return(i);
}


float fmax(float x,float y)
{
if(x>y)
return(x);
else
return(y);
}

float fmin(float x,float y)
{
if(x<y)
return(x);
else
return(y);
}

float avg(float x,float y)
{
return((float)(0.5*(x+y)));
}

int halt()
{
const times=1000;
int temp;
int j;
/* int ch;*/
j=0;
 do
 {
  j++;
 }while(j<times);
 temp=(j<times);
 /*
 cout<<"是否繼續?(1/0)";
 cin>>ch;
 if(ch==1) 
	return(0);
 else
    return(1); */
 return(temp);
}

void initmalloc()     /*為全局數據變量分配空間 */
{
  int nbytes,ncbytes;
  int j;
  int fmaxc,fmaxp;
  cfile>>fmaxp;
  cfile>>fmaxc;
  ncbytes =fmaxc*(fmaxp*sizeof(int)+3*sizeof(int)+3*sizeof(float));
     if((pop->classifier = (struct classtype *) malloc(ncbytes)) == NULL)
        { cout<<"malloc: out of memory making !!"<<endl;
         exit(-1);
        } 
   nbytes=fmaxp*sizeof(int);
   for(j=0;j<=fmaxc-1;j++)
   {
      if((pop->classifier[j].c = (int *) malloc(nbytes)) == NULL)
        { cout<<"malloc: out of memory making !!"<<endl;
        exit(-1);
	  }
   }
   nbytes=fmaxp*sizeof(int);
     if((envmessage = (int *) malloc(nbytes)) == NULL)
        { cout<<"malloc: out of memory making !!\n"<<endl;
        exit(-1);
        }
   if((matchl->clist = (int *) malloc(pop->nclassifier*sizeof(int))) == NULL)
    { cout<<"malloc: out of memory making !!\n"<<endl;
     exit(-1);
    }

   nbytes=fmaxp*sizeof(int);
       if((environrec.signal = (int *) malloc(nbytes)) == NULL)
        { cout<<"malloc: out of memory making !!\n"<<endl;
        exit(-1);
        }
   nbytes = fmaxmating*sizeof(struct mrecord);
       if((garec.mating = (struct mrecord *) malloc(nbytes)) == NULL)
        { cout<<"malloc: out of memory making !!\n"<<endl;
        exit(-1);
        }
  pop->nclassifier=fmaxc;
  pop->nposition=fmaxp;
}

void generatecfile()
{
    int nclassifier,nposition;      
    float pgeneral,cbid,bidsigma,bidtax,lifetax,bid1,bid2,ebid1,ebid2;  
    float strength;
	int i,j;
	float temprand;
    ofstream rcfile("c:\\scs\\cfile.txt");   

    cout<<" 分類器前件碼長=";
    cin>>nposition;
    rcfile<<nposition<<endl;
		
	cout<<" 分類器數目= ";
    cin>>nclassifier;
	rcfile<<nclassifier<<endl;
    
	cout<<" 隨機概率= ";
    cin>>pgeneral;
	rcfile<<pgeneral<<endl;

	cout<<" 投標系數= ";   
    cin>>cbid;
    rcfile<<cbid<<endl;

    cout<<" 有效投標中隨機噪聲的均方差 = ";
    cin>>bidsigma;
	rcfile<<bidsigma<<endl;
	
    cout<<" 投標稅= ";
	cin>>bidtax;
	rcfile<<bidtax<<endl;

    cout<<" 存活稅  = ";
    cin>>lifetax;
	rcfile<<lifetax<<endl;

	cout<<" 投標確定性基數 = ";
    cin>>bid1;
	rcfile<<bid1<<endl;

    cout<<" 投標確定性倍率 = ";
    cin>>bid2;
	rcfile<<bid2<<endl;

    cout<<" 有效投標確定性基數 = ";
	cin>>ebid1;
	rcfile<<ebid1<<endl;

	cout<<" 有效投標確定性倍率 = ";
    cin>>ebid2;
    rcfile<<ebid2<<endl;
  
	cout<<" 分類器初始權值 = ";
    cin>>strength;
    
   for(i=0;i<=nclassifier-1;i++)
   {
	   for(j=0;j<=nposition-1;j++)
	   {
		temprand=(float)(rand()/32767.);
	   if(temprand<1./3)
	    rcfile<<"0";
	   else if((temprand>=1/3.)&&(temprand<2/3.))
	    rcfile<<"1";
	   else
	   rcfile<<"#";
	   }
       rcfile<<":";
	   temprand=(float)(rand()/32767.);
	   if(temprand<1/2.)
	    rcfile<<"0";
	   else
	    rcfile<<"1";
       rcfile<<" "<<strength<<endl;	   
   }
   rcfile<<"n"<<endl;
}

void freeall()    /* 釋放內存空間 */
{
int j;
free(pop->classifier);
for(j=0;j<=pop->nclassifier-1;j++)
  free(pop->classifier[j].c);
free(matchl->clist);
free(envmessage); 
free(environrec.signal);
free(garec.mating);
   }

void main()  /*  主程序 */
{
/* generatecfile();*/
initialization();
detectors(&environrec,envmessage);
report();
do {
    timekeeper(&timekeeprec);
    environment(&environrec);
    detectors(&environrec,envmessage);
	matchl->nactive=0;
	matchclassifiers(pop,envmessage,matchl);
	aoc(pop,matchl,&clearingrec);
    environrec.classifieroutput=pop->classifier[clearingrec.winner].a;
    reinforcement(&reinforcementrec,pop,&clearingrec,&environrec);
    if(timekeeprec.reportflag)   report();
    if(timekeeprec.consolereportflag)   consolereport(&reinforcementrec);
    if(timekeeprec.plotreportflag)   plotreport(&reinforcementrec);
    advance(&clearingrec);
    if(timekeeprec.gaflag)
     {
     ga(&garec,pop);
     if(timekeeprec.reportflag)   reportga(&garec,pop);
     }
   }while(halt()==0);
   report();
   freeall();
 }


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩电影在线| 国产精品色噜噜| 成人免费va视频| 另类中文字幕网| 亚洲高清在线视频| 亚洲精品国久久99热| 日本一区二区三区dvd视频在线| 91精品国产91久久久久久最新毛片 | 久久影视一区二区| 日韩欧美另类在线| 欧美一区日本一区韩国一区| 欧美亚洲综合久久| 在线欧美日韩精品| 欧美特级限制片免费在线观看| 色综合天天做天天爱| 91丨九色丨尤物| 欧美亚洲自拍偷拍| 欧美电影一区二区| 欧美一区二区三区公司| 欧美成人免费网站| 国产欧美日韩亚州综合| 欧美国产欧美综合| 亚洲人成电影网站色mp4| 中文字幕亚洲精品在线观看| 亚洲欧美在线另类| 一级中文字幕一区二区| 一区二区成人在线| 日韩va欧美va亚洲va久久| 中文字幕在线不卡一区二区三区| 美国三级日本三级久久99| 亚洲成人一区二区在线观看| 亚洲一级片在线观看| 天堂久久一区二区三区| 看片网站欧美日韩| 成人午夜又粗又硬又大| 色香蕉成人二区免费| 欧美三级电影网| 日韩欧美色综合| 国产欧美日韩激情| 亚洲国产wwwccc36天堂| 激情综合五月婷婷| 91在线精品秘密一区二区| 97aⅴ精品视频一二三区| 欧美日韩在线三区| 久久久精品国产免大香伊| 一本大道综合伊人精品热热| 欧美一区二区免费视频| 久久尤物电影视频在线观看| √…a在线天堂一区| 午夜成人免费电影| 成人午夜看片网址| 91超碰这里只有精品国产| 久久久亚洲精华液精华液精华液 | 亚洲国产精品激情在线观看| 亚洲精品视频在线观看网站| 琪琪久久久久日韩精品| 成人性生交大片免费| 欧美巨大另类极品videosbest | 在线精品视频小说1| 日韩欧美美女一区二区三区| 亚洲欧美日韩精品久久久久| 麻豆精品视频在线| 欧美熟乱第一页| 久久精品欧美日韩精品| 日日欢夜夜爽一区| 高潮精品一区videoshd| 欧美精品少妇一区二区三区| 国产日韩欧美不卡| 免费观看在线综合色| 成人精品电影在线观看| 日韩精品一区二区在线| 一区二区三区 在线观看视频| 国产一区二区三区久久久| 欧美另类一区二区三区| 伊人色综合久久天天人手人婷| 久久er99精品| 91精品国产色综合久久久蜜香臀| 自拍av一区二区三区| 久久爱www久久做| 欧美精品高清视频| 亚洲综合av网| av一二三不卡影片| 国产欧美日本一区二区三区| 精品一区在线看| 日韩一区二区三区免费看| 亚洲v日本v欧美v久久精品| 日本高清视频一区二区| 亚洲欧美经典视频| 色综合久久中文综合久久牛| 国产精品国产馆在线真实露脸| 国产精品888| 国产午夜精品一区二区三区视频| 久久国产夜色精品鲁鲁99| 欧美一区二区三级| 日本亚洲三级在线| 欧美成人在线直播| 九九精品一区二区| 国产亚洲欧美在线| 成人av电影在线网| 日韩毛片高清在线播放| 91久久精品一区二区| 亚洲激情网站免费观看| 欧美性猛片xxxx免费看久爱| 亚洲资源在线观看| 3d动漫精品啪啪1区2区免费| 视频一区在线播放| 精品91自产拍在线观看一区| 国产精品亚洲午夜一区二区三区 | 337p日本欧洲亚洲大胆色噜噜| 蜜桃精品视频在线| 亚洲精品在线免费观看视频| 毛片av一区二区| 日本一区免费视频| 色综合视频在线观看| 亚洲午夜久久久久久久久电影院| 欧美三片在线视频观看| 免费高清在线视频一区·| xnxx国产精品| 91视频国产资源| 日本欧美在线观看| 国产欧美日韩卡一| 欧美三级韩国三级日本一级| 老司机精品视频在线| 日本一区二区三区视频视频| 91麻豆国产福利在线观看| 欧美aaaaaa午夜精品| 亚洲国产精品黑人久久久| 欧美午夜精品理论片a级按摩| 日韩av在线发布| 国产精品传媒在线| 91精品国产aⅴ一区二区| 国产成人亚洲综合a∨猫咪| 亚洲欧美日本韩国| 精品国产一区二区三区不卡| 色综合婷婷久久| 韩国v欧美v日本v亚洲v| 亚洲在线视频一区| 国产免费成人在线视频| 6080亚洲精品一区二区| av在线不卡免费看| 久久91精品久久久久久秒播| 亚洲视频在线一区| 久久影视一区二区| 欧美日韩欧美一区二区| 不卡av免费在线观看| 美国毛片一区二区| 亚洲国产日韩在线一区模特| 国产欧美一区二区在线| 91麻豆精品国产91久久久| 色综合久久中文字幕综合网| 韩国精品一区二区| 日韩国产在线一| 一区二区三区在线视频免费 | 91蝌蚪porny九色| 国产综合久久久久久鬼色| 亚洲午夜国产一区99re久久| 亚洲国产精品国自产拍av| 日韩午夜在线影院| 欧美日韩国产在线观看| 91色乱码一区二区三区| eeuss鲁片一区二区三区| 国产中文一区二区三区| 免费日韩伦理电影| 日韩不卡在线观看日韩不卡视频| 一区二区三区日韩欧美精品| 国产精品色在线观看| 2019国产精品| 精品久久久三级丝袜| 日韩三级视频在线看| 91精品国产福利在线观看| 欧美日韩成人高清| 欧美疯狂性受xxxxx喷水图片| 在线视频观看一区| 日本道色综合久久| 色88888久久久久久影院野外| 99热精品国产| 99国产欧美久久久精品| 91在线码无精品| 色婷婷综合激情| 色网站国产精品| 在线精品观看国产| 欧美系列一区二区| 欧美精品第1页| 欧美成人综合网站| 国产日韩综合av| 国产精品第13页| 一区二区三区四区亚洲| 亚洲综合色视频| 日本成人超碰在线观看| 精品一区二区三区在线播放视频| 国产自产v一区二区三区c| 国产成人精品免费视频网站| 成人黄色电影在线| 在线观看欧美日本| 91精品国模一区二区三区| 日韩三级视频在线观看| 国产日韩欧美综合在线| 亚洲男女毛片无遮挡| 亚瑟在线精品视频| 韩国女主播成人在线|