A list,
Cat Swarm Optimization (CSO) is a global Optimization algorithm based on Cat behavior first proposed by Shu-An Chu et al in 2006. It has the characteristics of fast convergence and strong searching ability. In the cat swarm algorithm, the cat is the feasible solution of the optimization problem to be solved. The cat swarm algorithm divides the cat’s behavior into two modes. One is the mode called search mode when the cat is lazy and looking around. The other is the state of tracking a dynamic target called the tracking mode. In the cat swarm algorithm, some cats perform search mode and the rest perform tracking mode. The two modes interact by combining the Mixture Ratio (MR). MR represents the proportion of the number of cats performing tracking mode in the whole cat swarm, and MR should be a small value in the program. To solve the optimization problem with the cat swarm algorithm, the number of individuals involved in the optimization calculation should be determined first, that is, the number of cats. The attributes of each cat (including its position consisting of M dimensions), the speed of each dimension, the fitness of the reference function, and the identifier indicating whether the cat is in search or tracking mode. After cats have gone through the search mode and the tracking mode, their fitness is calculated according to the fitness function and the best solution in the current population is retained. Then, the cats were randomly divided into the searching part and the tracking part according to the binding rate, and the iterative calculation was carried out until the preset number of iterations was reached.
1.1 Mathematical Description The search mode is used to simulate the cat’s current state: resting, looking around, and searching for the next moving position. In the search mode, four basic elements are defined: memory pool (SMP), change domain (SRD), change number (CDC) and self position judgment (SPC). SMP defines the size of each cat’s search memory, which represents the location point searched by the cat. The cat will select the best location point from the memory pool according to the fitness size. SRD represents the variation rate of the selection domain. In the search mode, the change range of each dimension is determined by the change domain, and the value is generally 0.2 according to experience. CDC refers to the number of dimensions that will vary per cat, and its value is a random number ranging from 0 to the total dimension. SPC is a Boolean value indicating whether the cat considers the passed position as one of the candidate positions to move to. Its value does not affect the value of SMP.
1.1.1 Search Mode process Description
1.1.2 Tracing Mode Process description
2 Algorithm Flow
The algorithm flow chart is as follows:
Ii. Source code
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(num,MaxIt);
CostFunction=@(x,tb,bitt) cost_function(x,tb,bitt); % 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_cat,nPop,1);
vel_cat=rand(nPop,nVar)0.5;
one_vel_cat=rand(nPop,nVar)0.5;
zero_vel_cat=rand(nPop,nVar)0.5;
% Initialize Global Best
GlobalBest.Cost=inf;
for i=1:nPop
% Initialize Velocity
pop(i).Position = round(rand(1,nVar));
pop(i).Velocity = rand(1,nVar);
% Evaluate Solution
pop(i).Cost=CostFunction(pop(i).Position,tb,bitt);
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(MaxIt,1);
c1=1;
%% PSO Main Loop
for it=1:MaxIt oneadd_cat=zeros(nPop,nVar); zeroadd_cat=zeros(nPop,nVar); dd3_cat=c2_cat*rand; % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *for t_i=1:nPop
for g_i=1:nVar
if(GlobalBest.Position(g_i)==0)
oneadd_cat(t_i,g_i)=oneadd_cat(t_i,g_i)-dd3_cat;
zeroadd_cat(t_i,g_i)=zeroadd_cat(t_i,g_i)+dd3_cat;
else
oneadd_cat(t_i,g_i)=oneadd_cat(t_i,g_i)+dd3_cat;
zeroadd_cat(t_i,g_i)=zeroadd_cat(t_i,g_i)-dd3_cat;
end
end
end
one_vel_cat=w_cat*one_vel_cat+oneadd_cat;
zero_vel_cat=w_cat*zero_vel_cat+zeroadd_cat;
for t_i=1:nPop
for g_i=1:nVar
if(abs(vel_cat(t_i,g_i))>vmax_cat)
one_vel_cat(t_i,g_i)=vmax_cat*sign(one_vel_cat(t_i,g_i));
zero_vel_cat(t_i,g_i)=vmax_cat*sign(zero_vel_cat(t_i,g_i));
end
end
end
for t_i=1:nPop
for g_i=1:nVar
if(pop(t_i).Position(g_i)==1)
vel_cat(t_i,g_i)=zero_vel_cat(t_i,g_i);
elsevel_cat(t_i,g_i)=one_vel_cat(t_i,g_i); end end end veln_cat=logsig(vel_cat); % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *for i=1:nPop
if(pop(i).flag==0)
for r2=1:nVar
if(rand<veln_cat(i,r2))
pop(i).Position(r2)=GlobalBest.Position(r2);
else
pop(i).Position(r2)=pop(i).Position(r2);
end
end
pop(i).Cost = CostFunction(pop(i).Position,tb,bitt);
else
copy_cat=repmat(pop(i).Position,SMP,1);
pop(i).Position=mutate(copy_cat,nVar,nb,SRD,tb,bitt);
end
try
pop(i).Cost = CostFunction(pop(i).Position,tb,bitt);
catch tt
disp('ll');
end
% Update Global Best
if pop(i).Cost<=GlobalBest.Cost
GlobalBest=pop(i);
end
end
function z=cost_function(x,tb,bitt)
up=50;
low=- 50;
upb=mybin2dec(ones(1,bitt));
lowb=mybin2dec(zeros(1,bitt));
xn=[];
for j=1:tb
x1=x(1+(j- 1)*bitt:j*bitt);
x1=mybin2dec(x1)/(upb-lowb)*(up-low)+low;
xn=[xn x1];
end
% function for test fw
val=0;
n=size(xn,2);
for i=1:n
val=val+(xn(1)-xn(i)^2) ^2+(xn(i)- 1) ^2;
end
z=val;
Copy the code
3. Operation results
Fourth, note
Version: 2014a complete code or write plus 1564658423