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

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

?? scs.cpp

?? 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一区二区三区免费野_久草精品视频
国产又黄又大久久| 欧美三电影在线| 91视频免费播放| 欧美另类一区二区三区| 国产区在线观看成人精品| 亚洲欧美日韩国产中文在线| 国产精品一区二区久久不卡| 欧美日韩国产影片| 国产精品成人免费在线| 青椒成人免费视频| 精品视频在线免费| 亚洲老司机在线| 国产成人8x视频一区二区| 亚洲精品在线三区| 亚洲国产一区二区三区青草影视| 国产v综合v亚洲欧| 日韩欧美中文字幕制服| 午夜精品视频在线观看| 色国产综合视频| 亚洲国产高清不卡| 国产另类ts人妖一区二区| 日韩一卡二卡三卡四卡| 五月婷婷综合网| 欧美在线你懂的| 亚洲色图欧洲色图婷婷| 99re这里只有精品6| 国产欧美视频在线观看| 国内精品久久久久影院薰衣草| 欧美一区二区三区免费在线看 | 狠狠久久亚洲欧美| 欧美日韩亚州综合| 亚洲国产精品一区二区久久| 91麻豆文化传媒在线观看| 国产精品国产a级| 91麻豆swag| 一区二区三区av电影 | 欧美精品v国产精品v日韩精品 | 国产麻豆精品久久一二三| 91精品国产麻豆| 麻豆久久久久久| 2021久久国产精品不只是精品| 美国精品在线观看| 欧美精品一区二区三区在线播放| 国产乱子伦视频一区二区三区| 国产日本欧洲亚洲| 91麻豆高清视频| 亚洲国产cao| 日韩一区二区三区观看| 久久99深爱久久99精品| 国产网站一区二区三区| 国产91在线观看| 亚洲一区自拍偷拍| 精品少妇一区二区三区视频免付费| 激情文学综合网| 国产精品女上位| 日韩一级免费一区| 国产自产高清不卡| 中文字幕av资源一区| 色综合久久久网| 青青草国产精品亚洲专区无| 久久久久久久久久久电影| 99久久精品国产精品久久| 亚洲国产欧美在线| 久久婷婷色综合| 色偷偷88欧美精品久久久| 日本少妇一区二区| 国产精品麻豆久久久| 欧洲人成人精品| 国产精品亚洲第一区在线暖暖韩国| 亚洲女人小视频在线观看| 制服丝袜亚洲播放| 99久久精品久久久久久清纯| 日产欧产美韩系列久久99| 国产精品午夜电影| 欧美一卡在线观看| 99久久精品久久久久久清纯| 久久99久久精品| 亚洲成人自拍网| 国产欧美日韩综合| 日韩一区二区视频| 在线精品视频一区二区三四| 国产成人精品一区二区三区四区 | 日本一区二区免费在线观看视频 | 国产麻豆精品theporn| 亚洲国产欧美日韩另类综合| 国产亚洲精久久久久久| 91麻豆精品国产91久久久使用方法| 成人做爰69片免费看网站| 蜜臀av性久久久久av蜜臀妖精| 一区二区三区欧美日韩| 国产午夜精品一区二区三区四区| 91精品啪在线观看国产60岁| 日本韩国欧美三级| 成人av在线看| 国产一区二区三区香蕉| 日韩成人一级片| 亚洲一区影音先锋| 亚洲日本韩国一区| 中文字幕第一区二区| 久久久综合精品| 日韩欧美亚洲国产精品字幕久久久 | 国产精品美女久久久久久久久 | 欧美视频自拍偷拍| 91麻豆免费观看| 国产高清一区日本| 精品制服美女丁香| 久久精品国产网站| 天堂va蜜桃一区二区三区 | 欧美日韩高清不卡| 91女神在线视频| 成人av动漫在线| 成人av电影在线观看| 波多野结衣的一区二区三区| 国产成人一区二区精品非洲| 国产一区二区三区在线观看精品| 韩国理伦片一区二区三区在线播放 | 国产成人免费9x9x人网站视频| 精品一区二区三区影院在线午夜| 亚洲高清视频在线| 亚洲成人动漫在线免费观看| 亚洲一卡二卡三卡四卡无卡久久| 午夜欧美视频在线观看| 99久久免费国产| 国产精品一区二区久激情瑜伽| 免费观看成人av| 亚洲男人的天堂网| 亚洲国产视频一区| 欧美激情中文不卡| 欧美岛国在线观看| 中文字幕av不卡| 99re这里只有精品6| 韩国精品免费视频| 日本韩国精品一区二区在线观看| 欧美一区二区网站| 欧美一区国产二区| 日韩精品一区二区三区swag| 精品第一国产综合精品aⅴ| 久久女同精品一区二区| 中文字幕一区二区三区四区不卡| 亚洲日本欧美天堂| 日韩激情一区二区| 国产成人av福利| 在线亚洲高清视频| 精品日韩av一区二区| 国产精品婷婷午夜在线观看| 亚洲一区二区精品视频| 久久成人av少妇免费| 国产伦精品一区二区三区免费迷 | 日韩亚洲欧美一区| 久久久亚洲高清| 亚洲精品午夜久久久| 天天综合色天天| 东方欧美亚洲色图在线| 欧美理论片在线| 久久精品视频免费观看| 亚洲成人午夜影院| 大美女一区二区三区| 欧美电影一区二区| 国产精品天干天干在观线 | 亚洲一区二区三区四区不卡| 美女视频黄 久久| 一本色道久久综合亚洲aⅴ蜜桃| 欧美美女网站色| 国产精品视频在线看| 免费在线看成人av| 成人精品电影在线观看| 日韩欧美久久一区| 亚洲综合视频网| www.欧美日韩| 2021国产精品久久精品| 午夜不卡av在线| 日本高清视频一区二区| 国产午夜精品久久久久久久 | aaa亚洲精品一二三区| 日韩一级黄色片| 夜夜亚洲天天久久| 豆国产96在线|亚洲| 精品久久久影院| 美国十次了思思久久精品导航| 91久久精品网| 中文字幕一区二区三区色视频| 国产麻豆一精品一av一免费 | 韩国精品主播一区二区在线观看| 在线看不卡av| 亚洲欧美日韩一区| 成人av在线影院| 欧美激情一二三区| 国产九色sp调教91| 久久亚洲精精品中文字幕早川悠里| 日韩中文字幕区一区有砖一区| 欧美午夜电影网| 亚洲综合色网站| 欧美三级视频在线播放| 亚洲欧洲日产国码二区| 成人精品一区二区三区中文字幕 | 亚洲国产一二三| 欧美色偷偷大香| 亚洲v中文字幕| 4438x成人网最大色成网站| 午夜av电影一区|