91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

研究生課程之一,完整的智能優化算法相關代碼和介紹講義,包括期末考試的往年試題,將考試時用的資料都整理好了。

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?
#include?
#include?
#include?
using?namespace?std;

#define?N?69 //城市數量
#define?M?50 //螞蟻數量

int?AntCount =?M; //?螞蟻的數量
int?MAXIT =?60; //?最大迭代次數
double?alpha=1beta=5rho=0.5; //?信息素濃度、期望值、揮發系數

int?Q=100; //?每只螞蟻周游一遍留下的信息素總量

double CityPathTao[N][N]; //?初始時刻各邊上的信息素為1
double CityDeltaTao[N][N]; //?記錄信息素

int CityBestRoute[N]; //?記錄最優路徑
double CityBestRouteLength?=?10e9; //?記錄最優路徑長度

int CityAntVisited[N]; //?記錄螞蟻經過城市隊列
double CityDistance[N][N]; //?記錄城市間的距離
bool CityReached[N]; //?記錄城市是否來過
double CityPosition[N][2]; //?城市的坐標坐標矩陣
double CityProbility[N]; //?城市轉移概率

int?AntRoutes[M][N]; //?每只螞蟻的行走路徑記錄

clock_t StartTime; //?開始運行的時間,用于計時
double??ExecuteTime?=?0; //?執行的時間

//////////////////////////////////////////////////////////////////////////
//?返回[low,uper]之間的一個雙精度浮點數隨機數
double?RandomDouble(int?low?double?uper)
{
double?p=(rand()/(double)RAND_MAX)*((uper)-(low))+(low);
return?(p);
};

//////////////////////////////////////////////////////////////////////////
//?返回[0,uper]之間的一個整數隨機數
int?RandomInt(int?uper)
{
return?(rand()%uper);
};

//////////////////////////////////////////////////////////////////////////
//?遞歸計算到達每個城市的轉移概率
//?iCurCity?當前城市
//?iIndex 到達的城市
//?iNum 已經走過的城市
//?dProbSum?所有轉移概率的和
//?dRealSum?所有真實轉移概率之和
void?CaclCityProbility(int?iCurCity?int?iIndex?int&?iNum?
???double&?dProbSum?double&?dRealSum)
{
if((iIndex?=?N))
return;

if(!CityReached[iIndex])
{
double?dProb?=?pow((1.0/CityDistance[iCurCity][iIndex])beta)?
*?pow((CityPathTao[iCurCity][iIndex])alpha);

dProbSum?+=?dProb;

CaclCityProbility(iCurCity?iIndex?+?1?iNum?dProbSum?dRealSum);

CityProbility[iIndex]?=?dProb/dProbSum;

dRealSum?+=?CityProbility[iIndex];

iNum++;
}
else
{
CaclCityProbility(iCurCity?iIndex?+?1?iNum?dProbSum?dRealSum);
}
}

