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

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

?? 基本蟻群算法程序.txt

?? 這是一個基于基本蟻群算法求解源程序 可以修改循環(huán)次數(shù)和其他參數(shù)
?? TXT
字號:
//基本蟻群算法程序

//程序在vc++6.0下面同過,對原來的做了一點(diǎn)修改。
//你可以使用本代碼,如果感到對你有用的話,請通知作者,作者會很高興。
//通訊地址:fashionxu@163.com
//by FashionXu
#include "stdafx.h"
#include 
#include 
#include 
#include 

using namespace std;


const int iAntCount=34;//螞蟻數(shù)量
const int iCityCount=51;//城市數(shù)量
const int iItCount=2000;//最大跌代次數(shù)
const double Q=100;
const double alpha=1;
const double beta=5;
const double rou=0.5;

int besttour[iCityCount];//最有路徑列表

double  rnd(int low,double uper)//獲得隨機(jī)數(shù)
{

 double p=(rand()/(double)RAND_MAX)*((uper)-(low))+(low);

 return (p);

};


int rnd(int uper)
{
          return (rand()%uper);
};

class GInfo//tsp地圖信息,包含了信息素,城市距離,和信息素變化矩陣
{


public: 
 double m_dDeltTrial[iCityCount][iCityCount];
 double m_dTrial[iCityCount][iCityCount];
 double distance[iCityCount][iCityCount];


};


GInfo Map;


class ant
{


private:


 int ChooseNextCity();//選擇城市
 double prob[iCityCount];
 int m_iCityCount;
 int AllowedCity[iCityCount];//沒有走過的城市


public:


 void addcity(int city);
 int tabu[iCityCount];
 void Clear();
 void UpdateResult();
 double m_dLength;
 double m_dShortest;
 void move();
 ant();
 void move2last();


};
void ant::move2last()
{


 int i;
 for(i=0;i《iCityCount;i++)

  if (AllowedCity[i]==1)
  {
   addcity(i);
   break;
  }


}


void ant::Clear()
{
 m_dLength=0;
 int i;
 for(i=0; i〈iCityCount;i++)

  prob[i]=0;
  AllowedCity[i]=1;
 }
 i=tabu[iCityCount-1];
 m_iCityCount=0;
 addcity(i);
}
ant::ant()
{
 m_dLength=m_dShortest=0;
 m_iCityCount=0;
 int i;
 for(i=0;i〈iCityCount;i++)

  AllowedCity[i]=1;
  prob[i]=0;
 }
}
void ant::addcity(int city)
{
 //add city to tabu;
 tabu[m_iCityCount]=city;
 m_iCityCount++;
 AllowedCity[city]=0;
}
int ant::ChooseNextCity()
{
 //Update the probability of path selection
 //select a path from tabu[m_iCityCount-1] to next


 int i;
 int j=10000;
 double temp=0;
 int curCity=tabu[m_iCityCount-1];
 for (i=0;i〈iCityCount;i++)

  if((AllowedCity[i]==1)) 
  {
   temp+=pow((1.0/Map.distance[curCity][i]),beta)*pow((Map.m_dTrial[curCity][i]),alpha);
  }
 }
 double sel=0;
 for (i=0;i〈iCityCount;i++)

  if((AllowedCity[i]==1))
  {
   prob[i]=pow((1.0/Map.distance[curCity][i]),beta)*pow((Map.m_dTrial[curCity][i]),alpha)/temp;
   sel+=prob[i];
  }
  else 
   prob[i]=0;
 }
 double mRate=rnd(0,sel);
 double mSelect=0;

 for ( i=0;i〈iCityCount;i++)

  if((AllowedCity[i]==1))
   mSelect+=prob[i] ;
  if (mSelect>=mRate) {j=i;break;}
 }

 if (j==10000)
 {
  temp=-1;
  for (i=0;i〈iCityCount;i++)

   if((AllowedCity[i]==1))
    if (temp    {
     temp=pow((1.0/Map.distance[curCity][i]),beta)*pow((Map.m_dTrial[curCity][i]),alpha);
     j=i;
    }
  }
 }

 return j;

}
void ant::UpdateResult()
{
 // Update the length of tour
 int i;
 for(i=0;i〈iCityCount-1;i++)

       m_dLength+=Map.distance[tabu[i]][tabu[i+1]];
 m_dLength+=Map.distance[tabu[iCityCount-1]][tabu[0]];
}
void ant::move()
{
 //the ant move to next town and add town ID to tabu.
 int j;
 j=ChooseNextCity();
 addcity(j);
}
class project
{
public:

