• 大小: 5KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-07
  • 语言: 其他
  • 标签: 蚁群算法  

资源简介

蚁群算法单路径和多路径路由 31节点网络拓扑下寻找单个最短路径和前三条最短路径

资源截图

代码片段和文件信息

function []=MultiRoutes()
%%-------------------------------------------------------------------------
%% 主要符号说明
%% C n个节点的坐标,n×2的矩阵
%% NC_max 最大迭代次数
%% m 蚂蚁代理个数
%% Alpha 表征信息素重要程度的参数
%% Beta 表征启发式因子重要程度的参数
%% Rho 信息素蒸发系数
%% Q 信息素增加强度系数
%% R_best 各代最佳路线
%% L_best 各代最佳路线的长度
%%=========================================================================
clc
clear
% 设置初始参数如下:
m=30;Alpha=2;Beta=0.5;Rho=0.05;NC_max=100;Q=0.02;
%设定源目的节点
s=1;e=14;n=14;
% 网络拓扑为:
D=[  0        2100     3000        Inf         Inf         Inf         Inf         4800        Inf    Inf         Inf         Inf         Inf         Inf
     2100     0        1200        1500         Inf        Inf         Inf         Inf         Inf    Inf         Inf         Inf         Inf         Inf
     3000     1200     0           Inf         Inf         3600        Inf         Inf         Inf    Inf         Inf         Inf         Inf         Inf
     Inf      1500     Inf         0           1200        Inf         Inf         Inf         Inf    Inf        3900         Inf         Inf         Inf
     Inf      Inf      Inf         1200           0        2400        1200        Inf         Inf    Inf         Inf         Inf         Inf         Inf
     Inf      Inf      3600        Inf        2400         0           Inf         Inf         Inf    2100         Inf         Inf         Inf        3600
     Inf      Inf      Inf         Inf        1200         Inf           0         1500        Inf    2700         Inf         Inf         Inf         Inf
     4800     Inf      Inf         Inf         Inf         Inf         1500        0           1500   Inf         Inf         Inf         Inf         Inf
     Inf      Inf      Inf         Inf         Inf         Inf         Inf         1500        0      1500         Inf         600         600         Inf
     Inf      Inf      Inf         Inf         Inf         2100        2700        Inf         1500   0           Inf         Inf         Inf         Inf
     Inf      Inf      Inf         3900        Inf         Inf         Inf         Inf         Inf    Inf           0        1200        1500         Inf
     Inf      Inf      Inf         Inf         Inf         Inf         Inf         Inf         600    Inf        1200           0         Inf         600
     Inf      Inf      Inf         Inf         Inf         Inf         Inf         Inf         600    Inf        1500         Inf           0         300
     Inf      Inf      Inf         Inf         Inf        3600         Inf         Inf         Inf    Inf         Inf         600         300           0];
C=[ 10  80
    0   60
    10  30
    30  50 
    40  40
    50  10 
    60  50
    70  60
    100 75
    80  0
    110 130
    135 120
    140 100
    130 40];
%初始化变量
Eta=zeros(nn);
for k = 1:n
    for t = 1:n
        if D(kt)~=0
           Eta(kt)=1/D(kt);
        else Eta(kt)=0;
        end
    end
end        %Eta为启发因子,

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       7145  2011-11-09 19:21  single.m

     文件       8767  2011-11-08 21:30  MultiRoutes.m

----------- ---------  ---------- -----  ----

                15912                    2


评论

共有 条评论