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

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

?? nsgapopulation.cpp

?? 遺傳算法(Genetic Algorithm)是一類借鑒生物界的進化規律(適者生存
?? 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 "population.hpp"NsgaPopulation::NsgaPopulation(void) {  int ii, combinedPopSize = 2*(globalSetup->populationSize);  numFronts = 0;  numFrontChange = 0;  combinedGuys = new NsgaIndividual*[combinedPopSize];  numIndsFront = new int[combinedPopSize];  paretoFront = new int*[combinedPopSize];  for(ii = 0; ii < combinedPopSize; ii++) {    combinedGuys[ii] = new NsgaIndividual;    paretoFront[ii] = new int[combinedPopSize];  }  bestobj = new double[globalSetup->finalNoOfObjectives];  worstobj = new double[globalSetup->finalNoOfObjectives];  avgobj = new double[globalSetup->finalNoOfObjectives];  maxfit = new double[globalSetup->finalNoOfObjectives];  minfit = new double[globalSetup->finalNoOfObjectives];  avgfit = new double[globalSetup->finalNoOfObjectives];    varfit = new double[globalSetup->finalNoOfObjectives];    computeObjStatistics(GUYS);  mapObjectiveToFitness(GUYS);  computeFitnessStatistics(GUYS);}NsgaPopulation::~NsgaPopulation(void) {  int ii, combinedPopSize = 2*(globalSetup->populationSize);  for(ii = 0; ii < combinedPopSize; ii++) {    delete combinedGuys[ii];    delete paretoFront[ii];  }  delete []combinedGuys;  delete []numIndsFront;  delete []paretoFront;  delete []bestobj;  delete []worstobj;  delete []avgobj;  delete []minfit;  delete []maxfit;  delete []avgfit;  delete []varfit;}/***Peforms a nondominated sort of individuals to create a set of pareto fronts.Details:   *  The flag whichGuys refer to either the current population (for the initial generation) or the combined population.  *  domCount[i]: (domination count) Number of the individuals that dominate individual i  *  numIndDom[i]: Number of individuals that individual i dominates  *  indDomByMe[i]: Array of indices of individuals that individual i dominates  *  paretoFront[i]: Array of indices of individuals that are members of pareto front i.  *  numIndsFront[i]: Number of individuals in the ith front.  *  For every unique pair of individuals (i,j)     --Check if i dominates j, If yes then add j to indDomByMe[i], increment numIndDom[i] by 1 and increment domCount[j] by 1.     --On the other hand if j dominates i, then add i to indDomByMe[j], increment numIndDom[j] by 1 and increment domCount[i] by 1.  * For every individual i     --If domCount[i] equals 0, then add individual i to paretoFront[0], increment numIndsFront[0], and set the rank of individual i to 0  * Set frontID = 0. While number of individuals in the pareto Front is greater than zero, do     --For every individual i in the pareto front frontID          *  For every individual j that individual i dominates	    --Decrement the domination count of j by i            --If the domination count of j is equal to zero, then add j to the paretoFron[frontID+1], increment numIndsFront[frontID+1], and set the rank of individual j to frontID+1.     --Increment the frontID by one * Set total number of pareto fronts to frontID.*/void NsgaPopulation::doNonDominatedSort(int whichGuys){  int ii, jj, popSize, fid, idomj, nif;  int *domCount, **indDomByMe, *numIndDom;  int oldNoOfFronts;  NsgaIndividual **theGuys;  oldNoOfFronts = numFronts;  if(whichGuys == GUYS) {    popSize = globalSetup->populationSize;    theGuys = (NsgaIndividual**)guys;  }  else if(whichGuys == COMBINEDGUYS) {    popSize = 2*(globalSetup->populationSize);    theGuys = combinedGuys;  }  domCount = new int[popSize];  numIndDom = new int[popSize];  indDomByMe = new int*[popSize];  for(ii = 0; ii < popSize; ii++) {     indDomByMe[ii] = new int[popSize];    domCount[ii] = numIndDom[ii] = 0;  }  for(ii = 0; ii < popSize-1; ii++) {    for(jj = ii+1; jj < popSize; jj++) {      idomj = dominates(theGuys[ii],theGuys[jj]);      if(idomj == IDOMJ) {	indDomByMe[ii][numIndDom[ii]] = jj;	numIndDom[ii] += 1;	domCount[jj] += 1;      }      else if(idomj == JDOMI) {	indDomByMe[jj][numIndDom[jj]] = ii;	numIndDom[jj] += 1;	domCount[ii] += 1;      }    }  }  nif = 0;  for(ii = 0; ii < popSize; ii++) {    if(domCount[ii] == 0) {      paretoFront[0][nif++] = ii;      theGuys[ii]->setRank(0);    }  }  numIndsFront[0] = nif;  fid = 0;  while(numIndsFront[fid] != 0) {    nif = 0;    for(ii = 0; ii < numIndsFront[fid]; ii++) {      for(jj = 0; jj < numIndDom[paretoFront[fid][ii]]; jj++) {	domCount[indDomByMe[paretoFront[fid][ii]][jj]] -= 1;	if(domCount[indDomByMe[paretoFront[fid][ii]][jj]] == 0) {	  paretoFront[fid+1][nif++] = indDomByMe[paretoFront[fid][ii]][jj];	  theGuys[indDomByMe[paretoFront[fid][ii]][jj]]->setRank(fid+1);	}      }    }    fid += 1;    numIndsFront[fid] = nif;  }  numFronts = fid;  numFrontChange = abs(oldNoOfFronts - numFronts);  if(whichGuys == GUYS)     for(ii = 0; ii < popSize; ii++) guys[ii] = theGuys[ii];  else if(whichGuys == COMBINEDGUYS)    for(ii = 0; ii < popSize; ii++) combinedGuys[ii] = theGuys[ii];    for(ii = 0; ii < popSize; ii++)     delete indDomByMe[ii];  delete []domCount;  delete []numIndDom;  delete []indDomByMe;}/***Computes the crowding distance of each individual.Details:  * The flag whichGuys refer to either the current population (for the initial generation) or the combined population.  * For every front i    -- For every objective j       * Sort the individuals in front i in ascending order of objective j       * Set the crowding distance of the first and the last individual to infinity       * For every individual k in the front i except the first and the last individuals         --Normalize the fitness j by dividing the fitness j of individual k-1  and individual k+1 by maximum jth fitness.	 --Add absolute value of (Normalized jth fitness of individual k+1 - Normalized jth fitness of individual k-1) to the crowding distance of kth individual.*/void NsgaPopulation::computeCrowdingDistance(int whichGuys){  int ii, jj, kk, firstInd, lastInd;  int indId1, indId2, indId, popSize;  int *sortListByObj;  double normFit1, normFit2, *crowdDist;  NsgaIndividual **theGuys;    if(whichGuys == GUYS) {    popSize = globalSetup->populationSize;    theGuys = (NsgaIndividual**)guys;  }  else if(whichGuys == COMBINEDGUYS) {    popSize = 2*(globalSetup->populationSize);    theGuys = combinedGuys;  }  crowdDist = new double[popSize];  for(ii = 0; ii < popSize; ii++) crowdDist[ii] = 0.0;  for(ii = 0; ii < numFronts; ii++) {    sortListByObj = new int[numIndsFront[ii]];    for(jj = 0; jj < globalSetup->finalNoOfObjectives; jj++) {      for(kk = 0; kk < numIndsFront[ii]; kk++)	sortListByObj[kk] = paretoFront[ii][kk];      quickSort(theGuys, sortListByObj, 0, numIndsFront[ii],jj);      firstInd = sortListByObj[0];      lastInd = sortListByObj[numIndsFront[ii]-1];      crowdDist[firstInd] = crowdDist[lastInd] = INFTY;      for(kk = 1; kk < numIndsFront[ii]-1; kk++) {	indId = sortListByObj[kk];	indId1 = sortListByObj[kk+1];	indId2 = sortListByObj[kk-1];	normFit1 = theGuys[indId1]->getFitness(jj)/(1.0+maxfit[jj]);	normFit2 = theGuys[indId2]->getFitness(jj)/(1.0+maxfit[jj]);	crowdDist[indId] += fabs(normFit1 - normFit2);      }    }    delete []sortListByObj;  }    if(whichGuys == GUYS)     for(ii = 0; ii < popSize; ii++)       ((NsgaIndividual**)guys)[ii]->setCrowdingDistance(crowdDist[ii]);  else if (whichGuys == COMBINEDGUYS)    for(ii = 0; ii < popSize; ii++)      combinedGuys[ii]->setCrowdingDistance(crowdDist[ii]);  delete [] crowdDist;}/// Quick sort routine used for crowding distance computation. Sorts the individuals in a given pareto front in ascending order of objId th objective value.void NsgaPopulation::quickSort(NsgaIndividual **theGuys, int *output, 			       int left, int right, int objId){  int ii, xx;  double target;    if(right > left) {    target = theGuys[output[right-1]]->getFitness(objId);    ii = left-1;    xx = right-1;    for(;;) {      while(theGuys[output[++ii]]->getFitness(objId) < target)	if(ii >= right-1) break;      if(ii >= xx) break;      while(theGuys[output[--xx]]->getFitness(objId) > target)	if(xx <= 0) break;      if(ii >= xx) break;      swap(output[ii],output[xx]);    }    swap(output[ii],output[right-1]);    quickSort(theGuys, output, left, ii, objId);    quickSort(theGuys, output, ii+1, right, objId);  }}///Swap used by the sort functionvoid NsgaPopulation::swap(int& ii, int& jj){  int temp;  temp = jj; jj = ii; ii = temp;}///Quick sort function to sort individuals in a pareto front according to the crowding distance.void NsgaPopulation::regQSort(double *crowdDist, int *output, int left, int right){  int ii, xx;  double target;  if(right > left) {    target = crowdDist[output[right-1]];    ii = left-1;    xx = right-1;    for(;;) {      while(crowdDist[output[++ii]] < target)	if(ii >= right-1) break;      if(ii >= xx) break;      while(crowdDist[output[--xx]] > target)	if(xx <= 0) break;      if(ii >= xx) break;      swap(output[ii],output[xx]);    }    swap(output[ii],output[right-1]);    regQSort(crowdDist, output, left, ii);    regQSort(crowdDist, output, ii+1, right);  }}/*============================================================** Function Name: NsgaPopulation::computeObjStatistics(int whichGuys)** The flag whichGuys refer to either the current population (for the ** initial generation) or the combined population.** Function Task: this method generates statistics according to ** each objective function values. It finds out the average objective** value for the population and the best and worst objective ** values for each objective function. This depends on whether the ** type of optimization in the problem of each objective function ** is minimization or maximization. ** Output:None** Functions called: Individual::getObjective(int jj)**========================================================*/void NsgaPopulation::computeObjStatistics(int whichGuys) {  int ii, jj, popSize;  double oneOverPopulationSize;  NsgaIndividual **theGuys;    if(whichGuys == GUYS) {    popSize = globalSetup->populationSize;    theGuys = (NsgaIndividual**)guys;  }  else if(whichGuys == NEWGUYS) {    popSize = globalSetup->populationSize;    theGuys = (NsgaIndividual**)newGuys;  }  else if(whichGuys == COMBINEDGUYS) {    popSize = 2*(globalSetup->populationSize);    theGuys = combinedGuys;  }    oneOverPopulationSize = 1.0/(1.0*popSize);    for(jj = 0; jj < globalSetup->finalNoOfObjectives; jj++) {    bestobj[jj] = worstobj[jj] = theGuys[0]->getObjective(jj);    avgobj[jj] = oneOverPopulationSize*(theGuys[0]->getObjective(jj));    for(ii = 1; ii < popSize; ii++) {      avgobj[jj] += oneOverPopulationSize*(theGuys[ii]->getObjective(jj));      if(globalSetup->typeOfOptimizations[jj] == Maximization) {	if(theGuys[ii]->getObjective(jj) > bestobj[jj]) bestobj[jj] = theGuys[ii]->getObjective(jj);	if(theGuys[ii]->getObjective(jj) < worstobj[jj]) worstobj[jj] = theGuys[ii]->getObjective(jj);      }      if(globalSetup->typeOfOptimizations[jj]==Minimization) {	if(theGuys[ii]->getObjective(jj) < bestobj[jj]) bestobj[jj] = theGuys[ii]->getObjective(jj);	if(theGuys[ii]->getObjective(jj) > worstobj[jj]) worstobj[jj] = theGuys[ii]->getObjective(jj);      }          }  }}/*============================================================** Function Name: NsgaPopulation::computeFitnessStatistics(int whichGuys)** The flag whichGuys refer to either the current population ** (for the initial generation) or the combined population.** Function Task: this method generates statistics according to ** every 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 for each fitness function.** Output:None** Functions called: Individual::getFitness(int jj)**========================================================*/void NsgaPopulation::computeFitnessStatistics(int whichGuys) {  int ii, jj, popSize;  double oneOverPopulationSize;  NsgaIndividual **theGuys;    if(whichGuys == GUYS) {    popSize = globalSetup->populationSize;    theGuys = (NsgaIndividual**)guys;  }  else if(whichGuys == NEWGUYS) {    popSize = globalSetup->populationSize;    theGuys = (NsgaIndividual**)newGuys;  }  else if(whichGuys == COMBINEDGUYS) {    popSize = 2*(globalSetup->populationSize);    theGuys = combinedGuys;  }    oneOverPopulationSize = 1.0/(1.0*popSize);    for(jj = 0; jj < globalSetup->finalNoOfObjectives; jj++) {    maxfit[jj] = minfit[jj] = theGuys[0]->getFitness(jj);    avgfit[jj] = oneOverPopulationSize*(theGuys[0]->getFitness(jj));    varfit[jj] = oneOverPopulationSize*(theGuys[0]->getFitness(jj))*(theGuys[0]->getFitness(jj));        for(ii = 1; ii < popSize; ii++) {      avgfit[jj] += oneOverPopulationSize*(theGuys[ii]->getFitness(jj));      varfit[jj] += oneOverPopulationSize*(theGuys[ii]->getFitness(jj))*(theGuys[ii]->getFitness(jj));      if(theGuys[ii]->getFitness(jj) > maxfit[jj]) maxfit[jj] = theGuys[ii]->getFitness(jj);      if(theGuys[ii]->getFitness(jj) < minfit[jj]) minfit[jj] = theGuys[ii]->getFitness(jj);    }    varfit[jj] -= avgfit[jj]*avgfit[jj];  }}/***Map each objective to corresponding fitness value depending on minimization or maximization. The flag whichGuys refer to either the current population (for the initial generation) or the combined population. If the jth objective value is a maximization, then the fitness is set equal to the objective value. On the other hand, if the problem is a minimization one, then set the fitness equal to the negative of the objective value. */void NsgaPopulation::mapObjectiveToFitness(int whichGuys) {  int ii,jj, popSize;  NsgaIndividual **theGuys;    if(whichGuys == GUYS) {    popSize = globalSetup->populationSize;    theGuys = (NsgaIndividual **)guys;  }  else if(whichGuys == NEWGUYS) {    popSize = globalSetup->populationSize;    theGuys = (NsgaIndividual **)newGuys;  }  else if(whichGuys == COMBINEDGUYS) {    popSize = 2*(globalSetup->populationSize);    theGuys = combinedGuys;  }  for (jj=0; jj<globalSetup->finalNoOfObjectives; jj++) {    if (globalSetup->typeOfOptimizations[jj] == Maximization)       for(ii = 0; ii < popSize; ii++)        theGuys[ii]->setFitness(jj, theGuys[ii]->getObjective(jj));     else      for (ii=0; ii< popSize; ii++) 	theGuys[ii]->setFitness(jj, -theGuys[ii]->getObjective(jj));  }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区二区精品视频| 天天亚洲美女在线视频| 亚洲国产成人tv| 国产不卡在线一区| 91精品欧美一区二区三区综合在| 欧美国产激情二区三区| 人禽交欧美网站| 色呦呦国产精品| 国产婷婷一区二区| 捆绑调教一区二区三区| 欧美午夜精品一区二区三区| 日本一区二区三区免费乱视频| 日韩专区一卡二卡| 欧美视频一区二区三区四区 | 国产欧美综合在线观看第十页| 亚洲韩国精品一区| 在线观看免费亚洲| 亚洲视频综合在线| 97久久精品人人做人人爽| 久久午夜色播影院免费高清 | 欧美三级日本三级少妇99| 欧美国产日本韩| 国产成人精品午夜视频免费| 日韩亚洲欧美在线| 免费在线观看日韩欧美| 7777女厕盗摄久久久| 亚洲成a人片在线不卡一二三区| 91麻豆6部合集magnet| 国产精品第五页| 99在线精品观看| 亚洲欧美激情插| 91欧美激情一区二区三区成人| 国产精品高潮久久久久无| 成人激情开心网| 亚洲素人一区二区| 色av成人天堂桃色av| 日韩毛片精品高清免费| 色婷婷一区二区| 亚洲影视资源网| 欧美精品第1页| 奇米精品一区二区三区在线观看一 | 欧美日韩在线三区| 五月激情丁香一区二区三区| 欧美福利电影网| 日韩va欧美va亚洲va久久| 日韩一级片网址| 国产一区二区美女| 亚洲私人黄色宅男| 欧洲视频一区二区| 日本在线观看不卡视频| 久久亚洲综合色一区二区三区| 国产美女精品在线| 亚洲丝袜精品丝袜在线| 欧美日韩免费在线视频| 久久国产三级精品| 欧美激情一二三区| 欧美日韩在线播放三区| 美美哒免费高清在线观看视频一区二区| 日韩欧美国产一二三区| 国产宾馆实践打屁股91| 亚洲一二三专区| 精品国产乱码久久| 一本到三区不卡视频| 免费成人在线视频观看| 中文在线一区二区| 欧美精品久久99久久在免费线 | 亚洲国产精品久久人人爱蜜臀| 3d动漫精品啪啪一区二区竹菊| 国产精品资源站在线| 一区二区三区蜜桃网| 精品处破学生在线二十三| 91网站黄www| 老司机免费视频一区二区三区| 国产精品国产三级国产三级人妇| 精品视频色一区| 丁香六月综合激情| 青青草原综合久久大伊人精品 | 精品久久久久一区| 在线亚洲高清视频| 国产福利一区二区| 丝袜a∨在线一区二区三区不卡| 国产欧美日韩麻豆91| 在线电影国产精品| 色综合视频在线观看| 精品亚洲porn| 午夜精品久久久久久久久久久 | 日韩一区二区三区av| 91网页版在线| 成人综合在线视频| 狠狠色2019综合网| 日韩精品亚洲专区| 亚洲一区二区在线播放相泽| 国产精品国产自产拍高清av | 日本高清成人免费播放| 国产二区国产一区在线观看| 视频一区免费在线观看| 亚洲激情图片qvod| 日韩毛片高清在线播放| 久久久www成人免费无遮挡大片| 制服丝袜亚洲色图| 欧美综合色免费| 91在线国产福利| 菠萝蜜视频在线观看一区| 经典三级视频一区| 奇米亚洲午夜久久精品| 日韩国产欧美三级| 午夜久久福利影院| 天天色 色综合| 亚洲国产成人av好男人在线观看| 亚洲欧美色一区| 亚洲欧美韩国综合色| 亚洲日本在线看| 亚洲免费色视频| 亚洲乱码国产乱码精品精98午夜| 中文在线一区二区| 日本一区二区不卡视频| 中文久久乱码一区二区| 国产农村妇女精品| 国产精品美女一区二区在线观看| 国产精品三级视频| 国产精品久久久久久久午夜片| 日本一区二区三区四区在线视频| 国产欧美精品国产国产专区| 国产欧美精品在线观看| 国产精品色呦呦| 亚洲欧美日韩小说| 亚洲午夜影视影院在线观看| 亚洲一区在线观看免费| 天天av天天翘天天综合网色鬼国产| 亚洲电影在线播放| 麻豆精品蜜桃视频网站| 国产精品中文欧美| av在线播放一区二区三区| 色婷婷激情久久| 91精品久久久久久久久99蜜臂| 日韩亚洲欧美在线观看| 国产色综合久久| 亚洲视频一区二区免费在线观看| 一区二区三区.www| 日韩精品亚洲一区二区三区免费| 另类人妖一区二区av| 国产成人在线视频网址| 一本一道波多野结衣一区二区| 欧美日精品一区视频| 日韩一区二区三区三四区视频在线观看| 精品三级在线观看| 亚洲欧美成人一区二区三区| 无码av中文一区二区三区桃花岛| 国产一区二区伦理| 91行情网站电视在线观看高清版| 日韩色在线观看| 国产精品久久福利| 美女国产一区二区三区| k8久久久一区二区三区| 欧美日韩国产影片| 国产日韩欧美精品电影三级在线| 亚洲免费在线电影| 国产精品综合视频| 欧美视频在线播放| 国产精品视频一区二区三区不卡| 亚洲图片欧美视频| 成人精品鲁一区一区二区| 欧美精品丝袜中出| 国产精品久久久久久妇女6080| 五月婷婷另类国产| 91在线视频18| 久久午夜免费电影| 午夜av电影一区| 91影院在线观看| 国产亚洲欧美色| 日韩国产一二三区| 91蜜桃在线观看| 国产欧美一区二区精品久导航| 日本不卡的三区四区五区| 97久久精品人人做人人爽50路| 精品国产乱码久久| 日产国产高清一区二区三区 | 日韩欧美精品在线视频| 亚洲色欲色欲www| 国产成人免费在线| 日韩欧美国产电影| 视频一区中文字幕国产| 欧美在线你懂得| 一区二区三区四区不卡在线| 成人黄色软件下载| 欧美国产欧美亚州国产日韩mv天天看完整 | 国产精品女主播av| 国产精品一线二线三线精华| 日韩视频免费直播| 奇米色一区二区| 欧美一区二区播放| 亚洲高清不卡在线观看| 欧美在线播放高清精品| 亚洲制服丝袜在线| 色999日韩国产欧美一区二区| 最新不卡av在线| 91首页免费视频| 亚洲美女在线国产| 欧美亚洲动漫精品| 一区二区三区四区激情|