资源简介

猫群群算法解决优化问题,比遗传算法和粒子群算法更优

资源截图

代码片段和文件信息

clc;
close all;
num=2;     
MaxIt=200;  % Maximum Number of Iterations
nPop=50; 
%% Algorithm Parameters BINARY CAT 2013    
tb=10;
bitt=20;
nVar=bitt*tb; 
BestCost1_cat=zeros(numMaxIt);  
CostFunction=@(xtbbitt) cost_function(xtbbitt);   % Cost Function
c2_cat=1;
for ittt=1:num
    for ta=1:1 
            %  Number of Decision Variables
            alpha=0.3;
            VarSize=[1 nVar];   % Decision Variables Matrix Size
            %% PSO Parameters
            SMP=3;%0.25*nPop;
            SRD=0.2;
            CDC=0.2;
            nb=round(nVar*CDC);        
            MR=0.3;
            num_seek=round(MR*nPop);
            num_track=nPop-num_seek;
            cat=randperm(nPop);
            w_cat=0.5;
            vmax_cat=4;
            %********************************
            %% Initialization
            % Define Empty Structure to Hold Particle Data
            empty_cat.Position=[];
            empty_cat.flag=[];
            empty_cat.Velocity=[];
            empty_cat.Cost=[];
            pop=repmat(empty_catnPop1);
            vel_cat=rand(nPopnVar)-0.5;
            one_vel_cat=rand(nPopnVar)-0.5;
            zero_vel_cat=rand(nPopnVar)-0.5;
            % Initialize Global Best
            GlobalBest.Cost=inf;
            for i=1:nPop
                % Initialize Velocity
                pop(i).Position = round(rand(1nVar));
                pop(i).Velocity = rand(1nVar);
                % Evaluate Solution
                pop(i).Cost=CostFunction(pop(i).Positiontbbitt); 
                y=find(cat==i);
                if(y<=num_seek)
                    pop(i).flag=1;
                else
                    pop(i).flag=0;
                end
                % Update Global Best
                if pop(i).Cost<=GlobalBest.Cost
                    GlobalBest=pop(i);
                end
            end
            % Define Array to Hold Best Cost Values
            BestCost=zeros(MaxIt1);
            c1=1;
            %% PSO Main Loop
            for it=1:MaxIt
                    oneadd_cat=zeros(nPopnVar);
                    zeroadd_cat=zeros(nPopnVar);
                    dd3_cat=c2_cat*rand;
                    %******************************************************
                    for t_i=1:nPop
                        for g_i=1:nVar
                            if(GlobalBest.Position(g_i)==0)
                               oneadd_cat(t_ig_i)=oneadd_cat(t_ig_i)-dd3_cat;
                               zeroadd_cat(t_ig_i)=zeroadd_cat(t_ig_i)+dd3_cat;
                            else
                               oneadd_cat(t_ig_i)=oneadd_cat(t_ig_i)+dd3_cat; 
                               zeroadd_cat(t_ig_i)=zeroadd_cat(t_ig_i)-dd3_cat;
                            end
                        end
                    end
                    one_vel_cat=w_cat*one_vel_cat+oneadd_cat;
                    zero_vel_cat=w_cat*z

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       6616  2014-02-12 14:39  binary_cat_optimization\binary_cat_optimization.m

     文件        366  2014-02-12 14:39  binary_cat_optimization\cost_function.m

     文件        168  2014-10-19 21:46  binary_cat_optimization\f.m

     文件        141  2014-10-19 21:46  binary_cat_optimization\fitness.m

     文件       1018  2014-02-12 14:39  binary_cat_optimization\mutate.m

     文件        136  2014-02-12 14:39  binary_cat_optimization\mybin2dec.m

     文件        105  2014-02-12 14:39  binary_cat_optimization\RouletteWheelSelection.m

     目录          0  2014-10-20 11:00  binary_cat_optimization

----------- ---------  ---------- -----  ----

                 8550                    8


评论

共有 条评论