//////////////////////////////////////////////////////////////////////////
//?選擇下一個城市
//?iCurCity?當前城市
int?ChooseNextCity(int?iCurCity)
{
//?所有遍歷中的索引值
int?iIndex?=?0;
//?表示已走過的城市個數
int?iNum?=?0;
//?表示已經選中的城市
int?iChoose?=?10000;
//?所有未走過的城市轉移概率之和
double?dProbSum?=0;
double?dRealSum?=?0;

CaclCityProbility(iCurCity?0?iNum?dProbSum?dRealSum);

//?如果可以去的城市個數超過1個,
//?那么使用輪盤賭法決定下一個城市
if(iNum?>=?1)
{
//?獲取[0,sum]間一隨機數
double?dRate?=?RandomDouble(0?dRealSum);

double?dChoose?=?0;

for(iIndex?=?0;?iIndex? {
if(!CityReached[iIndex])
{
dChoose?+=?CityProbility[iIndex];

//由輪盤賭法選擇下個城市
if(dChoose?>=?dRate)
{
iChoose?=?iIndex;
break;
}
}
}
}

//?如果使用輪盤賭法沒有決定出一個城市,
//?那么直接使用第一個可達的城市
if(iChoose?!=?iIndex)
{
for(iIndex?=?0;?iIndex? {
if(!CityReached[iIndex])
{
iChoose?=?iIndex;
break;
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????3916??2014-04-14?10:43??智能優化算法程序\512041562?吳金徽\a.CPP

?????文件???????3341??2014-04-14?10:43??智能優化算法程序\512041562?吳金徽\a.dsp

?????文件????????510??2014-04-14?10:45??智能優化算法程序\512041562?吳金徽\a.dsw

?????文件??????41984??2014-04-14?10:45??智能優化算法程序\512041562?吳金徽\a.ncb

?????文件??????48640??2014-04-14?10:45??智能優化算法程序\512041562?吳金徽\a.opt

?????文件????????737??2014-04-14?10:43??智能優化算法程序\512041562?吳金徽\a.plg

?????文件???????4347??2013-04-26?09:36??智能優化算法程序\512041562?吳金徽\city.txt

?????文件?????274510??2014-04-14?10:43??智能優化算法程序\512041562?吳金徽\Debug\a.exe

?????文件?????333968??2014-04-14?10:43??智能優化算法程序\512041562?吳金徽\Debug\a.ilk

?????文件??????27925??2014-04-14?10:43??智能優化算法程序\512041562?吳金徽\Debug\a.obj

?????文件?????525312??2014-04-14?10:43??智能優化算法程序\512041562?吳金徽\Debug\a.pdb

?????文件??????50176??2014-04-14?10:43??智能優化算法程序\512041562?吳金徽\Debug\vc60.idb

?????文件??????61440??2014-04-14?10:43??智能優化算法程序\512041562?吳金徽\Debug\vc60.pdb

?????文件???????5160??2014-04-14?10:43??智能優化算法程序\512041562?吳金徽\input.txt

?????文件??????16115??2014-04-14?10:44??智能優化算法程序\512041562?吳金徽\結果.txt

?????文件??????10278??2012-04-10?09:56??智能優化算法程序\acoa.cpp

?????文件???????4919??2012-04-10?09:56??智能優化算法程序\ant1.cpp

?????文件???????4249??2012-04-10?09:56??智能優化算法程序\TSP?城市名\ant\ant.dsp

?????文件????????514??2012-04-10?09:56??智能優化算法程序\TSP?城市名\ant\ant.dsw

?????文件??????41984??2012-04-10?09:56??智能優化算法程序\TSP?城市名\ant\ant.ncb

?????文件??????48640??2012-04-10?09:56??智能優化算法程序\TSP?城市名\ant\ant.opt

?????文件???????1315??2012-04-10?09:56??智能優化算法程序\TSP?城市名\ant\ant.plg

?????文件????????451??2012-04-10?09:56??智能優化算法程序\TSP?城市名\ant\data.txt

?????文件?????274478??2012-04-10?09:56??智能優化算法程序\TSP?城市名\ant\Debug\ant.exe

?????文件??????26616??2012-04-10?09:56??智能優化算法程序\TSP?城市名\ant\Debug\ant.obj

?????文件?????640000??2012-04-10?09:56??智能優化算法程序\TSP?城市名\ant\Debug\ant.pdb

?????文件??????61440??2012-04-10?09:56??智能優化算法程序\TSP?城市名\ant\Debug\vc60.pdb

?????文件????????314??2012-04-10?09:56??智能優化算法程序\TSP?城市名\ant\save.txt

?????文件????????477??2012-04-10?09:56??智能優化算法程序\TSP?城市名\ant\復件?data.txt

?????文件???????5896??2012-04-10?09:56??智能優化算法程序\TSP?城市名\ant.cpp

............此處省略958個文件信息

評論

共有 條評論