1.完整项目描述和程序获取
>面包多安全交易平台:https://mbd.pub/o/bread/ZJaUk55u
>如果链接失效,可以直接打开本站店铺搜索相关店铺:
>如果链接失效,程序调试报错或者项目合作也可以加微信或者QQ联系。
2.部分仿真图预览
3.算法概述
模拟退火算法(simulated annealing,SAA)来源于固体退火原理,是一种基于概率的算法。模拟退火算法来源于固体退火原理,是一种基于概率的算法,将固体加温至充分高,再让其徐徐冷却,加温时,固体内部粒子随温升变为无序状,内能增大,而徐徐冷却时粒子渐趋有序,在每个温度都达到平衡态,最后在常温时达到基态,内能减为最小。
4.部分源码
................................................................
T0 = 500 ; % initial temperature
r = 0.997 ; % temperature damping rate
Ts = 1 ; % stop temperature
iter = 300;
model = initModel();
set(gcf,'unit','normalized','position',[0,0.35,1,0.7]);
flag = 0;
% initialization
while(1)
route = randomSol(model);
if(isFeasible(route,model))
break;
end
end
cost = calculateCost(route,model);
T = T0;
cnt = 1;
minCost = cost;
minRoute = route;
maxIterate = 2100;
costArray = zeros(maxIterate,1);
% SA
while(T > Ts)
for k = 1:iter
mode = randi([1 3]);
newRoute = createNeibor(route,model,mode);
newCost = calculateCost(newRoute,model);
delta = newCost - cost;
if(delta < 0)
cost = newCost;
route = newRoute;
else
p=exp(-delta/T);
if rand() <= p
cost = newCost;
route = newRoute;
end
end
end
costArray(cnt) = cost;
if cost<minCost
minCost = cost;
minRoute = route;
flag = 1;
end
T = T*r; % annealing
cnt = cnt+1;
figure(1);
if(flag == 1)
plotSolution(minRoute,model);
flag = 0;
end
pause(0.0001);
end
figure(2);
plot(costArray(1:cnt-1));
xlabel('迭代次数');
ylabel('优化过程');
figure(3);
plotSolution(minRoute,model);
legend('车1路线','车2路线','车3路线','车4路线');
A456