展会信息港展会大全

基本蚁群算法的C++源程序
来源:互联网   发布日期:2011-08-29 21:57:27   浏览:8792次  

导读:终于弄明白了傅里叶变换基本蚁群算法的C++源程序开始看蚁群聚类 博客 博客中国 博客动力 blog blogdriver blogger 中国...
FashionXu的博客

终于弄明白了傅里叶变换- -| 回首页 | 2006年索引 | - -开始看蚁群聚类

基本蚁群算法的C++源程序关键词: 蚁群算法    C++源程序    ACS                                           //基本蚁群算法程序

//程序在vc++6.0下面同过,对原来的做了一点修改。
//你可以使用本代码,如果感到对你有用的话,请通知作者,作者会很高兴。
//通讯地址:fashionxu@163.com
//by FashionXu
#include "stdafx.h"
#include
#include
#include
#include

using namespace std;


const int iAntCount=34;//蚂蚁数量
const int iCityCount=51;//城市数量
const int iItCount=2000;//最大跌代次数
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)//获得随机数
{

 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++)

赞助本站

人工智能实验室
相关内容
AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港