【优化算法】寄生-捕食优化算法(PPA)【含Matlab源码 1445期】

213 阅读3分钟

一、获取代码方式

获取代码方式1: 通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。

获取代码方式2: 通过紫极神光博客主页开通CSDN会员,凭支付凭证,私信博主,可获得此代码。

获取代码方式3: 完整代码已上传我的资源:【优化算法】寄生-捕食优化算法(PPA)【含Matlab源码 1445期】

备注:开通CSDN会员,仅只能免费获得1份代码(有效期为开通日起,三天内有效); 订阅紫极神光博客付费专栏,可免费获得2份代码(有效期为订阅日起,三天内有效);

二、部分源代码

%______________________________________________________________________________________________
% Parasitism ?Predation algorithm (PPA):
% mimics the interaction between predators/cats, parasites/cuckoos
% and hosts/crows in the crow朿uckoo朿at system model
%  Developed in MATLAB R2017a
%
%  
%
% For more info please refer to:
% Mohamed A. A. A., Hassan S. A., Hemeida A. M., et al.(2019).  
% Parasitism朠redation algorithm (PPA): A novel approach for feature selection.
% Ain Shams Engineering Journal. DOI: 10.1016/j.asej.2019.10.004
%_______________________________________________________________________________________________
% The initial parameters that you need are:
% d = number of your variables
% MAX_ITER = maximum number of generations
% n = number of search agents
% lb is the lower bound: lb=[lb_1,lb_2,...,lb_d]
% up is the uppper bound: ub=[ub_1,ub_2,...,ub_d]
clear all

for iji=14:23
    
    if iji==1;F=('F1');elseif iji==2;F=('F2');elseif iji==3;F=('F3');elseif iji==4;F=('F4');elseif iji==5;F=('F5'); ...
    elseif iji==6;F=('F6');elseif iji==7; F=('F7'); elseif iji==8; F=('F8');elseif iji==9; F=('F9'); ...
    elseif iji==10; F=('F10');elseif iji==11; F=('F11');elseif iji==12; F=('F12'); ...
    elseif iji==13; F=('F13');elseif iji==14; F=('F14');elseif iji==15; F=('F15');
    elseif iji==16; F=('F16');elseif iji==17; F=('F17');elseif iji==18; F=('F18');
    elseif iji==19; F=('F19');elseif iji==20; F=('F20');elseif iji==21; F=('F21');
    elseif iji==22; F=('F22');elseif iji==23; F=('F23');
    end
    if iji < 14;MAX_ITER=1000;else; MAX_ITER=500;end% Maximum number of iterations
    
    n =30;            % Number of search agents
    
    % Load details of the selected benchmark function
    [lb,ub,d,fobj] = Get_Functions_details(F);
    
    [Best_pos,Best_score,Convergence_curve]=PPA(n,MAX_ITER,ub,lb,d,fobj);
    
    %Draw and display objective function
    %figure,semilogy(Convergence_curve); title( F ); xlabel('Iteration'); ylabel('Best score obtained so far');
    
    % display(['The optimal solution of ',F, ' is: ',num2str(Best_pos)]);
    display(['The optimal value of ',F,' is : ', num2str(Best_score)]);
end
%______________________________________________________________________________________________
% Parasitism朠redation Algorithm (PPA)
                                                                                               

% reference:  
% [1] X. Yao, Y. Liu, G. Lin, Evolutionary programming made faster, IEEE Trans.Evolution. Comput. 3 (2) (1999) 82?02.
% [2] Salimi H. Stochastic Fractal Search: A powerful metaheuristic algorithm. Knowledge Based Syst 2015; 75: 1-18.?doi:10.1016/j.knosys.2014.07.025
% lb is the lower bound: lb=[lb_1,lb_2,...,lb_d]
% up is the uppper bound: ub=[ub_1,ub_2,...,ub_d]
% dim is the number of variables (dimension of the problem)
%_______________________________________________________________________________________________

function [lb,ub,dim,fobj] = Get_Functions_details(F)


switch F
    case 'F1'
        fobj = @F1;
        lb=-100;
        ub=100;
        dim=30;
        
    case 'F2'
        fobj = @F2;
        lb=-10;
        ub=10;
        dim=30;
        
    case 'F3'
        fobj = @F3;
        lb=-100;
        ub=100;
        dim=30;
        
    case 'F4'
        fobj = @F4;
        lb=-100;
        ub=100;
        dim=30;
        
    case 'F5'
        fobj = @F5;
        lb=-30;
        ub=30;
        dim=30;
        
    case 'F6'
        fobj = @F6;
        lb=-100;
        ub=100;
        dim=30;
        
    case 'F7'
        fobj = @F7;
        lb=-1.28;
        ub=1.28;
        dim=30;
        
    case 'F8'
        fobj = @F8;
        lb=-500;
        ub=500;
        dim=30;
        
    case 'F9'
        fobj = @F9;
        lb=-5.12;
        ub=5.12;
        dim=30;
        
    case 'F10'
        fobj = @F10;
        lb=-32;
        ub=32;
        dim=30;
        
    case 'F11'
        fobj = @F11;
        lb=-600;
        ub=600;
        dim=30;
        
    case 'F12'
        fobj = @F12;
        lb=-50;
        ub=50;
        dim=30;
        
    case 'F13'
        fobj = @F13;
        lb=-50;
        ub=50;
        dim=30;
        
    case 'F14'
        fobj = @F14;
        lb=-65.536;
        ub=65.536;
        dim=2;
        
    case 'F15'
        fobj = @F15;
        lb=-5;
        ub=5;
        dim=4;
        
    case 'F16'
        fobj = @F16;
        lb=-5;
        ub=5;
        dim=2;
        
    case 'F17'
        fobj = @F17;
        lb=[-5,0];
        ub=[10,15];
        dim=2;
        
    case 'F18'
        fobj = @F18;
        lb=-5;
        ub=5;
        dim=2;


三、运行结果

在这里插入图片描述

四、matlab版本及参考文献

1 matlab版本 2014a

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