• 大小: 6KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-09
  • 语言: 其他
  • 标签: 综述  优化算法  

资源简介

生物地理学算法的综述文章,一个算法实现程序,程序有详细备注,便于理解该算法。

资源截图

代码片段和文件信息

%
% Copyright (c) 2015 Yarpiz (www.yarpiz.com)
% All rights reserved. Please read the “license.txt“ for license terms.
%
% Project Code: YPEA113
% Project title: Biogeography-based Optimization (BBO) in MATLAB
% Publisher: Yarpiz (www.yarpiz.com)

% Developer: S. Mostapha Kalami Heris (Member of Yarpiz Team)

% Contact Info: sm.kalami@gmail.com info@yarpiz.com
%

clc;
clear;
close all;

%% Problem Definition

CostFunction=@(x) Sphere(x);        % Cost Function

nVar=5;             % Number of Decision Variables

VarSize=[1 nVar];   % Decision Variables Matrix Size

VarMin=-10;         % Decision Variables Lower Bound
VarMax= 10;         % Decision Variables Upper Bound

%% BBO Parameters

MaxIt=1000;          % Maximum Number of Iterations

nPop=50;            % Number of Habitats (Population Size)

KeepRate=0.2;                   % Keep Rate
nKeep=round(KeepRate*nPop);     % Number of Kept Habitats

nNew=nPop-nKeep;                % Number of New Habitats

% Migration Rates
mu=linspace(10nPop);          % Emmigration Rates
lambda=1-mu;                    % Immigration Rates

alpha=0.9;

pMutation=0.1;

sigma=0.02*(VarMax-VarMin);

%% Initialization

% Empty Habitat
habitat.Position=[];
habitat.Cost=[];

% Create Habitats Array
pop=repmat(habitatnPop1);

% Initialize Habitats
for i=1:nPop
    pop(i).Position=unifrnd(VarMinVarMaxVarSize);
    pop(i).Cost=CostFunction(pop(i).Position);
end

% Sort Population
[~ SortOrder]=sort([pop.Cost]);
pop=pop(SortOrder);

% Best Solution Ever Found
BestSol=pop(1);

% Array to Hold Best Costs
BestCost=zeros(MaxIt1);

%% BBO Main Loop

for it=1:MaxIt
    
    newpop=pop;
    for i=1:nPop
        for k=1:nVar
            % Migration
            if rand<=lambda(i)
                % Emmigration Probabilities
                EP=mu;
                EP(i)=0;
                EP=EP/sum(EP);
                
                % Select Source Habitat
                j=RouletteWheelSelection(EP);
                
                % Migration
                newpop(i).Position(k)=pop(i).Position(k) ...
                    +alpha*(pop(j).Position(k)-pop(i).Position(k));
                
            end
            
            % Mutation
            if rand<=pMutation
                newpop(i).Position(k)=newpop(i).Position(k)+sigma*randn;
            end
        end
        
        % Apply Lower and Upper Bound Limits
        newpop(i).Position = max(newpop(i).Position VarMin);
        newpop(i).Position = min(newpop(i).Position VarMax);
        
        % Evaluation
        newpop(i).Cost=CostFunction(newpop(i).Position);
    end
    
    % Sort New Population
    [~ SortOrder]=sort([newpop.Cost]);
    newpop=newpop(SortOrder);
    
    % Select Next Iteration Population
    pop=[pop(1:nKeep)
         newpop(1:nNew)];
     
    % Sort Population
    [~ SortOrder]=sort([pop.Cost]);
    pop

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-09-06 16:25  YPEA113 Biogeography-based Optimization\
     目录           0  2015-09-06 16:51  YPEA113 Biogeography-based Optimization\BBO\
     文件        3435  2015-10-21 03:56  YPEA113 Biogeography-based Optimization\BBO\bbo.m
     文件        1350  2015-08-23 04:39  YPEA113 Biogeography-based Optimization\BBO\license.txt
     文件         391  2015-09-06 19:27  YPEA113 Biogeography-based Optimization\BBO\main.m
     文件         490  2015-09-06 19:27  YPEA113 Biogeography-based Optimization\BBO\RouletteWheelSelection.m
     文件         432  2015-09-06 19:27  YPEA113 Biogeography-based Optimization\BBO\Sphere.m
     文件         121  2015-08-23 04:35  YPEA113 Biogeography-based Optimization\BBO\www.yarpiz.com.url
     文件        1350  2015-08-23 04:39  YPEA113 Biogeography-based Optimization\license.txt
     文件         121  2015-08-23 04:35  YPEA113 Biogeography-based Optimization\www.yarpiz.com.url

评论

共有 条评论