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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? gatsp.cpp

?? Evenly spaces the cities on the perimeter of a wheel and returns a vector of their coordinates 利用AI
?? CPP
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
	if ( (RandFloat() > m_dCrossoverRate) || (mum == dad)) 
	{
    //make sure baby1 and baby2 are assigned some cities first!
    baby1 = mum;
    baby2 = dad;
    
		return;
	}

  //initialize the babies with minus values so we can tell which positions
  //have been filled later in the algorithm
  baby1.assign(mum.size(), -1);
  baby2.assign(mum.size(), -1);

  int l = baby2.size();

  //holds the positions of the chosen cities
  vector<int> positions;

  //first city position
  int Pos = RandInt(0, mum.size()-2);

  //keep adding random cities until we can add no more
  //record the positions as we go
  while (Pos < mum.size())
  {
    positions.push_back(Pos);

    //next city
    Pos += RandInt(1, mum.size()-Pos);
  }
  
  //now we have chosen some cities it's time to copy the selected cities
  //over into the offspring in the same position.
  for (int pos=0; pos<positions.size(); ++pos)
  {
    //baby1 receives from mum
    baby1[positions[pos]] = mum[positions[pos]];

    //baby2 receives from dad
    baby2[positions[pos]] = dad[positions[pos]];
  }

  //fill in the blanks. First create two position markers so we know
  //whereabouts we are in baby1 and baby2
  int c1 = 0, c2 = 0;

  for (pos=0; pos<mum.size(); ++pos)
  {   
    //advance position marker until we reach a free position
    //in baby2
    while( (baby2[c2] > -1) && (c2 < mum.size()))
    {
      ++c2;
    }
    
    //baby2 gets the next city from mum which is not already
    //present
    if ( (!TestNumber(baby2, mum[pos])) )
    {
      baby2[c2] = mum[pos]; 
    }

    //now do the same for baby1
    while((baby1[c1] > -1) && (c1 < mum.size()))
    {      
      ++c1;
    }
    
    //baby1 gets the next city from dad which is not already
    //present
    if ( (!TestNumber(baby1, dad[pos])) )
    {
      baby1[c1] = dad[pos];
    }     
  }
}
//--------------------- Crossover ----------------------------------------
//
//  simple switch statement to perform crossover based on the selected
//  CrossoverType, type
//------------------------------------------------------------------------
void CgaTSP::Crossover(const vector<int>	&mum, 
							         const vector<int>	&dad, 
							         vector<int>        &baby1, 
							         vector<int>        &baby2,
                       CrossoverType      type)
{
  //perform crossover based on type
  switch(type)
  {
  case OBX:

    CrossoverOBX(mum, dad, baby1, baby2);

    break;

  case PMX:

    CrossoverPMX(mum, dad, baby1, baby2);

    break;

  case PBX:

    CrossoverPBX(mum, dad, baby1, baby2);

    break;


  default: break;

  }//end switch
}

//-----------------------CreateStartingPopulation()------------------------
//
//	clears any existing population, fills a vector with a random population
//	of genomes and resets appropriate member variables
//-------------------------------------------------------------------------
void CgaTSP::CreateStartingPopulation()
{
	//make sure the vector of genomes is empty before we
	//start
	m_vecPopulation.clear();
	
	//create a new population of random genomes
	for (int i=0; i<m_iPopSize; ++i)
	{
		m_vecPopulation.push_back(SGenome(m_iChromoLength));
	}

	//make sure variables are initialised correctly
	m_iGeneration	        = 0;
	m_dShortestRoute      = 9999999;
	m_dBestFitness	      = 0;
	m_dWorstFitness       = 9999999;
	m_dAverageFitness     = 0;
	m_iFittestGenome      = 0;
	m_bStarted			      = false;
  m_dBoltzmannTemp      = NUM_CITIES * 2;

}
//-----------------------------------Run-----------------------------------
//
//	This is the function that initializes a new population and sets the
//  ga running 
//------------------------------------------------------------------------
void CgaTSP::Run(HWND hwnd)
{
	//The first thing we have to do is create a random population
	//of genomes
	CreateStartingPopulation();

	m_bStarted = true;

}
//-------------------------Reset()------------------------------
//
//	resets all the relevant variables ready for a new generation
//--------------------------------------------------------------
void CgaTSP::Reset()
{
	//just make the shortest route some excessively large distance
	m_dShortestRoute	= 999999999;
	m_dLongestRoute		= 0;
	m_dTotalFitness		= 0;
	m_dBestFitness		= 0;
	m_dWorstFitness		= 9999999;
	m_dAverageFitness	= 0;
	m_bSorted			    = false;
  m_dSigma          = 1;
}

