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

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

?? selection.cpp

?? 遺傳算法程序最新版
?? CPP
字號:
/***************************************************************/* 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 "selection.hpp"// Constructor for the base selection class.// This has to be called explicitly from any// derived class constructor since the default// will be overriddenSelection::Selection (const Population *Pop) {  pop=Pop;}// Now for the derived class cosntructorsTournamentSelection::TournamentSelection (const int size, const Population *pop) :  Selection(pop) , tournamentSize(size){}TournamentSelectionWithReplacement::TournamentSelectionWithReplacement (const int size, const Population *pop) :  Selection(pop) , tournamentSize(size){}StochasticUniversalSelection::StochasticUniversalSelection (const Population *pop) :  Selection(pop){}RouletteWheelSelection::RouletteWheelSelection (const Population *pop) :  Selection(pop){}TruncationSelection::TruncationSelection(const int selP, const Population *pop) :  Selection(pop), selectionPressure(selP) {}/*** Tournament Selection Without Replacement: Randomly select S individuals without replacement and copy the best individual to the mating pool. Repeat this process till N individuals are selected. Implementation:    1. Shuffle the Individuals of the current population   2. Select S individuals without replacement   3. Copy the index of the best individual among those S individuals      to the mating pool   4. Go to step 2 till all the individuals are chosen   5. If the number of individuals in mating pool is less than N      then go to step 1.Note: Tournament selection without replacement should be preferred over tournament selection with replacement.*/void TournamentSelection::select(int *matingPool){                                         int ii, jj, kk, ll = 0;  int p1, p2, *randomArray, *winner;  randomArray = new int[globalSetup->populationSize];  winner = new int[globalSetup->populationSize];  for(ii = 0; ii < globalSetup->populationSize; ii++) randomArray[ii] = ii;  for(ii = 0; ii < tournamentSize; ii++) {    myRandom.shuffleArray(randomArray, globalSetup->populationSize);    for(jj = 0; jj < globalSetup->populationSize; jj += tournamentSize) {      p1 = randomArray[jj];      for(kk = 1; kk < tournamentSize; kk++) {	p2 = randomArray[jj+kk];	if(betterIndividual((*pop)[p1],(*pop)[p2])) winner[ll] = p1;	else winner[ll] = p2;	p1 = winner[ll];      }      ++ll;    }  }    for(ii = 0; ii < globalSetup->populationSize; ii++)     matingPool[ii] = winner[ii];  delete []randomArray;  delete []winner;}/*** Tournament Selection With Replacement: Randomly select S individuals with replacement and copy the best individual to the mating pool. Repeat this process till N individuals are selected. Implementation:    1. Shuffle the Individuals of the current population   2. Select S individuals with replacement   3. Copy the index of the best individual among those S individuals      to the mating pool   4. Go to step 1 till the mating pool has N individuals. Note: Tournament selection without replacement should be preferred over tournament selection with replacement.*/void TournamentSelectionWithReplacement::select(int *matingPool){                                         int ii, jj, p1, p2;  int *winner;  winner = new int[globalSetup->populationSize];    for(ii = 0; ii < globalSetup->populationSize; ii++) {    p1 = myRandom.boundedIntegerRandom(0,globalSetup->populationSize);    for(jj = 1; jj < tournamentSize; jj++) {      do{ p2 = myRandom.boundedIntegerRandom(0,globalSetup->populationSize); }while(p2 == p1);      if(betterIndividual((*pop)[p1],(*pop)[p2])) winner[ii] = p1;      else winner[ii] = p2;      p1 = winner[ii];    }  }  for(ii = 0; ii < globalSetup->populationSize; ii++) matingPool[ii] = winner[ii];  delete []winner;}/*** Truncation Selection: Sort the individuals in the population according to the fitness (or some performace criteria) and allocate S copies to the top N/S individuals.*/void TruncationSelection::select(int *matingPool){                                         int ii, jj, kk, *randomArray, *winner;    randomArray = new int[globalSetup->populationSize];  winner = new int[globalSetup->populationSize];  for(ii = 0; ii < globalSetup->populationSize; ii++) randomArray[ii] = ii;  selectionQuickSort(pop, randomArray, 0, globalSetup->populationSize);  for(ii = 0, kk = 0; kk < globalSetup->populationSize; ii++)     for(jj = 0; jj < selectionPressure; jj++)       winner[kk++] = randomArray[globalSetup->populationSize-1-ii];  for(ii = 0; ii < globalSetup->populationSize; ii++)  matingPool[ii] = winner[ii];    delete []randomArray;  delete []winner;}/*** Roulette Wheel Selection: Each individual is assigned a slice proportional to its fitness. The wheel is spun N times, where N is the number of individuals in the population. Note: Ordinal selection schemes like tournament or trunction selection schemes should always be preferred over roulette wheel selectionNote: Stochastic universal selection should be preferred over roulette wheel selection.Note: Roulette wheel selection should always be used with some scaling method.*/void RouletteWheelSelection::select(int *matingPool){  int ii, jj, *winner;  double rndNo, *sumFit;  winner = new int[globalSetup->populationSize];  sumFit = new double[globalSetup->populationSize];  sumFit[0] = pop->getFitness(0);  for(ii = 1; ii < globalSetup->populationSize; ii++)     sumFit[ii] = sumFit[ii-1] + pop->getFitness(ii);  for(ii = 0; ii < globalSetup->populationSize; ii++) {    rndNo = myRandom.boundedRandom(0,sumFit[globalSetup->populationSize-1]);    for(jj = 0; jj < globalSetup->populationSize; jj++) {      if(sumFit[jj] >= rndNo) { winner[ii] = jj; break; }    }  }  for(ii = 0; ii < globalSetup->populationSize; ii++)  matingPool[ii] = winner[ii];  delete []winner;  delete []sumFit;}/***Stochasting Universal Selection: It is a method for selecting a populationaccording to some given probability in a way that minimizes chance fluctuations associated with Roulette Wheel Selection. Instead of spinning the roulette wheel N times to select N parents, SUS spins the wheel once, with N equally spaced pointers, which are used to select N individuals.Under this method, each individual is guaranteed to reporduce at least floor(Expected number of copies of the individual) and at most ceil(Expected number of copies of the individual). SUS also has the advantage of being easier and quicker to implement that roulette wheel sampling. In practice it should always be preferred over roulette wheel selection. Note: This should almost always be used with some scaling method.Note: Currently this works only with SGA.Reference: Baker, J.E. (1985). "Adaptive Selection Methods for Genetic Algorithms", In Grefenstte, J. (Ed.), Proceedings of the International Conference on Genetic Algorithms and Their Applications (pp. 101-111). Hillsdale, NJ:Lawrence Erlbaum Associates (TCGA No. 00460). */void StochasticUniversalSelection::select(int *matingPool){  int ii, jj = 0, *winner;  double rndNo, sum, avgRank = 0.0;      winner = new int[globalSetup->populationSize];  rndNo = myRandom.random01();  for(sum = 0.0, ii = 0; ii < globalSetup->populationSize; ii++)     for(sum += (pop->getFitness(ii))/(pop->getAvgFit()); sum > rndNo; rndNo++)      winner[jj++] = ii;  for(ii = 0; ii < globalSetup->populationSize; ii++)    matingPool[ii] = winner[ii];    delete []winner;}/***Returns 1 if individual 1 is better than individual 2 depending onconstraint handling method and the GA type, else returns 0.Methods Invoked: constrTournComp(Individual*, Individual*, compareWhat)                 crowdingCom(NsgaIndvidual*, NsgaIndividual*);Details: If the GA type is SGA then             * If the constraint handling method is either penalty or if 	      there are no constraints then return 1 if individual 1               has higher fitness compared to individual 2, otherwise 	      return 0.	    * If the constraint handling method is tournament selection,	      then return 1 if the function compTournComp returns 1, else	      return 0.	 If the GA type is NSGA then, return 1 if crowdingComp returns 1, 	 otherwise return 0. */int Selection::betterIndividual(Individual *guy1, Individual *guy2) {  if(globalSetup->gaType == SGA) {    switch(globalSetup->constraintMethod) {      case NoConstraints: case Penalty:      if(guy1->getFitness() > guy2->getFitness()) return 1;      else return 0;      break;    case Tournament:      if(constrTournComp(guy1,guy2, FITNESS)) return 1;      else return 0;      break;    default: exit(0);    };  }  else if(globalSetup->gaType == NSGA) {    if(crowdingComp((NsgaIndividual*)guy1,(NsgaIndividual*)guy2)) return 1;    else return 0;  }
  return 0;}///This is a quick sort routine used for truncation selectionvoid Selection::selectionQuickSort(const Population *pop, int *output, 				   int left, int right){  int ii, xx;  Individual *target;    if(right > left) {    (target) = (*pop)[output[right-1]];    ii = left-1;    xx = right-1;    for(;;) {      while(!betterIndividual((*pop)[output[++ii]],target))	if(ii >= right-1) break;      if(ii >= xx) break;      while(betterIndividual((*pop)[output[--xx]],target))	if(xx <= 0) break;      if(ii >= xx) break;      swap(output[ii],output[xx]);    }    swap(output[ii],output[right-1]);    selectionQuickSort(pop, output, left, ii);    selectionQuickSort(pop, output, ii+1, right);  }}///This is a swap routine used by the quick sort subroutinevoid Selection::swap(int& ii, int& jj){  int temp;  temp = jj; jj = ii; ii = temp;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品久久一区二区三区| 亚洲日本欧美天堂| 中文文精品字幕一区二区| 亚洲免费在线视频一区 二区| 亚洲h在线观看| 成人美女在线视频| 欧美一区二区网站| 亚洲在线视频一区| 国产成人午夜高潮毛片| 日韩手机在线导航| 一级特黄大欧美久久久| 国产九色精品成人porny| 欧美久久久久久久久中文字幕| 亚洲国产成人自拍| 韩国欧美国产一区| 欧美一区二区精品久久911| 亚洲视频每日更新| 成人激情午夜影院| 精品国产乱码久久久久久图片| 亚洲成人黄色影院| 91视频在线观看免费| 国产视频一区在线观看| 久久精品国产亚洲一区二区三区| 欧美三区在线视频| 亚洲综合视频网| 91网站在线观看视频| 国产精品麻豆网站| 成人精品鲁一区一区二区| 精品国产精品网麻豆系列| 蜜桃视频一区二区三区 | 亚洲综合激情小说| 99在线精品视频| 国产欧美精品日韩区二区麻豆天美| 喷水一区二区三区| 日韩一级片网站| 免费不卡在线观看| 日韩美女视频在线| 国内外成人在线| 久久一夜天堂av一区二区三区| 久久精品噜噜噜成人av农村| 欧美一区二区三区啪啪| 美女高潮久久久| 精品美女一区二区| 国产成人精品在线看| 国产欧美日韩卡一| 9人人澡人人爽人人精品| 亚洲欧洲国产日韩| 色88888久久久久久影院按摩| 玉米视频成人免费看| 欧美偷拍一区二区| 美腿丝袜亚洲综合| 久久综合色综合88| 成人av中文字幕| 亚洲精品国产一区二区三区四区在线| 91免费在线视频观看| 亚洲妇女屁股眼交7| 欧美日韩电影在线播放| 久久99精品久久久久| 久久久99免费| 色婷婷狠狠综合| 石原莉奈在线亚洲二区| 久久综合久久综合久久综合| 成人精品视频一区二区三区尤物| 中文字幕永久在线不卡| 欧美精品电影在线播放| 国产在线麻豆精品观看| 亚洲欧美偷拍卡通变态| 欧美一区二区三区爱爱| 国产成人在线观看| 亚洲一区免费在线观看| 精品国产乱码久久久久久老虎 | 日韩精品电影在线| 久久九九久久九九| 一本在线高清不卡dvd| 蜜臀av一区二区在线免费观看| 欧美精品一区在线观看| 在线免费一区三区| 精品一区二区三区在线视频| 亚洲人成网站影音先锋播放| 日韩欧美久久久| 91丨porny丨首页| 国内精品久久久久影院色| 亚洲免费av观看| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 首页国产欧美日韩丝袜| 国产视频一区不卡| 欧美高清性hdvideosex| 99精品国产99久久久久久白柏| 三级不卡在线观看| 亚洲人成精品久久久久| 日韩亚洲欧美中文三级| 成人av电影免费观看| 久热成人在线视频| 丝袜美腿亚洲一区| 亚洲最大成人网4388xx| 精品久久久久久久一区二区蜜臀| 色88888久久久久久影院野外| 国产精品一二二区| 久久久蜜桃精品| 欧美三级三级三级| 黄一区二区三区| 日韩不卡在线观看日韩不卡视频| 亚洲欧美综合在线精品| 久久精品免视看| 精品国精品国产尤物美女| 777午夜精品视频在线播放| 91福利社在线观看| 色成年激情久久综合| www.日韩av| 99久久久精品免费观看国产蜜| 国产剧情一区二区| 韩日av一区二区| 麻豆免费精品视频| 美女免费视频一区| 久久精品二区亚洲w码| 日本欧美韩国一区三区| 午夜精品久久久久久久99水蜜桃| 亚洲视频综合在线| 国产精品国产三级国产普通话蜜臀 | 肉色丝袜一区二区| 丝瓜av网站精品一区二区| 日韩主播视频在线| 奇米亚洲午夜久久精品| 麻豆精品一二三| 国产一区二区三区在线观看精品 | 日韩美女视频一区二区 | 日本91福利区| 蜜臀久久久久久久| 日本va欧美va欧美va精品| 久久精工是国产品牌吗| 精品午夜一区二区三区在线观看| 韩国欧美国产一区| 99视频一区二区| 欧美在线视频不卡| 欧美丰满嫩嫩电影| 2023国产一二三区日本精品2022| 欧美成人a视频| 国产无一区二区| 亚洲激情图片一区| 日本不卡免费在线视频| 国产精品自产自拍| 色婷婷精品久久二区二区蜜臂av| 欧美在线观看视频在线| 日韩一区二区三区四区五区六区| 精品动漫一区二区三区在线观看| 中国色在线观看另类| 亚洲一线二线三线视频| 激情都市一区二区| 91麻豆国产福利精品| 日韩一级视频免费观看在线| 国产女人水真多18毛片18精品视频| 亚洲女女做受ⅹxx高潮| 麻豆成人久久精品二区三区红 | 成人性生交大片免费看视频在线| 色婷婷综合在线| 欧美成人欧美edvon| 中文字幕一区二区三区av| 视频一区欧美精品| 国产999精品久久久久久绿帽| 欧美在线不卡一区| 日本一区二区成人| 日韩电影一区二区三区四区| 成人精品国产免费网站| 日韩免费高清电影| 一区二区三区不卡在线观看| 日韩精品电影在线观看| 国产成人免费在线| 欧美日韩国产一二三| 中文字幕欧美日韩一区| 美女视频网站黄色亚洲| 91麻豆文化传媒在线观看| 久久久久久免费网| 日韩专区中文字幕一区二区| 97久久精品人人澡人人爽| 久久综合资源网| 日日夜夜免费精品| 在线亚洲欧美专区二区| 国产欧美日韩精品在线| 六月丁香综合在线视频| 欧美日韩国产小视频| 亚洲欧美福利一区二区| 国产成人免费视| 久久综合狠狠综合久久综合88| 亚洲成a人片在线不卡一二三区 | 在线观看av不卡| 中文字幕一区二区三区四区| 国产剧情一区在线| 精品剧情在线观看| 日本不卡不码高清免费观看| 欧美日韩精品一区视频| 一区二区三区91| 日本道免费精品一区二区三区| 国产精品丝袜一区| 国产精品综合在线视频| 精品久久久久香蕉网| 韩国理伦片一区二区三区在线播放| 日韩视频123| 精久久久久久久久久久| 精品国产sm最大网站免费看 | 亚洲国产日日夜夜|