1 Star 5 Fork 1

QianWei_1129/免疫算法选址

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Mutation.m 1001 Bytes
一键复制 编辑 原始数据 按行查看 历史
function ret=Mutation(pmutation,chrom,sizepop,length1)
% 变异操作
% pmutation input : 变异概率
% chrom input : 抗体群
% sizepop input : 种群规模
% iii input : 进化代数
% MAXGEN input : 最大进化代数
% length1 input : 抗体长度
% ret output : 变异得到的抗体群
% 每一轮for循环中,可能会进行一次变异操作,染色体是随机选择的,变异位置也是随机选择的
for i=1:sizepop
% 变异概率
pick=rand;
while pick==0
pick=rand;
end
index=unidrnd(sizepop);
% 判断是否变异
if pick>pmutation
continue;
end
pos=unidrnd(length1);
while pos==1
pos=unidrnd(length1);
end
nchrom=chrom(index,:);
nchrom(pos)=unidrnd(31);
while length(unique(nchrom))==(length1-1)
nchrom(pos)=unidrnd(31);
end
flag=test(nchrom);
if flag==1
chrom(index,:)=nchrom;
end
end
ret=chrom;
end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Matlab
1
https://gitee.com/qianwei-1129/immune-algorithm-location.git
git@gitee.com:qianwei-1129/immune-algorithm-location.git
qianwei-1129
immune-algorithm-location
免疫算法选址
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385