//------------------------Epoch-------------------------------
//
//	creates a new population of genomes using the selection,
//	mutation and crossover operators
//------------------------------------------------------------
void CgaTSP::Epoch()
{

	//first we reset variables and calculate the fitness of each genome
	Reset();
	
	CalculatePopulationsFitness();

	//if we have found a solution exit
	if ((m_dShortestRoute <= m_pMap->BestPossibleRoute()))
	{
		m_bStarted = false;
		
		return;
	}	

  //perform the appropriate fitness scaling
  FitnessScaleSwitch();

  //if sigma is zero (either set in sigma scaling or in CalculateBestWorstAv
  //then the population are identical and we should stop the run
  if (m_dSigma == 0)
  {
    m_bStarted = false;

    return;
  }
	
	//create a temporary vector for the new population
	vector<SGenome> vecNewPop;
	
  if (m_bElitism)
  {
	  //Now to add a little elitism we shall add in some copies of the
	  //fittest genomes
	  const int CopiesToAdd = 2;
	  const int NBest		  = 4;
	  
	  //make sure we add an EVEN number or the roulette wheel
	  //sampling will crash
	  if (!(CopiesToAdd * NBest % 2))
	  {
		  GrabNBest(NBest, CopiesToAdd, vecNewPop);
	  }
  }

  //SUS selection selects the entire population all at once so we have to
  //handle the epoch slightly differently if SUS is chosen
  if(m_SelectionType != SUS)
  {
	  //now create the remainder of the population
	  while (vecNewPop.size() != m_iPopSize)
	  {
	  
		  SGenome mum, dad;
    
      //switch on selection method
      switch(m_SelectionType)
      {
      case ROULETTE:
  
        //grab two parents dependent on the selection method
		    mum = RouletteWheelSelection();
		    dad = RouletteWheelSelection();

        break;

      case TOURNAMENT:

        mum = TournamentSelection(NUM_TO_COMPARE);
	      dad = TournamentSelection(NUM_TO_COMPARE);

        break;

      case ALT_TOURNAMENT:
 
        mum = AlternativeTournamentSelection();
	      dad = AlternativeTournamentSelection();

        break;
      }

		  //create 2 children
		  SGenome baby1, baby2;
		  
		  //Breed them
      Crossover(mum.vecCities,
                dad.vecCities,
                baby1.vecCities,
                baby2.vecCities,
                m_CrossoverType);

		  //and mutate them
		  Mutate(baby1.vecCities, m_MutationType);
		  Mutate(baby2.vecCities, m_MutationType);

		  //add them to new population
		  vecNewPop.push_back(baby1);
		  vecNewPop.push_back(baby2);
	  }
  }

  //SUS selection
  else
  {
    //select all the individuals
    vector<SGenome> vecSampledPop;

    SUSSelection(vecSampledPop);

    //step through the newly sampled population and apply crossover
    //and mutation operators
    for (int gen=0; gen<vecSampledPop.size(); gen+=2)
    {
      SGenome baby1, baby2;
      
      Crossover(vecSampledPop[gen].vecCities,
                vecSampledPop[gen+1].vecCities,
                baby1.vecCities,
                baby2.vecCities,
                m_CrossoverType);

      Mutate(baby1.vecCities, m_MutationType);
      Mutate(baby2.vecCities, m_MutationType);

      vecNewPop.push_back(baby1);
      vecNewPop.push_back(baby2);      

    }
   
  }

	//copy into next generation
	m_vecPopulation = vecNewPop;

	//increment generation counter
	++m_iGeneration;
}

