模拟退火算法及禁忌搜索算法的matlab源程序
启发式算法中模拟退火算法和禁忌搜索算法的matlab源程序,这两种算法在网上要想找到源程序非常困难
%%% 模拟退火算法源程序
% 此题以中国31省会城市的最短旅行路径为例:
% clear;clc;
function [MinD,BestPath]=MainAneal(pn)
% CityPosition存储的为每个城市的二维坐标x和y;
CityPosition=[1304 2312;3639 1315;4177 2244;3712 1399;3488 1535;3326 1556;3238 1229;... 4196 1044;4312 790;4386 570;3007 1970;2562 1756;2788 1491;2381 1676;...
1332 695;3715 1678;3918 2179;4061 2370;3780 2212;3676 2578;4029 2838;...
4263 2931;3429 1908;3507 2376;3394 2643;3439 3201;2935 3240;3140 3550;...
2545 2357;2778 2826;2370 2975];
figure(1);
plot(CityPosition(:,1),CityPosition(:,2),'o')
m=size(CityPosition,1);%城市的数目
%
D = sqrt((CityPosition(:,ones(1,m)) - CityPosition(:,ones(1,m))').^2 + ...
(CityPosition(:,2*ones(1,m)) - CityPosition(:,2*ones(1,m))').^2);
path=zeros(pn,m);
for i=1:pn
path(i,:)=randperm(m);
end
iter_max=100;%i
m_max=5;%
Len1=zeros(1,pn);Len2=zeros(1,pn);path2=zeros(pn,m);
t=zeros(1,pn);
T=1e5; tau=1e-5;
N=1;
while T>=tau
iter_num=1;
m_num=1;
while m_num<m_max && iter_num<iter_max
for i=1:pn
Len1(i)=sum([D(path(i,1:m-1)+m*(path(i,2:m)-1))
D(path(i,m)+m*(path(i,1)-1))]);
path2(i,:)=ChangePath2(path(i,:),m);
Len2(i)=sum([D(path2(i,1:m-1)+m*(path2(i,2:m)-1))
D(path2(i,m)+m*(path2(i,1)-1))]);
end
R=rand(1,pn);
if find((Len2-Len1<t&exp((Len1-Len2)/T)>R)~=0)
你可能喜欢
- 模拟退火算法matlab
- 蚁群算法 matlab
- 遗传算法matlab代码
- 粒子群算法matlab
- 遗传算法应用实例
- 遗传算法解决TSP问题
- 粒子群优化
- 哈密尔顿圈 遗传模拟 退火算法matlab 源程序5页
- 模拟退火算法-matlab7页
- 模拟退火算法及禁忌搜索算法的matlab源程序6页
- 完全图哈密尔顿圈的遗传模拟退火算法matlab通用源程序4页
- 模拟退火算法matlab源程序3页
- 模拟退火算法及禁忌搜索算法的matlab源程序6页
- matlab 蚁群算法 机器人路径优化问题12页
- 蚁群算法最短路径matlab程序6页
- matlab蚁群算法求解TSP问题3页
- 蚁群算法matlab源码3页
- matlab蚁群算法2页
- 可以直接运行的蚁群算法(matlab版)2页
- 遗传算法程序源代码matlab7页
- 遗传算法matlab代码11页
- 遗传算法matlab代码3页
- 遗传算法matlab代码2页
- matlab、lingo程序代码3-背包问题(遗传算法)3页
- 遗传算法matlab程序代码7页
- 基本粒子群算法的matlab源程序2页
- 粒子群算法通用matlab程序2页
- 粒子群算法的matlab代码实现5页
- 粒子群算法matlab代码19页
- 多目标粒子群算法matlab源代码12页
- 基本粒子群算法的matlab源程序2页
- MATLAB.遗传算法和粒子群算法程序设计及实例应用11页
- 遗传算法及其应用实例5页
- 遗传算法在数据挖掘中的应用实例分析2页
- 遗传算法在数据挖掘中的应用实例分析3页
- Matlab遗传算法工具箱函数及应用实例2页
- matlab基本遗传算法应用实例2页


