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

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

?? scs.cpp

?? 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一区二区三区免费野_久草精品视频
欧美一区二区精美| 欧美美女bb生活片| 国产一区二区三区四区在线观看| 亚洲国产你懂的| 亚洲一区二区三区视频在线 | 天天影视网天天综合色在线播放| 亚洲欧洲美洲综合色网| 中文字幕一区二区三区精华液| 国产精品视频观看| 国产精品第一页第二页第三页| 亚洲欧洲成人自拍| 亚洲午夜久久久久久久久电影院 | 美日韩一区二区| 国产一区在线精品| 国产精品1024| 色欧美片视频在线观看 | 激情国产一区二区| 国产福利精品一区二区| 99久久精品免费| 欧美人妖巨大在线| 欧美白人最猛性xxxxx69交| 久久亚洲免费视频| 中文字幕中文字幕一区| 亚洲三级久久久| 日韩高清一区在线| 国产999精品久久久久久绿帽| 成人永久免费视频| 欧美日韩亚洲综合在线| 欧美va亚洲va| 综合电影一区二区三区 | 国产成人亚洲精品狼色在线| 色综合视频在线观看| 欧美日韩你懂得| 欧美韩国日本不卡| 亚洲成人高清在线| 国产成人精品午夜视频免费| 欧美专区在线观看一区| 久久免费的精品国产v∧| 中文字幕一区在线观看视频| 日韩精品91亚洲二区在线观看| 国产一区二区三区在线看麻豆| eeuss鲁片一区二区三区在线观看| 欧美在线观看一区二区| 欧美国产综合一区二区| 日韩中文字幕av电影| 成人毛片视频在线观看| 日韩欧美视频在线 | 欧美美女一区二区三区| 国产精品乱码一区二区三区软件 | 亚洲在线免费播放| 国产丶欧美丶日本不卡视频| 精品视频免费看| 亚洲欧美日韩在线| 国产高清不卡一区| 欧美一区二区性放荡片| 一区二区三区精品久久久| 成人性生交大片免费看在线播放 | 亚洲伦理在线精品| 国产成人无遮挡在线视频| 91麻豆精品91久久久久同性| 日韩伦理免费电影| 国产成人免费视| 久久亚洲一区二区三区四区| 日韩电影在线免费| 欧美顶级少妇做爰| 亚洲图片欧美综合| 在线观看日韩精品| 亚洲一区二区三区自拍| 99久久国产免费看| ㊣最新国产の精品bt伙计久久| 国产伦精一区二区三区| 日韩精品一区二区三区在线播放| 天天综合天天做天天综合| 欧美亚州韩日在线看免费版国语版 | 一本色道久久综合狠狠躁的推荐| 国产亚洲精品aa| 福利91精品一区二区三区| 欧美精品一区二区三区高清aⅴ| 日韩电影在线看| 日韩一级完整毛片| 狠狠色狠狠色综合系列| 国产亚洲成年网址在线观看| 国产精品自拍一区| 国产精品久久久久久久第一福利| 成人福利视频网站| 亚洲色图视频免费播放| 欧美色大人视频| 久久国产夜色精品鲁鲁99| 久久欧美一区二区| av亚洲产国偷v产偷v自拍| 亚洲一区二区中文在线| 在线不卡一区二区| 国产一区二区在线观看视频| 久久精品日韩一区二区三区| 99久久综合国产精品| 亚洲午夜一二三区视频| 在线电影一区二区三区| 国产一区在线观看视频| 国产精品传媒在线| 欧美日韩性生活| 国产在线麻豆精品观看| 国产精品国产三级国产aⅴ原创| 97久久超碰国产精品| 丝袜诱惑制服诱惑色一区在线观看 | 久久视频一区二区| 91首页免费视频| 蜜桃视频一区二区| 国产精品视频看| 91精品国产综合久久福利| 成人在线视频首页| 亚洲国产综合人成综合网站| 久久亚洲综合色一区二区三区| 色婷婷亚洲婷婷| 精品一区二区在线播放| 亚洲乱码国产乱码精品精98午夜| 欧美一区二区在线看| 91香蕉视频mp4| 麻豆国产精品官网| 亚洲综合在线免费观看| 久久中文字幕电影| 欧美一区午夜视频在线观看| 国产91丝袜在线播放0| 日韩精品一区第一页| 国产精品毛片高清在线完整版| 欧美日本精品一区二区三区| 国产91精品欧美| 麻豆精品国产91久久久久久| 亚洲自拍偷拍av| 国产精品污www在线观看| 日韩欧美国产一二三区| 在线免费观看日本一区| 粉嫩av一区二区三区| 麻豆精品视频在线观看视频| 一区二区三区在线视频免费| 中文字幕精品一区二区精品绿巨人| 在线成人免费观看| 欧美日韩国产一二三| 一本高清dvd不卡在线观看| 国产成人在线视频免费播放| 日韩和欧美一区二区三区| 亚洲精品视频在线看| 国产精品初高中害羞小美女文| 国产欧美日韩另类视频免费观看| 精品久久久久久久久久久久久久久久久| 91久久精品日日躁夜夜躁欧美| av亚洲精华国产精华| a级高清视频欧美日韩| 国产精品一二二区| 国产99精品在线观看| 国产综合色视频| 韩国精品免费视频| 国产在线观看一区二区 | 欧美经典三级视频一区二区三区| 欧美成人福利视频| 久久久亚洲国产美女国产盗摄| 精品人在线二区三区| 精品乱码亚洲一区二区不卡| 日韩美女视频在线| 久久亚洲影视婷婷| 国产网红主播福利一区二区| 国产日韩欧美亚洲| 中文字幕一区二区在线播放| 亚洲日本一区二区三区| 亚洲综合色区另类av| 日本午夜一区二区| 精彩视频一区二区| 成人精品电影在线观看| 91在线视频在线| 欧美日韩国产综合草草| 欧美一级二级在线观看| 久久久久久免费毛片精品| 国产精品色在线观看| 亚洲欧美日韩国产中文在线| 丝瓜av网站精品一区二区| 精品午夜久久福利影院| 99久久777色| 欧美一级xxx| 国产精品伦理在线| 亚洲一区二区3| 久久91精品国产91久久小草| 国产成人在线免费观看| 在线观看三级视频欧美| 日韩欧美一二区| 亚洲欧美日韩成人高清在线一区| 天天av天天翘天天综合网| 国产一区二区三区观看| 91亚洲精品乱码久久久久久蜜桃| 欧美喷潮久久久xxxxx| 久久先锋影音av| 亚洲综合区在线| 国产乱子伦一区二区三区国色天香| 91在线一区二区| 久久综合久色欧美综合狠狠| 亚洲精品免费电影| 国产九色sp调教91| 欧美日韩激情一区| 国产精品天天摸av网| 日本sm残虐另类| 色婷婷综合久久久久中文一区二区| 日韩视频免费观看高清完整版在线观看|