⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ga.m

📁 用matlab编写的采用遗传算法进行图像分割的一个程序
💻 M
字号:
a=1,b=256,pc=0.6;pm=0.06;
popsize=20;stringlength=8;
maxgeneration=20;
% generation=0;
[pop]=initialise(popsize,stringlength,a,b);
tic;
for generation=0:1:maxgeneration
%  nextpop=pop;
[bmax,bestindes]=max(pop(:,stringlength+2));
best1=pop(bestindes,:);
[bmin bminindes]=min(pop(:,stringlength+2));
% if (bmax-bmin)>50
pop(bminindes,:)=best1;
[rnewpop]=roulette(pop,popsize,stringlength);
[cnewpop]=crossover(rnewpop,stringlength,a,b,pc);
[mnewpop]=mutation(cnewpop,stringlength,a,b,pm);
pop=mnewpop;
% else
%     generation;
%   break;     
%   end
end
best1,
toc

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -