资源简介
参数自适应差分进化算法SACPMDE.rar参数自适应差分进化算法SACPMDE.rar参数自适应差分进化算法SACPMDE.rar
代码片段和文件信息
function [trbjbmn] = SACPMDE(VTRXVminXVmaxDNPfname)
% 参数自适应差分进化算法对Rastrigrin函数起作用
% aa 当前计算到第几次
% VTR 优化的目标值
% fname 选择测试函数
% XVmin 搜索空间下限
% XVmax 搜索空间上限
itermax = 8000; % maximum number of iterations (generations)
F = 0.6; % DE-stepsize F from interval [0 2]
F1=0.45;
CR = 0.9; % crossover probability constant from interval [0 1]
%-----DE Initialize--------------------------------------------------------
pop = zeros(NPD); % initialize pop
for i = 1:NP
pop(i:) = XVmin + rand(1D).*(XVmax - XVmin);
end
popold = zeros(size(pop));% toggle population
val = zeros(1NP); % create and reset the “cost array“
bestmem = zeros(1D); % best population member ever
bestmemit = zeros(1D); % best population member in iteration
for i = 1:NP % Evaluate the best member after initialization
input = pop(i:);
output(i) = feval(fnameinput);
end
val = output‘;
[bestvalitidx] = min(val);
bestmemit = pop(idx:); % best member of current iteration
bestmem = bestmemit; % best member ever
bestval = bestvalit; % best value ever
%-----DE Iteration---------------------------------------------------------
tr = zeros(1itermax);
for j = 1:itermax
if (bestval-VTR) < 1e-5
break
end
popold = pop;
% generate the trail population
for i = 1:NP
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CR=0.1;
if val(i)<=mean(val)
CR=0.1+(0.6-0.1)*(val(i)-max(val))/(min(val)-max(val));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% pick up the donor and differential vectors
rd = fix(rand(1) * NP + 1);
while val(rd) > val(i)
rd = fix(rand(1) * NP + 1);
end
rb = fix(rand(1) * NP + 1);
while rb == i || rb == rd
rb = fix(rand(1) * NP + 1);
end
rc = fix(rand(1) * NP + 1);
while rc == i || rc == rd || rc==rb
rc = fix(rand(1) * NP + 1);
end
re = fix(rand(1) * NP + 1);
while re == i || re == rd || re==rb || re==rc
re = fix(rand(1) * NP + 1);
end
% bulid a trial vector and crossover
jr = fix(rand(1) * D + 1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 找基变量
tb=rd;
if val(rb:)<=min(val(rd:)val(rc:))
tb=rb;
end
if val(rc:)<=min(val(rd:)val(rb:))
tb=rc;
end
% 找另两个差分向量;
tm=rd;
if val(rb:)>=min(val(rd:)val(rc:)) && val(rb:)<=max(val(rd:)val(rc:))
tm=rb;
end
if val(rc:)>=min(val(rd:)val(rb:)) && val(rc:)<=max(val(rd:)val(rb:))
tm=rc;
end
% 找最差的向量
tw=rd;
if val(rb:)>=max(val(rd:)val(rc:))
tw=rb;
end
if val(rc:)>=max(val(rd:)val(rb:))
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4326 2009-05-05 10:13 SACPMDE.m
----------- --------- ---------- ----- ----
4326 1
评论
共有 条评论