 void UpdateTrial();
 double m_dLength;
 void initmap();
 ant ants[iAntCount];
 void GetAnt();
 void StartSearch();
 project();
};
void project::UpdateTrial()
{
 //calculate the changes of trial information
 int i;
 int j;

 for(i=0;i〈iAntCount;i++)
  for (j=0;j〈iCityCount-1;j++)

{   Map.m_dDeltTrial[ants[i].tabu[j]][ants[i].tabu[j+1]]+=Q/ants[i].m_dLength ;
   Map.m_dDeltTrial[ants[i].tabu[j+1]][ants[i].tabu[j]]+=Q/ants[i].m_dLength;
  }
  Map.m_dDeltTrial[ants[i].tabu[iCityCount-1]][ants[i].tabu[0]]+=Q/ants[i].m_dLength;
  Map.m_dDeltTrial[ants[i].tabu[0]][ants[i].tabu[iCityCount-1]]+=Q/ants[i].m_dLength;
 }
 for (i=0;i〈iCityCount;i++)

  for (j=0;j〈iCityCount;j++)

  {
   Map.m_dTrial[i][j]=(rou*Map.m_dTrial[i][j]+Map.m_dDeltTrial[i][j] );
   Map.m_dDeltTrial[i][j]=0;
  }

 }


}
void project::initmap()
{
 int i;
 int j;
 for(i=0;i〈iCityCount;i++)
  for (j=0;j〈iCityCount;j++)
  {


   Map.m_dTrial[i][j]=1;
   Map.m_dDeltTrial[i][j]=0;
  }
}
project::project()
{
 //initial map,read map infomation from file . et.
 initmap();
 m_dLength=10e9;


 ifstream in("eil51.tsp");

 struct city
 {
  int num;
  int x;
  int  y;
 }cc[iCityCount];
 
 for (int i=0;i〈iCityCount;i++)
 {
  in>>cc[i].num>>cc[i].x>>cc[i].y;
  besttour[i]=0;
 }
 int j;
 for(i=0;i〈iCityCount;i++)
  for (j=0;j〈iCityCount;j++)
  {

   {
    Map.distance[i][j]=sqrt(pow((cc[i].x-cc[j].x),2)+pow((cc[i].y-cc[j].y),2));
   }
  }


}
void project::GetAnt()
{
 //randomly put ant into map
 int i=0;
 int city;
 srand( (unsigned)time( NULL ) +rand());
for (i=0;i〈iAntCount;i++)

 {
  city=rnd(iCityCount);
  ants[i].addcity(city);
 }

}
void project::StartSearch()
{
 //begin to find best solution
 int max=0;//every ant tours times
 int i;
 int j;
 double temp;
 int temptour[iCityCount];
 while ((max〈iItCount)

{  
  for(j=0;j〈iAntCount;j++) 

  { 
   for (i=0;i〈iCityCount-1;i++)

  ants[j].move();
  }

   for(j=0;j〈iAntCount;j++) 
  {   ants[j].move2last();
   ants[j].UpdateResult ();
  }

  //find out the best solution of the step and put it into temp
  int t;
  temp=ants[0].m_dLength;
  for (t=0;t〈iCityCount;t++)
   temptour[t]=ants[0].tabu[t];
  for(j=0;j〈iAntCount;j++) 
  {
   if (temp〉ants[j].m_dLength) {
    temp=ants[j].m_dLength;
    for ( t=0;t〈iCityCount;t++)
     temptour[t]=ants[j].tabu[t];
   }
  }

  if(temp〈m_dLength){
   m_dLength=temp;
   for ( t=0;t〈iCityCount;t++)
    besttour[t]=temptour[t];
  }
  printf("%d : %f\n",max,m_dLength);
  UpdateTrial(); 

  for(j=0;j〈iAntCount;j++) 
   ants[j].Clear();



  max++;

 }
 printf("The shortest toure is : %f\n",m_dLength);

 for ( int t=0;t〈iCityCount;t++)
  printf(" %d ",besttour[t]);

}
int main()
{

 project TSP;
 TSP.GetAnt();
 TSP.StartSearch();
 return 0;
}

求eil51最優(yōu)到了438,可以修改循環(huán)次數(shù)和其他參數(shù)。以得到更好的解。使用TSP數(shù)據(jù)的時候,將前面的一些字符串信息刪除,只留下坐標(biāo)數(shù)據(jù)。

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久噜噜噜久久中文字幕色伊伊| 色琪琪一区二区三区亚洲区| 欧美一区二区三区电影| 奇米影视一区二区三区小说| 欧美精品第1页| 奇米四色…亚洲| 欧美成人精品3d动漫h| 激情小说亚洲一区| 国产日韩欧美精品一区| 99久久免费精品高清特色大片| 亚洲人精品午夜| 欧美日韩中文字幕一区| 天天综合网 天天综合色| 日韩免费视频线观看| 国产 日韩 欧美大片| 自拍偷自拍亚洲精品播放| 欧美天堂亚洲电影院在线播放| 美女一区二区久久| 亚洲国产高清aⅴ视频| 91在线观看免费视频| 亚洲国产另类av| 精品国产区一区| 波多野结衣视频一区| 亚洲高清不卡在线| 久久蜜桃av一区精品变态类天堂 | 制服.丝袜.亚洲.另类.中文| 免费不卡在线观看| 欧美激情一区二区三区蜜桃视频| 99re视频这里只有精品| 日日夜夜免费精品| 久久久国产精品不卡| 欧美视频一区在线观看| 国产一区二区三区观看| 一区二区三区在线观看国产| 精品少妇一区二区三区日产乱码 | 99久久综合精品| 亚洲一区二区3| 国产日韩欧美在线一区| 91精选在线观看| 99久久精品国产毛片| 精品一区二区三区在线视频| 亚洲女性喷水在线观看一区| 久久综合国产精品| 欧美精品在线一区二区三区| 成人国产精品免费网站| 免费视频一区二区| 一区二区三区**美女毛片| 久久久亚洲精华液精华液精华液| 91国偷自产一区二区开放时间| 狠狠色狠狠色综合日日91app| 亚洲一区二区三区四区不卡| 国产亚洲精品7777| 日韩精品在线看片z| 欧美午夜精品久久久久久超碰| 国产suv精品一区二区6| 美女在线视频一区| 日韩精品乱码免费| 亚洲女厕所小便bbb| 国产欧美精品在线观看| 精品国产伦理网| 日韩一区二区高清| 欧美蜜桃一区二区三区| 在线免费不卡电影| 97久久精品人人爽人人爽蜜臀 | 国产欧美一区二区三区鸳鸯浴 | 亚洲视频一二三区| 国产欧美日韩综合精品一区二区| 欧美一区二区三区视频在线观看| 91福利社在线观看| 91极品视觉盛宴| 色狠狠桃花综合| 色综合久久久久久久久| 99久久精品国产毛片| 99久久精品免费| av一区二区三区四区| 成人黄色在线看| 成人网页在线观看| 成人伦理片在线| 成人av片在线观看| aaa欧美日韩| 91麻豆国产香蕉久久精品| 99精品久久99久久久久| 99riav一区二区三区| 色婷婷综合久久| 欧美三级日韩三级国产三级| 欧美在线播放高清精品| 欧美午夜在线观看| 欧美疯狂做受xxxx富婆| 欧美久久婷婷综合色| 制服丝袜日韩国产| 日韩欧美国产一区二区在线播放| 亚洲一区二区精品3399| 日日夜夜一区二区| 美腿丝袜亚洲综合| 韩国毛片一区二区三区| 国产成人精品aa毛片| 不卡一区二区三区四区| 99re在线视频这里只有精品| 欧美亚洲愉拍一区二区| 7777精品伊人久久久大香线蕉经典版下载 | 国产在线精品一区二区夜色 | 亚洲精品亚洲人成人网在线播放| 亚洲丝袜制服诱惑| 亚洲高清视频在线| 国模套图日韩精品一区二区| 国产成人免费视频一区| 色综合久久综合网欧美综合网| 欧美剧在线免费观看网站| 欧美videos大乳护士334| 国产亚洲欧美中文| 一区二区免费在线| 国产综合一区二区| 91丨九色丨尤物| 欧美精品久久天天躁| 久久久综合九色合综国产精品| 亚洲少妇屁股交4| 青椒成人免费视频| 9i看片成人免费高清| 欧美精品九九99久久| 国产精品日韩精品欧美在线| 亚洲制服丝袜一区| 国产成人av电影在线播放| 精品婷婷伊人一区三区三| 久久久久久久久久美女| 亚洲成人动漫一区| 国产盗摄一区二区三区| 欧美日韩高清影院| 国产精品嫩草影院com| 三级欧美韩日大片在线看| www.日韩精品| 精品成人佐山爱一区二区| 亚洲精品福利视频网站| 国产伦精品一区二区三区视频青涩 | 国产成人啪午夜精品网站男同| 在线一区二区三区四区五区 | 精品一区二区国语对白| 91丨porny丨首页| 精品成人在线观看| 日韩精品电影在线| 99精品国产99久久久久久白柏| 精品国精品国产| 亚洲图片欧美综合| 97成人超碰视| 国产丝袜欧美中文另类| 秋霞午夜av一区二区三区| 日本电影欧美片| 亚洲欧洲精品一区二区精品久久久 | 亚洲香肠在线观看| www.亚洲激情.com| 日本一区二区三区四区| 免费在线欧美视频| 欧美日韩电影在线| 亚洲国产成人高清精品| 色国产综合视频| 日韩久久一区二区| 成人黄色在线视频| 国产欧美一区二区三区在线看蜜臀 | 精品福利二区三区| 免费在线成人网| 欧美一区二区三区四区在线观看 | 欧美精品一区二区三区久久久| 亚洲国产日日夜夜| 欧美亚一区二区| 亚洲综合成人在线| 91九色最新地址| 亚洲午夜国产一区99re久久| 日本韩国精品在线| 一区二区久久久久久| 欧美在线视频日韩| 亚洲国产欧美在线| 欧美日韩国产一区二区三区地区| 亚洲最大的成人av| 欧美性猛交一区二区三区精品| 樱花草国产18久久久久| 欧美伊人精品成人久久综合97| 亚洲亚洲精品在线观看| 欧美日韩日日骚| 美女免费视频一区| 久久综合色综合88| 懂色av中文字幕一区二区三区| 中文乱码免费一区二区 | 91成人看片片| 午夜精品国产更新| 日韩免费性生活视频播放| 激情综合五月婷婷| 中文字幕第一区综合| 一本久久a久久免费精品不卡| 亚洲一区二区成人在线观看| 欧美精品一二三| 久久er精品视频| 国产精品视频yy9299一区| 欧美在线你懂得| 麻豆精品视频在线| 国产精品美女久久久久av爽李琼| 99精品一区二区| 日本欧美在线看| 国产丝袜欧美中文另类| 日本电影亚洲天堂一区| 裸体歌舞表演一区二区| 中文一区在线播放|