蚁群算法c++.rar

  • liang886
    了解作者
  • C/C++
    开发工具
  • 19KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 10 积分
    下载积分
  • 3
    下载次数
  • 2020-09-11 08:31
    上传日期
蚁群算法的c++源程序,修改部分数值可以直接使用
蚁群算法c++.rar
  • 蚁群算法c++.docx
    22.5KB
内容介绍
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta name="generator" content="pdf2htmlEX"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css"> <link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css"> <link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/6267045f4f8811599ec6813e/raw.css"> <script src="https://static.pudn.com/base/js/compatibility.min.js"></script> <script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script> <script> try{ pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({}); }catch(e){} </script> <title></title> </head> <body> <div id="sidebar" style="display: none"> <div id="outline"> </div> </div> <div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/6267045f4f8811599ec6813e/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">#include&lt;bits/stdc++.h&gt;</div><div class="t m0 x1 h3 y3 ff1 fs0 fc0 sc0 ls0 ws0">using namespace std;</div><div class="t m0 x1 h3 y4 ff1 fs0 fc0 sc0 ls0 ws0">// const</div><div class="t m0 x1 h3 y5 ff1 fs0 fc0 sc0 ls0 ws0">const int INF = 0x3f3f3f3f;</div><div class="t m0 x1 h3 y6 ff1 fs0 fc0 sc0 ls0 ws0">#de!ne sqr(x) ((x)*(x))</div><div class="t m0 x1 h3 y7 ff1 fs0 fc0 sc0 ls0 ws0">#de!ne eps 1e-8</div><div class="t m0 x1 h3 y8 ff1 fs0 fc0 sc0 ls0 ws0">//variables</div><div class="t m0 x1 h3 y9 ff1 fs0 fc0 sc0 ls0 ws0">string !le_name;</div><div class="t m0 x1 h4 ya ff1 fs0 fc0 sc0 ls0 ws0">int type;// type == 1 <span class="_ _0"></span><span class="ff2">&#20840;&#30697;&#38453;</span>, type == 2 <span class="ff2">&#20108;&#32500;&#27431;&#25289;&#36317;&#31163; </span></div><div class="t m0 x1 h4 yb ff1 fs0 fc0 sc0 ls0 ws0">int N;//<span class="ff2">&#22478;&#24066;&#25968;&#37327; </span></div><div class="t m0 x1 h4 yc ff1 fs0 fc0 sc0 ls0 ws0">double **dis;//<span class="ff2">&#22478;&#24066;&#38388;&#36317;&#31163; </span></div><div class="t m0 x1 h4 yd ff1 fs0 fc0 sc0 ls0 ws0">double **pheromone;//<span class="ff2">&#20449;&#24687;&#32032; </span></div><div class="t m0 x1 h4 ye ff1 fs0 fc0 sc0 ls0 ws0">double **herustic;//<span class="ff2">&#21551;&#21457;&#24335;&#20540; </span></div><div class="t m0 x1 h3 yf ff1 fs0 fc0 sc0 ls0 ws0">double **info;// info = pheromone ^ delta<span class="_ _0"></span> * herustic ^ beta </div><div class="t m0 x1 h4 y10 ff1 fs0 fc0 sc0 ls0 ws0">double pheromone_0;//pheromone<span class="_ _1"> </span><span class="ff2">&#21021;&#22987;&#20540;&#65292;&#36825;&#37324;&#26159;<span class="_ _1"> </span></span>1 / (avg * N)<span class="ff2">&#20854;&#20013;</span></div><div class="t m0 x1 h4 y11 ff1 fs0 fc0 sc0 ls0 ws0">avg<span class="_ _1"> </span><span class="ff2">&#20026;&#22270;&#32593;&#20013;&#25152;&#26377;&#36793;&#36793;&#26435;&#30340;&#24179;&#22343;&#25968;&#12290; </span></div><div class="t m0 x1 h4 y12 ff1 fs0 fc0 sc0 ls0 ws0">int m;//<span class="ff2">&#31181;&#32676;&#25968;&#37327;</span></div><div class="t m0 x1 h4 y13 ff1 fs0 fc0 sc0 ls0 ws0">int delta, beta;//<span class="ff2">&#21442;&#25968; </span></div><div class="t m0 x1 h3 y14 ff1 fs0 fc0 sc0 ls0 ws0">double alpha;</div><div class="t m0 x1 h4 y15 ff1 fs0 fc0 sc0 ls0 ws0">int *r1, *s, *r;//agent k<span class="_ _1"> </span><span class="ff2">&#30340;&#20986;&#21457;&#22478;&#24066;&#65292;&#19979;&#19968;&#20010;&#28857;&#65292;&#24403;&#21069;&#28857;&#12290; </span></div><div class="t m0 x1 h4 y16 ff1 fs0 fc0 sc0 ls0 ws0">int MAX, iteration;//<span class="ff2">&#26368;&#22823;&#36845;&#20195;&#27425;&#25968;&#65292;&#36845;&#20195;&#35745;&#25968;&#21464;&#37327; </span></div><div class="t m0 x1 h3 y17 ff1 fs0 fc0 sc0 ls0 ws0">set&lt;int&gt; empty, *J;</div><div class="t m0 x1 h3 y18 ff1 fs0 fc0 sc0 ls0 ws0">struct vertex{</div><div class="t m0 x1 h4 y19 ff1 fs0 fc0 sc0 ls0 ws0"> <span class="_ _0"></span> double x, y;// <span class="ff2">&#22478;&#24066;&#22352;&#26631; </span></div><div class="t m0 x1 h4 y1a ff1 fs0 fc0 sc0 ls0 ws0"> <span class="_ _0"></span> int id;// <span class="ff2">&#22478;&#24066;&#32534;&#21495; </span></div><div class="t m0 x1 h3 y1b ff1 fs0 fc0 sc0 ls0 ws0"> <span class="_ _0"></span> int input(FILE *fp){</div><div class="t m0 x1 h3 y1c ff1 fs0 fc0 sc0 ls0 ws0"> <span class="_ _0"></span> return fscanf(fp, "%d %lf %lf", &amp;id, <span class="_ _0"></span> <span class="_ _0"></span> &amp;x, </div><div class="t m0 x1 h3 y1d ff1 fs0 fc0 sc0 ls0 ws0">&amp;y);</div><div class="t m0 x1 h3 y1e ff1 fs0 fc0 sc0 ls0 ws0">}</div><div class="t m0 x1 h3 y1f ff1 fs0 fc0 sc0 ls0 ws0">}*node;</div><div class="t m0 x1 h3 y20 ff1 fs0 fc0 sc0 ls0 ws0">typedef pair&lt;int, int&gt; pair_int;</div></div></div><div class="pi" data-data='{"ctm":[1.611850,0.000000,0.000000,1.611850,0.000000,0.000000]}'></div></div> </body> </html>
评论
    相关推荐
    • 蚁群算法.rar
      优化算法 蚁群算法 MATLAB代码实例求解
    • ACO-蚁群算法.zip
      蚁群算法是一种用来寻找优化路径的概率型算法。它由Marco Dorigo于1992年在他的博士论文中提出,其灵感来源于蚂蚁在寻找食物过程中发现路径的行为。 这种算法具有分布计算、信息正反馈和启发式搜索的特征,本质上是...
    • 蚁群算法大全
      比较全的一个蚁群算法,经典蚁群算法,蚁群算法深入.还有一个应用可以直观的了解蚁群算法
    • 蚁群算法.zip
      蚁群算法是一种用来寻找优化路径的概率型算法。这种算法具有分布计算、信息正反馈和启发式搜索的特征,本质上是进化算法中的一种启发式全局优化算法。
    • 蚁群算法
      蚁群算法,寻找所有节点如省会城市的的最短路径
    • 蚁群算法 matlab代码
      蚁群算法的matlab实现,带有注释帮助理解
    • wsm的蚁群算法
      wsm网络蚁群算法源码 MATLAB源码仿真
    • 蚁群算法
      蚁群算法研究路径规划问题,以TSP问题为基础
    • 蚁群算法解决TSP问题
      使用蚁群算法解决TSP问题用来与其它智能优化算法作比较。
    • 蚁群算法.rar
      蚁群算法基于python实现的源代码程序