【TSP问题】基于蜜蜂算法求解旅行商问题附matlab代码

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法  神经网络预测 雷达通信  无线传感器

信号处理 图像处理 路径规划 元胞自动机 无人机  电力系统

⛄ 内容介绍

旅行商问题(TSP)是经典的 组合优化问题之一.人工蜂群算法是近年来被提出的一种新的智能启发式算法.根据旅行商问题的模型特点,设计蜜蜂算法对算例进行仿真求解.,结果表明:蜜蜂算法可以有效的求解旅行商问题,在收敛速度,计算效率,稳定性方面相对遗传算法具有一定的优势.

⛄ 部分代码

clc;

clear;

close all

%% Bees Algorithm Parameters

MaxIt=1000;              % Maximum Number of Iterations

nScoutBee=25;            % Number of Scout Bees

nEliteSite=4;            % Number of Elite Sites 

nBestSite=20;            % Number of Best Sites 

nEliteSiteBee=300;       % Number of Recruited Bees for Elite Sites

nBestSiteBee=100;        % Number of Recruited Bees for Best Sites

%% Initialization

% Create the map 

[map]=create_tsp_map();

% Empty Bee Structure

empty_bee.A=[];

empty_bee.Cost=[];

e=newbee;

            end

        end

        end

        if bestnewbee.Cost<bee(i).Cost

            bee(i)=bestnewbee;

        end

    end

    

    % Global search

    for i=nBestSite+1:nScoutBee

        bee(i).A=randperm(map.n);

        bee(i).Cost=CF(bee(i).A,map);

    end

  

    % Sort

    [~, SortOrder]=sort([bee.Cost]);

    bee=bee(SortOrder);

   

    % Update Best Solution Ever Found

    BestSol=bee(1);

    

    % Store Best Cost Ever Found

    BestCost(it)=BestSol.Cost;

    

    % Display Iteration Information

    disp(['Iteration ' num2str(it) ': Best Cost = ' num2str(BestCost(it))]);

    

      % online map 

%     colony = [bee(1).A bee(1).A(1)]; 

%     subplot(1,1,1)

%     cla

%     drawBestTour(colony, map);

%     drawnow

    

end

%% Results

       

    % best route map of all iterations

    colony = [bee(1).A bee(1).A(1)]; 

    subplot(1,1,1)

    cla

    drawBestTour(colony, map);

    drawnow

⛄ 运行结果

⛄ 参考文献

[1]黄丽韶, 朱喜基. 基于MATLAB的蚁群算法求解旅行商问题[J]. 无线互联科技, 2012(3):3.

⛄ Matlab代码关注

❤️部分理论引用网络文献,若有侵权联系博主删除

❤️ 关注我领取海量matlab电子书和数学建模资料

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值