function main()
clear;
clc;
for xx=1:2
tic
% 参数初始化
genmax=500;
[xy,n,nind,D,Q,TT,ET,EL,ELL,CT,CL,dmax,qmax,fitmax,c0,c1,k,v]=datas();
%生成初试种群
chrom=initpop(nind,n,k);
gen=1;
while gen<=genmax
%计算适应值矩阵
[fit,fitx]=fitness(D,Q,chrom,TT,ET,EL,CT,CL,dmax,qmax,fitmax,c0,c1,k,v,n,nind);
%找出最优个体适应值
avefit(gen)=sum(fit)/nind;%平均适应值
[bestfitc,bestindex]=min(fit);
bestindex=bestindex(1);
bestfit(gen)=bestfitc;%最小适应值fit的集
bestpop(gen,:)=chrom(bestindex,:);%最优个体集
%选择
chrom=select(chrom,fitx);
%交叉
chrom=crossover(chrom);
%变异
chrom=mutate(chrom,avefit,gen);
%精英策略
chrom(1,:)=bestpop(gen,:);
gen=gen+1;
end
bestpop;
y=bestfit;%各代最优适应值
%y1=avefit;%各代平均适应值
%找出最优的适应值、个体
[minbestfit,minindex]=min(bestfit);%取最优适应值的位置、最优适应值
minindex=minindex(1);
%取最优个体
minbestpop=bestpop(minindex,:);
%解码最优染色体
a=randperm(size(minbestpop,2));
a1=sort(a);
a2=sort(minbestpop);
a3=zeros(1,size(minbestpop,2));
for i=1:size(minbestpop,2)
for j=1:size(minbestpop,2)
if minbestpop(i)==a2(j);
a3(i)=a1(j);
a2(j)=0;
break;
end
end
end
a3;
for i=1:size(a3,2)
if a3(i)>n
a3(i)=1;
end
end
a4=[1,a3,1];
%去重
for i=1:size(a4,2)-1
if a4(i)-a4(i+1)==0
a4(i)=0;
end
end
ii=find(a4==0);
a4(ii)=[];
a4;
%最优方案
minbestpop1=a4;
minbestfit;%最低适应值
%画线路
DrawPath(minbestpop1,xy);
%迭代图
figure
x=1:1:genmax;
plot(x,y,'r--')
%plot(x,y);
hold on
%plot(x,y1,'r--');%适应值平均数
title('遗传优化过程')
xlabel('迭代次数')
ylabel('最优适应值')
axis([0,genmax,0,2000])
%输出最优解
disp('最优解为:');
N=size(minbestpop1,2);
p=num2str(minbestpop1(1));
for i=2:N;
p=[p,'->',num2str(minbestpop1(i))];
end
disp(p);
disp(['最优解为:',num2str(minbestpop1)]);
disp(['最优成本为:',num2str(minbestfit)]);
s=0;
r=minbestpop1;
for i=1:size(r,2)-1
s=s+D(r(i),r(i+1));
end
disp(['行驶里程:',num2str(s)]);
toc
end
没有合适的资源?快使用搜索试试~ 我知道了~
基于MATLAB实现的遗传算法求解VRP带时间窗(可以运行)+使用说明文档.rar
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共32个文件
m:31个
md:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 98 浏览量
2024-05-23
09:59:07
上传
评论
收藏 22KB RAR 举报
温馨提示
CSDN IT狂飙上传的代码均可运行,功能ok的情况下才上传的,直接替换数据即可使用,小白也能轻松上手 【资源说明】 基于MATLAB实现的遗传算法求解VRP带时间窗(可以运行)+使用说明文档.rar 1、代码压缩包内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2020b;若运行有误,根据提示GPT修改;若不会,私信博主(问题描述要详细); 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可后台私信博主; 4.1 期刊或参考文献复现 4.2 Matlab程序定制 4.3 科研合作 功率谱估计: 故障诊断分析: 雷达通信:雷达LFM、MIMO、成像、定位、干扰、检测、信号分析、脉冲压缩 滤波估计:SOC估计 目标定位:WSN定位、滤波跟踪、目标定位 生物电信号:肌电信号EMG、脑电信号EEG、心电信号ECG 通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 5、欢迎下载,沟通交流,互相学习,共同进步!
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![md](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![md](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 32 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
IT狂飙
- 粉丝: 4779
- 资源: 2658
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
下载权益
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
C知道特权
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
VIP文章
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
课程特权
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- da_1718811404508..apk
- StudentManagementSystem.java
- 示例代码:java动态代理和cglib代理的简单例子
- 应急响应-linux入侵排查.md
- 基于Springboot的漫画网站(有报告) Javaee项目,springboot项目
- 年金、净现值NPV、IRR、现值PV、终值FV、EAR等常见概念.pdf
- 数据处理matlab代码
- 小程序版基于深度学习对火龙果成熟度识别-不含数据集图片-含逐行注释和说明文档.zip
- 小程序版CNN图像分类识别牛油果是否腐烂-不含数据集图片-含逐行注释和说明文档.zip
- 小程序版深度学习CNN训练识别食物新鲜-不含数据集图片-含逐行注释和说明文档.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)