//-------------------------------Render-------------------------------
//
//	This function does all the drawing and textual output. Called from
// the winproc when it receives a WM_PAINT msg
//--------------------------------------------------------------------
void CgaTSP::Render(HDC surface, int cx, int cy)const
{

		//draw all the cities
	for (int city_num = 0; city_num < m_pMap->m_vecCityCoOrds.size(); ++city_num)
	{
		int x = (int)m_pMap->m_vecCityCoOrds[city_num].x;
		int y = (int)m_pMap->m_vecCityCoOrds[city_num].y;
		
		Ellipse(surface, x-CITY_SIZE, y+CITY_SIZE, x+CITY_SIZE, y-CITY_SIZE);
	}
	
	//draw the fittest route so far
	vector<int> route = m_vecPopulation[m_iFittestGenome].vecCities;
	
	//only display the routes if we are in a run
	if (m_iGeneration != 0)
	{ 
		MoveToEx(surface, (int)m_pMap->m_vecCityCoOrds[route[0]].x, (int)m_pMap->m_vecCityCoOrds[route[0]].y, NULL);
		
		for (int i=1; i<route.size(); ++i)
		{
			int CityX = (int)m_pMap->m_vecCityCoOrds[route[i]].x;
			int CityY = (int)m_pMap->m_vecCityCoOrds[route[i]].y;
			
			LineTo(surface, CityX, CityY);
			
			//draw the numbers representing the order the cities are visited.
			//No point drawing them after about a 100 cities as the display
			//just becomes confused
			if (NUM_CITIES < 100)
			{
				string CityNumber = itos(i);
			
				TextOut(surface, CityX, CityY, CityNumber.c_str(), CityNumber.size());
			}
		}

		//now draw the line from the last city visited back to the starting point
		LineTo(surface, (int)m_pMap->m_vecCityCoOrds[route[0]].x, (int)m_pMap->m_vecCityCoOrds[route[0]].y);
	}	
	
	//print stats
	string sGen = itos(m_iGeneration);
	sGen = "Generation: " + sGen;
	TextOut(surface, 5, cy - 20, sGen.c_str(), sGen.size());


	if (!m_bStarted)
	{
		string Start = "Press Return to start a new run";

		TextOut(surface, cx/2 - (Start.size() * 3), cy - 20, Start.c_str(), Start.size());

    if (m_dSigma == 0)
    {
      string s = "Premature Convergence!";

      TextOut(surface, cx-40 - (Start.size() * 3), cy-20, s.c_str(), s.size());
    }
	}

	else

	{
		string Start = "Space to stop";
		
		TextOut(surface, cx/2 - (Start.size() * 3), cy - 20, Start.c_str(), Start.size());
	}	

 

  //render the current Boltzmann temperature if applicable
  if (m_ScaleType == BOLTZMANN)
  {
    string s = "Boltzmann Temp: " + ftos(m_dBoltzmannTemp);
    TextOut(surface, 400, 5, s.c_str(), s.size());
  }
    
}


