签到

06月21日
尚未签到

共有回帖数 0

    做月子

    等级:
    什么是 Ant Colony Optimization?
    请看百度百科 http://baike.baidu.com/view/539346.htm

    什么是 TSP 问题(Travelling Salesman Problem,旅行商问题)
    一个旅行商要访问 n 座城市,但是他必须恰好访问每座城市一次,并最终回到出发的城市。城市 A 到城市 B 的旅行费用为 c(A, B),他希望使旅行的总费用尽可能最小。该问题已被证明为 NPC 问题,不太可能有多项式时间内解决的算法。ACO 是求 TSP 问题近似最优解的一种方法。

    下面是用简单的 ACO 求解 TSP 问题的程序:

    #include cfloat
    #include cmath
    #include cstdio
    #include cstdlib
    #include ctime
    #include vector
    using namespace std;

    const int N = 51;
    const int M = 20; //蚂蚁数量
    const int Q = 100;
    const int ALPHA = 1;
    const int BETA = 4;
    const int TIMES = 200; //迭代次数
    const double RHO = 0.3; //信息素的散逸系数
    double dist[N][N], //两座城市间的距离
       pheromone[N][N]; //信息素
    static struct {int id; double x, y; } a[N]; //城市编号及坐标

    楼主 2016-01-08 10:11 回复

共有回帖数 0
  • 回 帖
  • 表情 图片 视频
  • 发表

登录直线网账号

Copyright © 2010~2015 直线网 版权所有,All Rights Reserved.沪ICP备10039589号 意见反馈 | 关于直线 | 版权声明 | 会员须知