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

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

?? select.cc

?? 用C++編寫的遺傳算法
?? CC
字號:
// select.cc/* -------------------------------------------------------------------gpc++ - The Genetic Programming KernelThis program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 1, or (at your option)any later version.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.Copyright 1993, 1994 Adam P. Fraser and 1996, 1997 Thomas WeinbrennerFor comments, improvements, additions (or even money) contact:Thomas WeinbrennerGrauensteinstr. 2635789 LaimbachGermanyE-mail: thomasw@emk.e-technik.th-darmstadt.deWWW:    http://www.emk.e-technik.th-darmstadt/~thomasw  or (Address may be out of date)Adam Fraser, Postgraduate Section, Dept of Elec & Elec Eng,Maxwell Building, University Of Salford, Salford, M5 4WT, United Kingdom.E-mail: a.fraser@eee.salford.ac.ukTel:    (UK) 061 745 5000 x3633Fax:    (UK) 061 745 5999------------------------------------------------------------------- */// All the common code for selections of a gp#include "gp.h"// Sometimes, an array of integer is needed, with unspecified size,// where in most cases, however, the size is just a few.  We provide// such an array here to save us the slow memory allocation, but// allocate if necessary.  I would like to use templates here (I hate// it to duplicate code, and a #define macro is not what I want), but// it makes no sense just for the few lines...const int selectionArraySize=2;class IntegerArraySel{public:  // Constructor  IntegerArraySel (int size)   {    // Is is necessary to allocate space?  If not, set pointer to    // local array    allocateFlag=size>selectionArraySize;    if (allocateFlag)      arrayPtr=new int [size];    else       arrayPtr=&array[0];  }  // Destructor  ~IntegerArraySel ()   {    // If space was allocated, delete it    if (allocateFlag)      delete [] arrayPtr;  }  // Access array via [] operator  int& operator [] (int index) { return *(arrayPtr+index); }private:  // Flag whether space was allocated or not  short allocateFlag;  // Pointer to allocated space or local array  int* arrayPtr;  // Local array  int array[selectionArraySize];};// Same for tournament arrayconst int tournamentArraySize=20;class IntegerArrayTourn{public:  // Constructor  IntegerArrayTourn (int size)   {    // Is is necessary to allocate space?  If not, set pointer to    // local array    allocateFlag=size>tournamentArraySize;    if (allocateFlag)      arrayPtr=new int [size];    else       arrayPtr=&array[0];  }  // Destructor  ~IntegerArrayTourn ()   {    // If space was allocated, delete it    if (allocateFlag)      delete [] arrayPtr;  }  // Access array via [] operator  int& operator [] (int index) { return *(arrayPtr+index); }private:  // Flag whether space was allocated or not  short allocateFlag;  // Pointer to allocated space or local array  int* arrayPtr;  // Local array  int array[tournamentArraySize];};// Selection routine for tournament selection// By Adam Fraser.  What is tournament selection?  Tournament// selection randomly selects a number of genetic programs from the// population.  The fitness of each member of this group are compared// with each other and the best replaces the worst.// Why should I use tournament selection?  This method is one which// can be easily implemented using a parallel methodology and seems to// result in a quicker solution in a search than the fitness// proportionate method to be used by Koza.  No idea why really it// just seems to give better emperical results though some people// (Howard Oakley ??) find that with certain problems (he studies// chaotic data series of blood flow) tournament selection actually// gives worst results.  So be careful with the selection method you// choose and check a few methods out before doing thousands of runs.// We have to select some members (this routine works only with 1 and// 2 members, otherwise we would have to use some sort algorithm to// get the n best/worst ones of the tournament), and return them in// the array pointed to by the variable selection.void GPPopulation::tournamentSelection (int *selection, int numToSelect,					int selectWorst, 					GPPopulationRange& range){  int i;#if GPINTERNALCHECK  if (numToSelect!=1 && numToSelect!=2)    GPExitSystem ("GPPopulation::tournamentSelection", 		  "Wrong argument numToSelect");  if (GPVar.TournamentSize<2)    GPExitSystem ("GPPopulation::tournamentSelection", 		  "Wrong tournament size");  if (range.endIx-range.startIx<1)    GPExitSystem ("GPPopulation::tournamentSelection", 		  "Range to select from is empty");#endif  // The tournament is an array of integers, containing the indices to  // the GPs  IntegerArrayTourn tourn (GPVar.TournamentSize);  // We randomly select a few members from the given index range and  // put the indices into the tournament array.  for (i=0; i<GPVar.TournamentSize; i++)    tourn[i]=range.startIx + GPrand () % (range.endIx-range.startIx);  // Now we look for the two best/worst ones, which become the  // parents.  Well, perhaps we need only one  int bestOrWorst=0, second=1;  if (selectWorst)    // Find the two worst ones    {      if (NthGP (tourn[0])->stdFitness < NthGP (tourn[1])->stdFitness)	{	  bestOrWorst=1; second=0;	}      for (i=2; i<GPVar.TournamentSize; i++)	if (NthGP (tourn[i])->stdFitness 	    > NthGP (tourn[bestOrWorst])->stdFitness)	  {	    second=bestOrWorst;	    bestOrWorst=i;	  }	else	  if (NthGP (tourn[i])->stdFitness 	    > NthGP (tourn[second])->stdFitness)	    second=i;    }  else    // Find the two best ones    {      if (NthGP (tourn[0])->stdFitness > NthGP (tourn[1])->stdFitness)	{	  bestOrWorst=1; second=0;	}      for (i=2; i<GPVar.TournamentSize; i++)	if (NthGP (tourn[i])->stdFitness 	    < NthGP (tourn[bestOrWorst])->stdFitness)	  {	    second=bestOrWorst;	    bestOrWorst=i;	  }	else	  if (NthGP (tourn[i])->stdFitness 	      < NthGP (tourn[second])->stdFitness)	    second=i;    }  // Put the index of the best/worst (maximum: two) in the array  selection[0]=tourn[bestOrWorst];  if (numToSelect==2)    selection[1]=tourn[second];}// Calc 1/xinline static double inverse (double x){  if (x<1e-10)    return 1e10;  else     return 1.0/x;}// Selects the n best or worst members using a probablistic fitness// function in the population.  For information see John Koza 'Genetic// Programming' or David Goldberg 'Genetic Algorithms for Search and// Optimisation'.  I had to change the algorithm a bit because we are// now using standardized fitness which means we have to use the// inverse value of it.  We have to select some members, and return// them in the array pointed to by the variable selection.void GPPopulation::probabilisticSelection (int *selection, int numToSelect, 					   int selectWorst, 					   GPPopulationRange& range){  int i;#if GPINTERNALCHECK  if (numToSelect<1)    GPExitSystem ("GPPopulation::probablisticSelection",		  "Wrong argument numToSelect");#endif  // If this is the first time the function is called for this deme,  // loop through population or deme and summate all fitnesses.  if (range.firstSelectionPerDeme)    {      range.firstSelectionPerDeme=0;      sumFitness=0.0; invSumFitness=0.0;      for (i=range.startIx; i<range.endIx; i++)	{	  GP* gp=NthGP (i);	  invSumFitness+=inverse (gp->stdFitness);	  sumFitness+=gp->stdFitness;	}    }  // We select as much members as the user wants (usually 1 or 2)  for (int n=0; n<numToSelect; n++)    {      // Get random number between 0 and a high value.  The higher the      // value, the better the resolution.  Be careful what numbers      // the random generator gives us! (The new random generator      // doesn't have the problems the old one had)      const long highValue=300000l;      double rand=(double) (GPrand() % highValue);      // Loop through population, summing up the fitness/inversed      // fitness.  As we are using standardized fitness, we sum up      // 1/stdFitness when looking for the best, which yields to the      // maximum value of invSumFitness.  If we reach the randomized      // value (we have to perform some scaling here), thats the      // member we want!      if (selectWorst)	{	  double sum=0.0;	  double lookingForFit=rand / (double)(highValue-1l) 	    * sumFitness;	  for (i=range.startIx; i<range.endIx; i++)	    {	      sum+=NthGP (i)->stdFitness;	      if (sum>=lookingForFit)		break;	    }	}      else	{	  double sumInv=0.0;	  double lookingForInvFit=rand / (double)(highValue-1l) 	    * invSumFitness;	  for (i=range.startIx; i<range.endIx; i++)	    {	      sumInv+=inverse (NthGP (i)->stdFitness);	      if (sumInv>=lookingForInvFit)		break;	    }	}      // This shouldn't happen, but just in case...      if (i>=range.endIx) 	i=range.endIx-1;      // Add the selected population member to the array of indives      selection[n]=i;    }}// We select numToSelect best or worst population members from the// population using one of the specified selection methods, and return// the indices of the selected members as an array of integers.  We// don't select from all population members, but only in a range// between startIx and endIx (the last one exclusive).  This is used// for demetic grouping.void GPPopulation::selectIndices (int *selection, int numToSelect, 				  int selectWorst, 				  GPPopulationRange& range){  // The selection method differs  switch (GPVar.SelectionType)    {    case GPTournamentSelection:      tournamentSelection (selection, numToSelect, selectWorst, range);      break;    case GPProbabilisticSelection:      probabilisticSelection (selection, numToSelect, selectWorst, range);      break;    default:#if GPINTERNALCHECK      GPExitSystem ("GPPopulation::select", "Unknown selection method");#endif      break;    }}// Select numToSelect best population members from the population// using the function selectIndices, make a copy of them and return// them in a container.  We don't select from all population members,// but only in a range between startIx and endIx (the last one// exclusive).  This is used for demetic grouping.GPContainer* GPPopulation::select (int numToSelect, 				   GPPopulationRange& range){  // An array of integers with the indices of the selected GPs  IntegerArraySel selec (numToSelect);  // Select the best ones  selectIndices (&selec[0], numToSelect, 0, range);  // Allocate container  GPContainer* cont=new GPContainer (numToSelect);  // Add the selected population member to the container, making a  // copy of it  for (int n=0; n<numToSelect; n++)    cont->put (n, NthGP(selec[n])->duplicate ());  // Return container  return cont;}// Select two parents and return them in a container.GPContainer* GPPopulation::selectParents (GPPopulationRange& range){  return     select (2, range);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本一二三不卡| 久久久久高清精品| 日韩精品91亚洲二区在线观看| 日本大香伊一区二区三区| 亚洲精品免费看| 欧美体内she精视频| 日本大胆欧美人术艺术动态| 欧美一级淫片007| 极品瑜伽女神91| 国产欧美日产一区| 91在线视频播放地址| 亚洲综合精品久久| 日韩欧美在线观看一区二区三区| 精品无人区卡一卡二卡三乱码免费卡 | 欧美性一区二区| 日韩激情中文字幕| 国产日韩欧美麻豆| 色综合欧美在线| 青青草成人在线观看| 日本一区二区三区电影| 色婷婷久久久久swag精品| 三级欧美韩日大片在线看| 久久精品欧美日韩精品 | 亚洲伦理在线免费看| 这里只有精品免费| 成人精品gif动图一区| 亚洲高清在线精品| 久久伊99综合婷婷久久伊| 91电影在线观看| 久久精品国产一区二区三| 欧美激情一区三区| 91精品国产综合久久精品| 国产91在线|亚洲| 亚洲国产精品久久一线不卡| 精品国产一区久久| 欧美三级日本三级少妇99| 精品夜夜嗨av一区二区三区| 亚洲一区二区在线免费看| 国产亚洲欧美一区在线观看| 在线看日韩精品电影| 国产电影一区在线| 日韩电影在线看| 亚洲精品日产精品乱码不卡| 国产午夜精品久久久久久免费视| 欧美色网一区二区| 99视频在线观看一区三区| 国内精品久久久久影院一蜜桃| 亚洲国产欧美另类丝袜| 国产精品网站在线观看| 欧美精品一区二区三区蜜臀| 欧美色国产精品| 99久久国产综合色|国产精品| 卡一卡二国产精品| 水野朝阳av一区二区三区| 亚洲色图欧美偷拍| 国产精品精品国产色婷婷| 中文幕一区二区三区久久蜜桃| 欧美一级黄色大片| 欧美丝袜第三区| 日本高清不卡在线观看| 成人高清视频免费观看| 国产精品一区不卡| 国内精品不卡在线| 久久99精品国产麻豆不卡| 石原莉奈一区二区三区在线观看 | 2欧美一区二区三区在线观看视频| 91国产免费观看| 一本色道久久加勒比精品| 99久久久精品免费观看国产蜜| 国产高清视频一区| 国产成a人亚洲精品| 大白屁股一区二区视频| 国产精品一二三在| 国产91在线看| 成人精品国产一区二区4080| 风间由美一区二区av101| 国产不卡视频在线播放| 高清不卡在线观看| 国产99久久久国产精品潘金| 国产成人免费视| 成人app软件下载大全免费| 风间由美一区二区三区在线观看| 国产一区二区伦理片| 韩国v欧美v亚洲v日本v| 国产麻豆午夜三级精品| 东方欧美亚洲色图在线| 97se亚洲国产综合自在线不卡 | 久久久久久综合| 国产三级欧美三级日产三级99| 久久天天做天天爱综合色| 中文久久乱码一区二区| 久久精品99久久久| 国产成人综合视频| 91免费版pro下载短视频| 色综合久久中文综合久久97| 欧美三级中文字| 久久综合av免费| 中文字幕一区二区5566日韩| 亚洲综合av网| 麻豆视频观看网址久久| 国产一区二区三区蝌蚪| 99在线热播精品免费| 欧美日本视频在线| 欧美精品一区二区蜜臀亚洲| 国产精品久久三区| 亚洲国产乱码最新视频| 狠狠网亚洲精品| 99免费精品视频| 5566中文字幕一区二区电影 | 国产激情一区二区三区四区| 成人午夜免费视频| 在线视频国内自拍亚洲视频| 欧美一级片在线观看| 国产欧美日韩卡一| 亚洲va韩国va欧美va| 国产成人自拍高清视频在线免费播放 | 中文字幕一区二区在线播放| 一区二区三区高清不卡| 久久99久久久久| 99在线精品免费| 精品久久久久一区| 尤物在线观看一区| 国产一区二区视频在线| 91丨porny丨最新| 欧美tickling挠脚心丨vk| 亚洲人成网站色在线观看| 激情成人午夜视频| 色噜噜狠狠色综合中国| 久久久国产一区二区三区四区小说| 中文字幕欧美一| 激情成人综合网| 欧美日韩一区三区四区| 国产精品网友自拍| 久久精品国产久精国产爱| 91丝袜国产在线播放| 精品成人在线观看| 亚洲福利一二三区| 91蜜桃视频在线| 国产女人aaa级久久久级| 美女mm1313爽爽久久久蜜臀| 91在线国产福利| 国产农村妇女毛片精品久久麻豆| 日本欧美一区二区三区乱码| 91国在线观看| 国产精品久久久久精k8 | 国产黄人亚洲片| 精品免费日韩av| 日本成人超碰在线观看| 欧美又粗又大又爽| 亚洲欧洲av在线| 国产91对白在线观看九色| 2020国产精品| 蜜芽一区二区三区| 欧美日韩一区二区三区免费看| 综合亚洲深深色噜噜狠狠网站| 国产麻豆精品在线| 欧美一区二区三区免费大片| 亚洲国产精品久久久男人的天堂| 99热精品国产| 亚洲男人天堂av| 99精品国产一区二区三区不卡| 中文无字幕一区二区三区| 国产成人aaa| 国产精品入口麻豆原神| 国产夫妻精品视频| 国产欧美日本一区视频| 国产毛片精品视频| 国产亚洲欧美一级| 成人黄色小视频| 中文字幕视频一区| 一本到不卡免费一区二区| 亚洲女同ⅹxx女同tv| 欧美中文字幕亚洲一区二区va在线| 亚洲精选视频在线| 欧美伊人久久久久久久久影院| 亚洲一区二区在线播放相泽| 欧美精选一区二区| 日本一不卡视频| 亚洲欧美欧美一区二区三区| 91在线看国产| 亚洲丶国产丶欧美一区二区三区| 欧美午夜一区二区三区| 婷婷久久综合九色综合绿巨人| 欧美人狂配大交3d怪物一区 | 美女www一区二区| 久久嫩草精品久久久久| 成人动漫精品一区二区| 亚洲色图丝袜美腿| 欧美高清视频一二三区| 国产最新精品免费| 成人免费一区二区三区在线观看| av亚洲精华国产精华精| 亚洲国产精品精华液网站| 日韩精品一区二区三区视频播放| 国产一区二区中文字幕| 国产精品久久久久桃色tv| 欧美日韩一区二区三区不卡| 免费高清不卡av| 中文字幕亚洲在| 欧美理论片在线|