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

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

?? scs.cpp

?? 遺傳算法GA的源代碼及例子
?? 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一区二区三区免费野_久草精品视频
免费一级片91| www日韩大片| 日韩av不卡一区二区| 久久综合久久综合亚洲| 91麻豆精品久久久久蜜臀| 欧美日韩亚州综合| 欧美精品久久天天躁| 日韩限制级电影在线观看| 日韩欧美国产午夜精品| 99re视频精品| 精品亚洲国产成人av制服丝袜| 久久精品国产99| 亚洲在线成人精品| 偷窥少妇高潮呻吟av久久免费| 国产精品99久久久久久久女警| 国产精品一区二区三区四区| 一区二区三区色| 日韩激情在线观看| 一区二区激情视频| 日韩经典中文字幕一区| 国产在线麻豆精品观看| 99视频精品免费视频| 国产精品原创巨作av| 日韩精品一级中文字幕精品视频免费观看| 国产日产精品1区| 欧美乱妇一区二区三区不卡视频| 91在线观看高清| 成人av网址在线观看| 韩国女主播成人在线观看| 日韩黄色在线观看| 午夜电影网亚洲视频| 亚洲精品久久久久久国产精华液| 国产精品美女久久久久av爽李琼| 亚洲一区在线观看免费观看电影高清| 亚洲欧美综合在线精品| 日韩专区一卡二卡| 成人午夜碰碰视频| 在线综合视频播放| 亚洲免费观看高清完整版在线观看熊 | 国产suv精品一区二区883| av一本久道久久综合久久鬼色| 欧美日韩国产免费一区二区| 国产清纯在线一区二区www| 精品久久五月天| 一区二区三区四区在线| 国产精品一二一区| 国产.精品.日韩.另类.中文.在线.播放| 精品一区二区国语对白| 在线观看亚洲a| 国产喷白浆一区二区三区| 日本一区二区三区免费乱视频| 午夜成人在线视频| 日韩1区2区日韩1区2区| 另类中文字幕网| 欧美制服丝袜第一页| 国产精品美女久久久久久2018| 久久国产成人午夜av影院| 欧美日韩午夜在线| 亚洲精品一二三区| 91小视频免费观看| 亚洲国产精品高清| 国产精品77777竹菊影视小说| 日韩一区和二区| 久久久蜜桃精品| 中文字幕在线不卡一区| 国产主播一区二区| 2020国产精品自拍| 综合久久久久久久| 成人av综合在线| 亚洲国产精品传媒在线观看| 亚洲欧美另类久久久精品2019| 一区二区三区精品| 在线观看日韩一区| 亚洲欧美国产三级| 91久久精品国产91性色tv| 国产精品久久久久久久久免费丝袜 | 久久亚洲精品国产精品紫薇| 日韩不卡手机在线v区| 欧美日本韩国一区| 久久久久久综合| 国产一区二区三区电影在线观看 | 国产精品午夜久久| 亚洲国产色一区| 欧美日韩激情一区二区| 国产人成一区二区三区影院| 国产精品乡下勾搭老头1| 欧美日精品一区视频| 亚洲一区二区精品久久av| 欧美日韩不卡一区| 国产在线国偷精品产拍免费yy| 久久亚区不卡日本| 一本大道久久a久久精二百| 亚洲国产精品尤物yw在线观看| 9191精品国产综合久久久久久| 麻豆精品在线看| 国产精品伦理在线| 欧美日韩在线免费视频| 亚洲欧洲综合另类| 欧美日韩视频在线观看一区二区三区 | 极品少妇xxxx精品少妇偷拍 | 亚洲欧美日韩一区| 国产乱国产乱300精品| 欧美区视频在线观看| 极品美女销魂一区二区三区| 国产精品免费久久久久| 国产一区二区三区久久悠悠色av| 欧美色综合网站| 亚洲码国产岛国毛片在线| 337p亚洲精品色噜噜噜| 福利一区在线观看| 天堂一区二区在线| 欧美激情一区三区| 国产成人在线观看免费网站| 精品欧美乱码久久久久久 | 欧美高清精品3d| 成人综合日日夜夜| 日本少妇一区二区| 在线播放视频一区| 日韩黄色免费网站| 亚洲日韩欧美一区二区在线| 91原创在线视频| 玉米视频成人免费看| 91国产免费看| 日韩专区一卡二卡| 日韩一级二级三级精品视频| 99re免费视频精品全部| 亚洲人成小说网站色在线| 色综合久久久久久久久久久| 国产一区二区在线视频| 午夜成人免费视频| 亚洲一区在线视频观看| 欧美精品在欧美一区二区少妇| 日本最新不卡在线| 亚洲在线视频免费观看| 欧美一级夜夜爽| 欧美色倩网站大全免费| 97se亚洲国产综合自在线| 亚洲国产日日夜夜| 一区二区三区 在线观看视频| 国产精品天天看| 欧美亚洲禁片免费| 欧美aaaaaa午夜精品| 亚洲高清不卡在线观看| 精品国产污网站| 欧美一级黄色大片| 成人av在线资源网站| 国产美女一区二区三区| 亚洲女人的天堂| 亚洲女人****多毛耸耸8| 日韩一级片在线观看| 欧美一三区三区四区免费在线看| 欧美三级电影网| 国产一区二区视频在线| 国产在线不卡一区| 国产成人av网站| 午夜成人免费视频| 亚洲天堂福利av| 欧美草草影院在线视频| 一本色道久久综合狠狠躁的推荐| 97久久超碰精品国产| 91免费视频网| 欧美日本一区二区三区四区| 国产高清精品久久久久| 粉嫩aⅴ一区二区三区四区五区| 国产成人精品1024| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | 亚洲欧美另类久久久精品2019| 亚洲黄色录像片| 国产婷婷色一区二区三区| 国产女主播视频一区二区| 亚洲色图欧洲色图婷婷| 亚洲v精品v日韩v欧美v专区| 久久精品国产一区二区三区免费看| 中文字幕一区二区不卡| 一区二区三区日韩欧美精品| 日本aⅴ亚洲精品中文乱码| 国产馆精品极品| 日本精品一区二区三区四区的功能| 国产成人av电影在线| 色婷婷综合视频在线观看| 欧美一区二区三区日韩| 亚洲成人免费视频| 美女在线一区二区| 精品亚洲成a人| 99精品国产99久久久久久白柏| 亚洲激情男女视频| 一区二区三区高清不卡| 麻豆精品一区二区三区| 男女男精品网站| 丰满亚洲少妇av| 成人黄色a**站在线观看| 日本精品一级二级| 日韩欧美高清一区| 另类的小说在线视频另类成人小视频在线 | a亚洲天堂av| 亚洲图片欧美激情| 蜜臀a∨国产成人精品| 成人91在线观看| √…a在线天堂一区| 色哟哟日韩精品|