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

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

?? population.cpp

?? 遺傳算法(Genetic Algorithm)是一類借鑒生物界的進化規律(適者生存
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/***************************************************************/* Single & Multi-Objective Real-Coded Genetic Algorithms Code *//* Author: Kumara Sastry                                       *//* Illinois Genetic Algorithms Laboratory (IlliGAL)            *//* Deparment of General Engineering                            *//* University of Illinois at Urbana-Champaign                  *//* 104 S. Mathews Ave, Urbana, IL 61801                        *//***************************************************************/#include "population.hpp"Population::Population() {  // Things to be done:  // Initialization of member variables:  //    1. Guys, newGuys -> Depending upon the type of GA  //    2. mpool -> new int[popSize]  //    3. bestInd -> new Individual  //    4. selection = new kindOfSelection(this);  //    5. crossover = new kindOfCrossover();  // If (TypeOfGA == SGA)  //    1. Initialize all statistics to new double;  int ii;  guys = new Individual*[globalSetup->populationSize];  newGuys = new Individual*[globalSetup->populationSize];  if (globalSetup->gaType==SGA) {    bestInd = new Individual;    freezeMask = new int[globalSetup->noOfDecisionVariables];    for(ii = 0; ii < globalSetup->noOfDecisionVariables; ii++)      freezeMask[ii] = OFF;    for (ii=0; ii<globalSetup->populationSize; ii++) {      guys[ii] = new Individual;      newGuys[ii] = new Individual(guys[ii]);    }  }  else {    bestInd = new NsgaIndividual;    for (ii=0; ii<globalSetup->populationSize; ii++) {      guys[ii] = new NsgaIndividual;      newGuys[ii] = new NsgaIndividual(guys[ii]);    }  }  mpool = new int[globalSetup->populationSize];  switch (globalSetup->selectionType) {  case TournamentWOR: selection = new TournamentSelection(*((int *)globalSetup->selectionParameters), this);    break;  case SUS: selection = new StochasticUniversalSelection(this);    break;  case Truncation:  	selection = new TruncationSelection(*((int *)globalSetup->selectionParameters), this);    break;  case TournamentWR:    selection = new TournamentSelectionWithReplacement(*((int *)globalSetup->selectionParameters), this);    break;  case RouletteWheel:    selection = new RouletteWheelSelection(this);    break;  default: exit(0);  }  switch (globalSetup->xOverType) {  case OnePoint: crossover = new OneTwoPointCrossover(1);    break;  case TwoPoint: crossover = new OneTwoPointCrossover(2);    break;  case Uniform:    if (globalSetup->xOverParameters==NULL)      crossover = new UniformCrossover();    else      crossover = new UniformCrossover(((double *)globalSetup->xOverParameters)[0]);    break;  case SBX:    if (globalSetup->xOverParameters==NULL)      crossover = new SimulatedBinaryCrossover();    else      crossover = new SimulatedBinaryCrossover(((double *)globalSetup->xOverParameters)[0]);    break;  default: exit(0);  }  if(globalSetup->loadPopulation) {    loadPopulationFromFile();  }  // Initialization of the other stuff  if (globalSetup->gaType==SGA) {    bestobj = new double;    worstobj = new double;    avgobj = new double;    maxfit = new double;    minfit = new double;    avgfit = new double;    varfit = new double;    bestFitChange = new double;    avgFitChange = new double;    fitVarChange = new double;    bestObjChange = new double;    avgObjChange = new double;    switch (globalSetup->localSearchMethod) {    case NoLocalSearch: break;    case SimplexSearch:      localSearch = new Simplex;      break;      //    case Complex: localSearch = new Complex();      //      break;      //    case MOM: localSearch = new methodOfMultipliers();      //      break;    default: exit(0);    }    computeObjStatistics();    mapObjectiveToFitness();    computeFitnessStatistics();    if((globalSetup->selectionType == SUS)||       (globalSetup->selectionType == RouletteWheel)||       (globalSetup->nichingType == Sharing)) {      scaleFitness();      if(globalSetup->nichingType == Sharing) shareFitness();      computeFitnessStatistics();    }    replacePopulation();    computeObjStatistics();    mapObjectiveToFitness();    computeFitnessStatistics();  }}std::ostream &operator<< (std::ostream &out, const Population &pop ){  int ii, jj;  if (globalSetup->gaType==SGA) {    if(globalSetup->nichingType == NoNiching) {      out << "Best Objective - "<<*(pop.bestobj)<< std::endl <<"Worst Objective - "<<*(pop.worstobj)<< std::endl<<"Average Objective - "<< *(pop.avgobj)<< std::endl;      out << "Maximum Fitness - "<<*(pop.maxfit)<<std::endl<<"Average Fitness - "<<*(pop.avgfit)<<std::endl;      out <<"The best individual"<<std::endl<<*(pop.bestInd)<<std::endl;    }    else {      out << "% ";      for(jj = 0; jj < globalSetup->noOfDecisionVariables; jj++)	out << "var #" << jj << "\t";      out << std::endl;      for(ii = 0; ii < globalSetup->populationSize; ii++) {	for(jj = 0; jj < globalSetup->noOfDecisionVariables; jj++)	  out << (*pop[ii])[jj] << "\t";	out << pop[ii]->getFitness() << std::endl;      }    }  }  else {    out << "% ";    for(jj = 0; jj < globalSetup->finalNoOfObjectives; jj++)      out << "obj #" << jj << "\t";    out << std::endl;    for(ii = 0; ii < globalSetup->populationSize; ii++) {      for(jj = 0; jj < globalSetup->finalNoOfObjectives; jj++)	out << ((NsgaIndividual *)(pop[ii]))->getObjective(jj) << "\t";      out << std::endl;    }  }  return out;}Population::~Population(){  int ii;  for(ii = 0; ii < globalSetup->populationSize; ii++){    delete guys[ii];    delete newGuys[ii];  }  delete [] guys;  delete [] newGuys;  delete bestInd;  delete []mpool;  delete selection;  delete crossover;  if (globalSetup->gaType == SGA) {    delete []freezeMask;    delete bestobj;    delete worstobj;    delete avgobj;    delete maxfit;    delete minfit;    delete avgfit;    delete varfit;    delete bestFitChange;    delete avgFitChange;    delete fitVarChange;    delete bestObjChange;    delete avgObjChange;  }}/*============================================================** Function Name: Population::doRTS()** Function Task: This method performs Restricted Tournament Selection**                For each new individual, random select W individuals and find the individual which closest to the new individual based on phenotypic distance. If the closest individual is better than the new individual, replace the new individual with the closest individual.** Reference: Harik, G. (1994). "Finding Multiple Solutions In Problems of Bounded Difficulty", Illigal Report No. 94002. http://www-illigal.ge.uiuc.edu/techreps.php3. (ftp://ftp-illigal.ge.uiuc.edu/pub/papers/IlliGALs/94002.ps.Z).** Output: None** Functions Called:**========================================================== */void Population::doRTS(void){  int windowSize = ((int *)globalSetup->nichingParameters)[0];  int ii, jj, kk,closest, rndGuy;  double minDist, distance, maxDist;  Individual **tempGuys;  tempGuys = new Individual*[globalSetup->populationSize];  for(ii = 0; ii < globalSetup->populationSize; ii++)    tempGuys[ii] = new Individual(guys[ii]);  maxDist = 0;  for(ii = 0; ii < globalSetup->noOfDecisionVariables; ii++)    maxDist += ((globalSetup->variableRanges[ii][1] - globalSetup->variableRanges[ii][0])*(globalSetup->variableRanges[ii][1] - globalSetup->variableRanges[ii][0]));    for(ii = 0; ii < globalSetup->populationSize; ii++) {    minDist = maxDist;    for(jj = 0; jj < windowSize; jj++) {      distance = 0.0;      rndGuy = myRandom.boundedIntegerRandom(0, globalSetup->populationSize);      for(kk = 0; kk < globalSetup->noOfDecisionVariables; kk++)	distance += ((*tempGuys[rndGuy])[kk]-(*newGuys[ii])[kk])*	  ((*tempGuys[rndGuy])[kk]-(*newGuys[ii])[kk]);      if(distance < minDist) {	closest = rndGuy;	minDist = distance;      }    }    if(isBetter(newGuys[ii],tempGuys[closest]))      *tempGuys[closest] = *newGuys[ii];  }  for(ii = 0; ii < globalSetup->populationSize; ii++) {    *(newGuys[ii]) = *(tempGuys[ii]);    delete tempGuys[ii];  }  delete []tempGuys;}/*============================================================** Function Name: Population::shareFitness()** Function Task: This method performs shared niching which consists** of the following steps. Calculate the number of individuals sharing** each niche using a phenotypic distance metric. An individual is** considered to be in the same niche as another if phenotypic distance** between is less than sigmaShare which is specified in th eglobal setup** as a parameter. shareAlpha is another parameter used for calculating** the sharing value which is used to update the niche count for each of** the individuals. The shared fitness of each individaul is calculate by** dividing is fitness by its niche count.** Output: None** Functions Called: Population::setFitness(double)** Reference: Goldberg, D.E. & Richardson, J. (1987). "Genetic Algorithms with Sharing for Multimodal Function Optimization", Genetic Algorithms and their Applications: Proceedings of the Second International Conference on Genetic Algorithms, 41-49. (TCGA No. 01170).**========================================================== */void Population::shareFitness(){  double sigmaShare = ((double *)globalSetup->nichingParameters)[0];  double shareAlpha = ((double *)globalSetup->nichingParameters)[1];  double *sharingValue;  int ii, jj, kk, ll, arraySize, transIndex;  double tempDist, nicheCount;  double phenoValue1, phenoValue2, sharedFitness;  arraySize = ((globalSetup->populationSize)*(globalSetup->populationSize-1))/2;  sharingValue = new double[arraySize];  ll = 0;  for(ii = 0; ii < globalSetup->populationSize-1; ii++) {    nicheCount = 1.0;    for(jj = ii + 1; jj < globalSetup->populationSize; jj++) {      tempDist = 0.0;      for(kk = 0; kk < globalSetup->noOfDecisionVariables; kk++) {	phenoValue1 = (*newGuys[ii])[kk];	phenoValue2 = (*newGuys[jj])[kk];	tempDist += ((phenoValue1-phenoValue2)*(phenoValue1-phenoValue2));      }      tempDist = sqrt(tempDist);      if(tempDist < sigmaShare)	sharingValue[ll] = 1.0 - pow((tempDist/(sigmaShare)), shareAlpha);      else	sharingValue[ll] = 0.0;      nicheCount += sharingValue[ll++];    }    for(jj = 0; jj < ii; jj++) {      transIndex = (globalSetup->populationSize)*jj + (ii-jj-1) - (jj*(jj+1)/2);      nicheCount += sharingValue[transIndex];    }    sharedFitness = (newGuys[ii]->getFitness())/nicheCount;    newGuys[ii]->setFitness(sharedFitness);  }  delete []sharingValue;}/*============================================================** Function Name: Population::freeze(int)** Function Task: Given a locus this method sets the freezemask** for the corresponding location on the chromosome.** It then calls Individual::freeze(int,) for each individual** to set value of the frozen gene in all individuals to the** value of the corresponding gene in the best individual.** This feature is diabled when Niching is on.** Output:None** Functions called: Individual::freeze(int,)**========================================================*/void Population::freeze(int locus){  int ii;  if((globalSetup->gaType == SGA)&&     (globalSetup->nichingType == NoNiching)&&     (freezeMask[locus] == OFF)) {    freezeMask[locus] = ON;    for(ii = 0; ii < globalSetup->populationSize; ii++) {      guys[ii]->freeze(locus, (*bestInd)[locus]);      newGuys[ii]->freeze(locus, (*bestInd)[locus]);    }  }}/*============================================================** Function Name: Population::flood(int)** Function Task: Given a locus this method sets the freezemask** of the corresponding location on the chromosome.** It then calls Individual::flood(int,) for each individual** to set value of the flooded genes to some random value.** This feature is diabled when Niching is on.** Output:None** Functions called: Individual::flood(int)**========================================================*/void Population::flood(int locus){  int ii;  freezeMask[locus]=OFF;  if((globalSetup->gaType == SGA)&&     (globalSetup->nichingType == NoNiching)) {    for(ii = 0; ii < globalSetup->populationSize; ii++) {      guys[ii]->flood(locus);      newGuys[ii]->flood(locus);    }  }}/*============================================================** Function Name: Population::computeObjStatistics(void)** Function Task: this method generates statistics according to** objective function values. It finds out the average objective** value for the population and the best and worst objective** values. This depends on whether the type of optimization in the**  problem is minimization or maximization.** Output:None** Functions called: Individual::getObjective()**========================================================*/void Population::computeObjStatistics(void){  int ii, bestGuy, worstGuy;  double oneOverPopulationSize;  double oldBestObj, oldAvgObj;  oneOverPopulationSize = 1.0/(1.0*(globalSetup->populationSize));  oldBestObj = *bestobj;  oldAvgObj = *avgobj;  bestGuy = worstGuy = 0;  *avgobj = oneOverPopulationSize*(newGuys[0]->getObjective());  for(ii = 1; ii < globalSetup->populationSize; ii++) {    *avgobj += oneOverPopulationSize*(newGuys[ii]->getObjective());    if(isBetter(newGuys[ii], newGuys[bestGuy])) bestGuy = ii;    if(isBetter(newGuys[worstGuy], newGuys[ii])) worstGuy = ii;  }  *bestobj = newGuys[bestGuy]->getObjective();  *worstobj = newGuys[worstGuy]->getObjective();  *bestObjChange = fabs(oldBestObj - *bestobj);  *avgObjChange = fabs(oldAvgObj - *avgobj);}/*============================================================** Function Name: Population::computeFitnessStatistics(void)** Function Task: this method generates statistics according to** fitness function values. It finds out the average fitness** value for the population and the maximum and minimum fitness** values as well as the fitness variance.** Output:None** Functions called: Individual::getFitness()**========================================================*/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
26uuu久久综合| 欧美精品成人一区二区三区四区| 亚洲大片免费看| 亚洲一区二区三区四区在线免费观看 | 一区二区在线观看免费视频播放| 国产欧美一区二区精品性色| 精品国产免费一区二区三区香蕉 | 亚洲最大成人综合| 夜夜嗨av一区二区三区网页 | 中文在线资源观看网站视频免费不卡| 日韩免费一区二区三区在线播放| 91精品国产aⅴ一区二区| 欧美精品777| 欧美成人一区二区三区| 欧美精品一区二区在线播放| 2023国产精品| 亚洲欧洲日韩在线| 婷婷国产在线综合| 国产一区二区三区久久悠悠色av | 91天堂素人约啪| 欧美日韩一区二区在线观看视频 | 成人看片黄a免费看在线| 成人综合婷婷国产精品久久| 91热门视频在线观看| 欧美日韩色一区| 精品国产免费人成电影在线观看四季| 国产夜色精品一区二区av| 1000部国产精品成人观看| 调教+趴+乳夹+国产+精品| 国产精品资源在线观看| 92国产精品观看| 欧美一级高清大全免费观看| 国产无遮挡一区二区三区毛片日本| 国产精品免费网站在线观看| 亚洲mv在线观看| 国产成人综合精品三级| 91久久香蕉国产日韩欧美9色| 欧美精品日韩精品| 国产精品热久久久久夜色精品三区| 一区二区三区四区激情| 国产盗摄女厕一区二区三区| 91在线码无精品| 亚洲精品一区二区三区99| 一区二区三区中文在线| 九一久久久久久| 欧美影视一区在线| 精品99一区二区三区| 亚洲资源中文字幕| 成人毛片视频在线观看| 日韩欧美国产一区在线观看| 亚洲黄色小说网站| 国产成人综合视频| 日韩精品一区二区三区三区免费| 亚洲欧美日韩综合aⅴ视频| 国内精品国产三级国产a久久| 在线观看一区日韩| 亚洲欧洲日本在线| 精品一区二区三区香蕉蜜桃| 欧美日韩一区国产| 亚洲综合在线观看视频| 成人久久视频在线观看| 国产婷婷色一区二区三区在线| 天天操天天干天天综合网| 91极品视觉盛宴| 中文字幕一区二区三区乱码在线 | 国产日产精品1区| 激情小说欧美图片| 欧美va亚洲va| 久久精品国产一区二区| 欧美精品三级在线观看| 亚洲第一成人在线| 欧美日韩综合一区| 午夜激情久久久| 欧美日韩三级视频| 日本三级韩国三级欧美三级| 欧美日韩精品欧美日韩精品一综合| 一区二区在线观看视频在线观看| 色综合中文字幕国产| 国产精品无人区| 成人av网站在线| 国产精品福利电影一区二区三区四区| 国产精品白丝av| 中文字幕欧美激情一区| 北条麻妃一区二区三区| 视频在线观看91| 欧美午夜精品久久久久久孕妇| 一区二区欧美视频| 在线播放一区二区三区| 天天色图综合网| 日韩欧美在线1卡| 国产精品18久久久久久久久久久久| 久久久久久久久久电影| 成人国产免费视频| 亚洲午夜电影网| 日韩视频免费观看高清完整版在线观看| 欧美a级一区二区| 久久久精品国产免大香伊| av不卡免费电影| 香蕉成人伊视频在线观看| 在线电影欧美成精品| 国产精一区二区三区| 亚洲美女区一区| 日韩一区二区精品在线观看| 国产乱理伦片在线观看夜一区| 国产精品久久久久久久久免费相片| 99riav久久精品riav| 亚洲成人久久影院| 国产人久久人人人人爽| 色国产精品一区在线观看| 蜜桃视频在线观看一区| 国产精品视频在线看| 欧美日韩久久一区| 国产成人精品免费| 性做久久久久久久久| 久久精品亚洲国产奇米99| 91视频国产观看| 激情综合一区二区三区| 亚洲人成网站影音先锋播放| 日韩欧美久久久| 色哟哟国产精品免费观看| 韩国精品免费视频| 亚洲综合一区二区三区| 久久精品日产第一区二区三区高清版| 欧美亚洲综合一区| 东方欧美亚洲色图在线| 日韩av电影天堂| 一区二区在线免费| 欧美激情一区二区三区全黄| 久久久精品一品道一区| 欧美色图激情小说| 成人ar影院免费观看视频| 久久国产精品99久久人人澡| 一区2区3区在线看| 中文字幕一区二区不卡| 久久久三级国产网站| 欧美一区二区三区喷汁尤物| 91黄色免费网站| 91在线视频免费观看| 国产成人精品一区二区三区四区 | 激情六月婷婷久久| 天堂成人国产精品一区| 亚洲欧美日韩一区二区三区在线观看| 久久综合九色综合欧美就去吻| 欧美日韩不卡一区二区| 91黄色免费观看| 99视频在线观看一区三区| 成人三级伦理片| 国产福利91精品| 国产激情一区二区三区桃花岛亚洲| 蓝色福利精品导航| 六月丁香婷婷久久| 国产制服丝袜一区| 国产麻豆视频一区二区| 国产精品亚洲а∨天堂免在线| 久久99久国产精品黄毛片色诱| 日本aⅴ精品一区二区三区| 日韩在线卡一卡二| 日韩高清一区二区| 免费成人结看片| 狠狠色综合播放一区二区| 久久99国产精品免费网站| 精彩视频一区二区| 国产成人99久久亚洲综合精品| 国产电影一区在线| 成人激情av网| 91福利区一区二区三区| 欧美日韩aaaaaa| 日韩三级电影网址| 欧美国产精品劲爆| 亚洲色图欧洲色图| 精品一区二区三区在线观看| 国产在线播精品第三| 丁香婷婷综合色啪| 91美女精品福利| 欧美日韩和欧美的一区二区| 欧美一区日本一区韩国一区| 精品嫩草影院久久| 国产精品青草综合久久久久99| 亚洲欧美另类图片小说| 五月激情丁香一区二区三区| 国内久久精品视频| 99久久综合色| 欧美一区三区四区| 国产精品九色蝌蚪自拍| 爽爽淫人综合网网站| 国产一区视频导航| 在线亚洲人成电影网站色www| 欧美高清视频一二三区| 欧美韩国日本综合| 午夜精品成人在线| 国产成人午夜精品影院观看视频 | 久久久国产午夜精品| 亚洲精品视频一区二区| 午夜精品久久久久影视| 国产精品888| 欧美精品tushy高清| 国产精品久线在线观看| 奇米色777欧美一区二区| 不卡视频在线观看| 日韩精品专区在线影院观看|