0
点赞
收藏
分享

微信扫一扫

【优化算法】广义正态分布优化算法(GNDO)【含Matlab源码 1531期】

二、部分源代码

clc
clear all

lb = -100.*ones(1,10);
ub = 100.*ones(1,10);
maxit = 100;
objf= @Sphere;

n = 30;
d = 10;

[BestCost,BestValue,Best]=GNDO(objf,n,d,lb,ub,maxit);
plot(BestCost,'r','linewidth',2)
xlabel('The number of iterations','Fontname','Times New Roma','fontsize',15);
ylabel('Fitness value','Fontname','Times New Roman','fontsize',15);

function [cgcurve,bestFitness,bestSol]=GNDO(obj,n,d,lb,ub,t)

%obj--------objective function
%c-------population size
%d-------dimension of problem
%lb-----the lower limit of the variables
%ub-----the upper limit of the variables
%t------the maximum number of function evaluations
%cgcurve---the record of the convergence curves
%bestobj--the optimal fitness value
%bestsol-------the optimal solution


% Initialise the population
for i=1:n
x(i,:)=lb+(ub-lb).*rand(1,d); % Eq. 26
end

bestFitness = inf;

for it=1: 1 : t

for i=1:n
fitness(i) = obj(x(i,:));

if fitness(i) < bestFitness
bestSol = x(i,:);
end
end
cgcurve(it)=bestFitness;


mo= mean(x);


for i=1:n
a=randperm(n,1);
b=randperm(n,1);
c=randperm(n,1);
while a==i | a==b | c==b | c==a |c==i |b==i
a=randperm(n,1);
b=randperm(n,1);
c=randperm(n,1);
end

if fitness(a)<fitness(i) %Eq. 24
v1=x(a,:)-x(i,:);
else
v1=x(i,:)-x(a,:);
end

if fitness(b)<fitness(c) %Eq. 25
v2=x(b,:)-x(c,:);
else
v2=x(c,:)-x(b,:);
end

if rand<=rand

u=1/3*(x(i,:)+bestSol+mo); %Eq . 19
deta=sqrt(1/3*((x(i,:)-u).^2 ...
+(bestSol-u).^2+(mo-u).^2)); %Eq. 20

vc1=rand(1,d);
vc2=rand(1,d);

%Eq. 21
Z1=sqrt(-1*log(vc2)).*cos(2*pi.*vc1);
Z2=sqrt(-1*log(vc2)).*cos((2*pi.*vc1)+pi);
a = rand;
b = rand;
if a<=b
eta = (u+deta.*Z1);
else
eta = (u+deta.*Z2);
end

三、运行结果

【优化算法】广义正态分布优化算法(GNDO)【含Matlab源码 1531期】_算法

四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,2016.
[2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,2017.


举报

相关推荐

0 条评论