遗传算法Matlab源代码(8)

2021-04-06 04:23

完整可以运行的数值优化遗传算法源代码

i=1;

if opts(1)==1%浮点变异

maxfit=max(fit);

upfit=maxfit+0.05*abs(maxfit);

if opts(2)==1|opts(2)==3

while(i<=L)%自适应变异(自增或自减)

Point=unidrnd(n);

T=(1-fit(MutIn(i))/upfit)^2;

q=abs(1-rand^T);

%if q>1%按严格数学推理来说,这段程序是不能缺少的

% q=1

%end

p=OldPop(MutIn(i),Point)*(1-q);

if unidrnd(2)==1

NewPop(MutIn(i),Point)=p+q;

else

NewPop(MutIn(i),Point)=p;

end

i=i+1;

end

elseif opts(2)==2|opts(2)==4%AEA变异(任意变量的某一位变异)

while(i<=L)

Point=unidrnd(n);

T=(1-abs(upfit-fit(MutIn(i)))/upfit)^2;

v=1+unidrnd(1+ceil(10*T));

%v=1+unidrnd(5+ceil(10*eranum/MaxEranum));

q=mod(floor(OldPop(MutIn(i),Point)*10^v),10);

NewPop(MutIn(i),Point)=OldPop(MutIn(i),Point)-(q-unidrnd(9))/10^v;

i=i+1;

end

else

while(i<=L)

Point=unidrnd(n);

if round(rand)

NewPop(MutIn(i),Point)=OldPop(MutIn(i),Point)*(1-rand);

else

NewPop(MutIn(i),Point)=OldPop(MutIn(i),Point)+(1-OldPop(MutIn(i),Point))*rand; end

i=i+1;

end

end

elseif opts(1)==0%二进制串变异

if L>=1

while i<=L

k=unidrnd(n,1,VarNum); %设置变异点数(=变量数)

for j=1:length(k)

if NewPop(MutIn(i),k(j))==1

NewPop(MutIn(i),k(j))=0;

else


遗传算法Matlab源代码(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:经典幻灯片模板

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: