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

举报
海神之光 发表于 2022/05/29 00:57:08 2022/05/29
1.4k+ 0 0
【摘要】 一、获取代码方式 获取代码方式1: 完整代码已上传我的资源:【优化算法】广义正态分布优化算法(GNDO)【含Matlab源码 1531期】 二、部分源代码 clc clear all lb = -...

一、获取代码方式

获取代码方式1:
完整代码已上传我的资源:【优化算法】广义正态分布优化算法(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

  
 

三、运行结果

在这里插入图片描述

四、matlab版本及参考文献

1 matlab版本
2014a

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

文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。

原文链接:qq912100926.blog.csdn.net/article/details/121353971

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

作者其他文章

评论(0

抱歉,系统识别当前为高风险访问,暂不支持该操作

    全部回复

    上滑加载中

    设置昵称

    在此一键设置昵称,即可参与社区互动!

    *长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

    *长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。