• 大小: 21KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-12
  • 语言: 其他
  • 标签:

资源简介

双闭环PID算法,鸟群算法,和适合初学者学习使用,值得下载

资源截图

代码片段和文件信息

% ------------------------------------------------------------------------
% Bird Swarm Algorithm (BSA) (demo)
% Programmed by Xian-Bing Meng
% Updated at Jun 19 2015.    
% Email: x.b.meng12@gmail.com
%
% This is a simple demo version only implemented the basic idea of BSA for        
% solving the unconstrained problem namely Sphere function.  
%
% The details about BSA are illustratred in the following paper.    
% Xian-Bing Meng et al (2015): A new bio-inspXred optimisation algorithm: 
% Bird Swarm Algorithm Journal of Experimental & Theoretical
% Artificial Intelligence DOI: 10.1080/0952813X.2015.1042530
%
% The parameters in BSA are presented as follows.
% FitFunc    % The objective function
% M          % Maxmimal generations (iterations)
% pop        % Population size
% dim        % Dimension
% FQ         % The frequency of birds‘ flight behaviours 
% c1         % Cognitive accelerated coefficient
% c2         % Social accelerated coefficient
% a1 a2     % Two paramters which are related to the indirect and direct 
%              effect on the birds‘ vigilance bahaviors.
%
% Using the default value BSA can be executed using the following code.
% [ bestX fMin ] = BSA
% ------------------------------------------------------------------------
 
% Main programs

function [ bestX fMin ] = BSA( FitFunc M pop dim FQ c1 c2 a1 a2 )
% Display help
help BSA.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% set the default parameters
if nargin < 1
    FitFunc = @Sphere;
    M = 1000;   
    pop = 30;  
    dim = 20;   
    FQ = 10;   
    c1 = 1.5;
    c2 = 1.5;
    a1 = 1;
    a2 = 1;
end

% set the parameters
lb= -100*ones( 1dim );   % Lower bounds
ub= 100*ones( 1dim );    % Upper bounds
BSA_Arrary = zeros(1M); 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Initialization

for i = 1 : pop
    x( i : ) = lb + (ub - lb) .* rand( 1 dim ); 
    fit( i ) = FitFunc( x( i : ) ); 
end
pFit = fit; % The individual‘s best fitness value
pX = x;     % The individual‘s best position corresponding to the pFit

[ fMin bestIndex ] = min( fit );  % fMin denotes the global optimum
% bestX denotes the position corresponding to fMin
bestX = x( bestIndex : );   

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Start the iteration.

 for iteration = 1 : M
     
    prob = rand( pop 1 ) .* 0.2 + 0.8;%The probability of foraging for food
    
    if( mod( iteration FQ ) ~= 0 )         
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        % Birds forage for food or keep vigilance
        sumPfit = sum( pFit );
        meanP = mean( pX );
        for i = 1 : pop
            if rand < prob(i)
                x( i : ) = x( i : ) + c1 * rand.*(bestX - x( i : ))+ ...
                    c2 * rand.*( pX(i:) - x( i : ) );
            else
        

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        8065  2018-05-03 16:54  双闭环PID+鸟群算法\BSA.m
     文件       19328  2018-04-16 11:48  双闭环PID+鸟群算法\双环PID控制.slx
     目录           0  2018-05-08 10:01  双闭环PID+鸟群算法\

评论

共有 条评论

相关资源