【优化算法】混沌博弈优化算法(CGO)【含Matlab源码 1803期】

举报
海神之光 发表于 2022/05/29 00:15:39 2022/05/29
【摘要】 一、获取代码方式 获取代码方式1: 完整代码已上传我的资源:【优化算法】混沌博弈优化算法(CGO)【含Matlab源码 1803期】 二、部分源代码 % Chaos Game Optimizati...

一、获取代码方式

获取代码方式1:
完整代码已上传我的资源:【优化算法】混沌博弈优化算法(CGO)【含Matlab源码 1803期】

二、部分源代码

%  Chaos Game Optimization (CGO) source codes version 1.0           
% 
clc;clear all;                                                              
%% Get Required Problem Information
ObjFuncName = @(x) Sphere(x); % @YourCostFunction ;
Var_Number = 10 ; % Number of your variables ;
LB = -10 *ones(1,Var_Number) ;  % Lower bound of variable ;
UB = 10 *ones(1,Var_Number) ;  % Upper bound of variable ;
%% Get Required Algorithm Parameters
MaxIter = 100 ; % Maximum number of generations ;
Seed_Number = 25 ; % Maximum number of initial eligible points ;
%% Outputs:
% BestSeed        (Best solution)
% BestFitness     (final Best fitness)
% Conv_History    (Convergence History Curve)
%% initialization
for i=1:Seed_Number   
    % Initializing the Position of initial eligible points
    Seed(i,:)=unifrnd(LB,UB);
    % Initializing the fitness of initial eligible points
    Fun_eval(i,:)=feval(ObjFuncName,Seed(i,:));
end
%% Search Process of the CGO
for Iter=1:MaxIter
    for i=1:Seed_Number
        % Update the best Seed
        [~,idbest]=min(Fun_eval);
        BestSeed=Seed(idbest,:);
        %% Generate New Solutions
        % Random Numbers
        I=randi([1,2],1,12); % Beta and Gamma
        Ir=randi([0,1],1,5);
        % Random Groups
        RandGroupNumber=randperm(Seed_Number,1);
        RandGroup=randperm(Seed_Number,RandGroupNumber);
        % Mean of Random Group
        MeanGroup=mean(Seed(RandGroup,:)).*(length(RandGroup)~=1)...
            +Seed(RandGroup(1,1),:)*(length(RandGroup)==1);   
        % New Seeds
        Alfa(1,:)=rand(1,Var_Number);
        Alfa(2,:)= 2*rand(1,Var_Number)-1;
        Alfa(3,:)= (Ir(1)*rand(1,Var_Number)+1);
        Alfa(4,:)= (Ir(2)*rand(1,Var_Number)+(~Ir(2)));   
        ii=randi([1,4],1,3);
        SelectedAlfa=Alfa(ii,:);

        NewSeed(1,:)=Seed(i,:)+SelectedAlfa(1,:).*(I(1)*BestSeed-I(2)*MeanGroup);
        NewSeed(2,:)=BestSeed+SelectedAlfa(2,:).*(I(3)*MeanGroup-I(4)*Seed(i,:));
        NewSeed(3,:)=MeanGroup+SelectedAlfa(3,:).*(I(5)*BestSeed-I(6)*Seed(i,:));
        NewSeed(4,:)=unifrnd(LB,UB);
        for j=1:4
            % Checking/Updating the boundary limits for Seeds
            NewSeed(j,:)=bound(NewSeed(j,:),UB,LB);
            % Evaluating New Solutions
            Fun_evalNew(j,:)=feval(ObjFuncName, NewSeed(j,:));
        end
        Seed=[Seed; NewSeed];       
        Fun_eval=[Fun_eval; Fun_evalNew];
    end
    [Fun_eval, SortOrder]=sort(Fun_eval);
    Seed=Seed(SortOrder,:);
    [BestFitness,idbest]=min(Fun_eval);   
    BestSeed=Seed(idbest,:);
    Seed=Seed(1:Seed_Number,:);
    Fun_eval=Fun_eval(1:Seed_Number,:);
    % Store Best Cost Ever Found
    Conv_History(Iter)=BestFitness;
    % Show Iteration Information
    disp(['Iteration ' num2str(Iter) ': Best Cost = ' num2str(Conv_History(Iter))]);
end
   



  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73

三、运行结果

在这里插入图片描述

四、matlab版本及参考文献

1 matlab版本
2014a

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

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

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

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

评论(0

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

全部回复

上滑加载中

设置昵称

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

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

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