?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩国产在线一| 日本一区二区三区在线观看| 成人美女视频在线看| 国产原创一区二区| 久久精品国产网站| 国产精品主播直播| 国产不卡一区视频| 波多野结衣亚洲| 91亚洲男人天堂| 欧美色视频在线观看| 在线播放91灌醉迷j高跟美女 | 欧美一级生活片| 日韩欧美国产一二三区| 久久久噜噜噜久久中文字幕色伊伊| 欧美xxx久久| 国产情人综合久久777777| 国产精品精品国产色婷婷| 一区av在线播放| 久久成人羞羞网站| 成人18视频在线播放| 色88888久久久久久影院按摩| 精品视频一区二区三区免费| 日韩欧美一级二级| 亚洲欧美综合网| 日韩主播视频在线| 国产一区二区三区黄视频| 91麻豆蜜桃一区二区三区| 欧美电影在线免费观看| 久久亚洲综合av| 一区二区三区91| 久久91精品国产91久久小草| 国产成人在线免费观看| 欧美日韩在线综合| 国产日韩精品视频一区| 午夜精品成人在线| gogo大胆日本视频一区| 欧美一三区三区四区免费在线看 | 亚洲欧洲韩国日本视频| 日日夜夜精品视频免费| thepron国产精品| 日韩美女视频在线| 亚洲综合一区在线| 国产成人综合网| 欧美一级免费观看| 一区二区成人在线视频| 国产激情精品久久久第一区二区| 色婷婷国产精品综合在线观看| 久久综合久久综合九色| 亚洲国产精品一区二区尤物区| 国产精品一区二区久久精品爱涩 | 裸体健美xxxx欧美裸体表演| 99综合影院在线| 久久亚洲欧美国产精品乐播| 亚洲综合免费观看高清完整版在线| 黄页网站大全一区二区| 在线不卡中文字幕| 亚洲成人自拍网| 色综合一区二区三区| 久久久久久97三级| 久久成人18免费观看| 欧美精品一二三| 亚洲国产一区二区视频| 91麻豆免费视频| 国产精品三级av在线播放| 精品无人码麻豆乱码1区2区| 91麻豆精品国产无毒不卡在线观看| 亚洲欧美色一区| 97se亚洲国产综合在线| 国产精品免费久久| 成人一区二区三区视频在线观看 | 亚洲欧美日韩中文播放| av在线不卡网| 中文字幕在线不卡一区二区三区| 国产成人aaa| 国产色综合一区| 国产91丝袜在线播放0| 国产日韩欧美一区二区三区综合| 国产一区二区女| 久久久国产精华| 丁香天五香天堂综合| 国产精品乱码久久久久久| 成人伦理片在线| 中文字幕一区二区在线播放| 99re热这里只有精品免费视频| 中文字幕亚洲视频| 欧洲国产伦久久久久久久| 亚洲最大成人网4388xx| 欧美日韩精品免费| 免费观看一级欧美片| 日韩欧美国产一区二区在线播放| 激情六月婷婷久久| 国产精品三级视频| 99re这里都是精品| 一区二区三区在线免费视频| 欧美视频精品在线观看| 久久国产日韩欧美精品| 欧美激情中文不卡| 欧美性色欧美a在线播放| 日本欧美肥老太交大片| 国产欧美日韩精品在线| 在线观看欧美精品| 麻豆精品新av中文字幕| 国产精品女同互慰在线看| 在线免费观看日本一区| 久久精品国产免费看久久精品| 日本一区二区三区dvd视频在线| 91在线精品一区二区三区| 肉丝袜脚交视频一区二区| 国产亚洲欧美一区在线观看| 欧美综合一区二区| 精品一区二区三区不卡| 亚洲欧美日韩国产成人精品影院 | 一区二区三区高清| 欧美tickling挠脚心丨vk| 91在线观看免费视频| 免费的国产精品| 夜夜爽夜夜爽精品视频| 久久久久综合网| 欧美久久久久中文字幕| 成人一区在线观看| 视频一区国产视频| 亚洲品质自拍视频| 欧美国产乱子伦| 欧美电影免费观看完整版| 欧美午夜精品理论片a级按摩| 国产美女视频一区| 石原莉奈一区二区三区在线观看| 中文av一区二区| 久久久久久久久蜜桃| 91精品国产麻豆国产自产在线 | 欧美不卡123| 在线观看日韩国产| 99视频在线精品| 粉嫩久久99精品久久久久久夜| 免费xxxx性欧美18vr| 午夜视频一区在线观看| 亚洲图片一区二区| 亚洲欧美另类小说| 亚洲欧洲精品一区二区三区不卡| 国产清纯白嫩初高生在线观看91| 日韩一级片在线观看| 777xxx欧美| 欧美一区二区三区四区高清| 欧美色区777第一页| 在线观看亚洲a| 色综合婷婷久久| 一本久久综合亚洲鲁鲁五月天 | 欧美亚洲国产bt| 99精品视频免费在线观看| 国产制服丝袜一区| 精品亚洲免费视频| 狠狠网亚洲精品| 国产一区二区三区黄视频 | 亚洲va韩国va欧美va精品| 亚洲欧美激情视频在线观看一区二区三区| 久久久影视传媒| 久久青草欧美一区二区三区| 欧美大片一区二区| 久久久久久久性| 亚洲国产精品黑人久久久| 中文字幕不卡三区| 亚洲色图19p| 亚洲二区视频在线| 免费日本视频一区| 国内精品自线一区二区三区视频| 国产一本一道久久香蕉| 风间由美性色一区二区三区| 成人自拍视频在线观看| 在线看国产一区二区| 91麻豆精品国产91久久久资源速度| 5858s免费视频成人| 久久久噜噜噜久噜久久综合| 国产精品理论在线观看| 一区二区激情视频| 美国毛片一区二区| 成人少妇影院yyyy| 91久久精品一区二区| 91精品国产综合久久精品性色| 精品国产亚洲一区二区三区在线观看| 久久这里只有精品6| 中文字幕一区在线| 热久久免费视频| av一区二区不卡| 欧美精品在欧美一区二区少妇| 久久久久99精品国产片| 亚洲免费观看高清完整| 美女性感视频久久| 91影视在线播放| 欧美成人官网二区| 亚洲少妇30p| 狠狠色丁香婷婷综合久久片| 本田岬高潮一区二区三区| 91精品午夜视频| 亚洲天堂福利av| 狠狠色丁香婷婷综合| 欧美精品色一区二区三区| 中文一区在线播放| 毛片一区二区三区| 欧美丝袜丝交足nylons| 中文字幕精品一区|