1.完整项目描述和程序获取
>面包多安全交易平台:https://mbd.pub/o/bread/ZJaalJ1x
>如果链接失效,可以直接打开本站店铺搜索相关店铺:
>如果链接失效,程序调试报错或者项目合作也可以加微信或者QQ联系。
2.部分仿真图预览
3.算法概述
模拟退火算法(simulated annealing,SAA)来源于固体退火原理,是一种基于概率的算法。模拟退火算法来源于固体退火原理,是一种基于概率的算法,将固体加温至充分高,再让其徐徐冷却,加温时,固体内部粒子随温升变为无序状,内能增大,而徐徐冷却时粒子渐趋有序,在每个温度都达到平衡态,最后在常温时达到基态,内能减为最小。
4.部分源码
.............................................................
data = load('vrp1.mat');
model = data.model;
model.eta = 0.1;
CostFunction = @(q) MyCost(q,model);
MaxIt = 1000;
MaxIt2 = 80;
T0 = 100;
alpha = 0.99;
x.Position = CreateRandomSolution(model);
[x.Cost x.Sol] = CostFunction(x.Position);
BestSol = x;
BestCost = zeros(MaxIt,1);
nfe = zeros(MaxIt,1);
T = T0;
for it=1:MaxIt
it
for it2=1:MaxIt2
xnew.Position = CreateNeighbor(x.Position);
[xnew.Cost xnew.Sol] = CostFunction(xnew.Position);
if xnew.Cost<=x.Cost
x=xnew;
else
delta=xnew.Cost-x.Cost;
p=exp(-delta/T);
if rand<=p
x=xnew;
end
end
if x.Cost<=BestSol.Cost
BestSol=x;
end
end
BestCost(it) = BestSol.Cost;
nfe(it) = NFE;
if BestSol.Sol.IsFeasible
FLAG=' *';
else
FLAG='';
end
T=alpha*T;
figure(1);
PlotSolution(BestSol.Sol,model);
end
figure;
plot(nfe,BestCost,'LineWidth',1);
xlabel('迭代次数');
ylabel('Cost');
A581