%--------------------------------------------------------------------------
% Modified ABC-PTS Algorithm in Matlab
% Reference:
% 1) D. Karaboga, B. Basturk, On The Performance Of Artificial Bee Colony (ABC)
% Algorithm, Applied Soft Computing,Volume 8, Issue 1, January 2008, Pages 687-697
% 2) Y. Wang, W. Chen, and C. Tellambura, A PAPR Reduction Method
% Based on Artificial Bee Colony Algorithm for OFDM Signals,IEEE Transactions on Wireless Communications, 2010, pp.2994-2999.
%
% Author: Leo Zhu , Yulong Guo
% South China University of Technology , 510640 Guangzhou, China
% Email: scut_ee@163.com
%--------------------------------------------------------------------------
clear all;close all;clc
Int=1;
%/* Control Parameters of ABC algorithm*/
NP=64; FoodNumber=NP/2; %/*The number of food sources equals the half of the colony size*/
maxCycle=32; %/*The number of cycles for foraging {a stopping criteria}*/
D=16; %/*The number of parameters of the problem to be optimized*/ % PTS Blocks
%limit=FoodNumber*D; %/*A food source which could not be improved through "limit" trials is abandoned by its employed bee*/
limit=10; %/*A food source which could not be improved through "limit" trials is abandoned by its employed bee*/
K=256; % OFDM Subcarriers
L=4*K;
Max_Symbols=1e3; % 1e2 is ok for approximation
pset = [1 -1];
%--------------------------------------------------------------------------
t_32_32_Verified_Set=zeros(1,Max_Symbols);
%--------------------------------------------------------------------------
while(Int==1)
% objfun='PAPR_Val_Phase2'; %cost function to be optimized
ub=ones(1,D-1)*2; %/*lower bounds of the parameters. */
lb=ones(1,D-1)*1;%/*upper bound of the parameters.*/
PAPR_Orignal = zeros(1,Max_Symbols);
%PAPR_Orignal_ = zeros(1,Max_Symbols);
PAPR_PTS = zeros(1,Max_Symbols);
%PAPR_PTS_ = zeros(1,Max_Symbols);
Int=2;
end
for nSymbol=1:Max_Symbols
%--------------------------------------------------------------------------
tic
%--------------------------------------------------------------------------
% /*All food sources are initialized */
%/*Variables are initialized in the range [lb,ub]. If each parameter has different range, use arrays lb[j], ub[j] instead of lb and ub */
Range = repmat((ub-lb),[FoodNumber 1]);
Lower = repmat(lb, [FoodNumber 1]);
Foods = [ones(1,FoodNumber)',(randint(FoodNumber,D-1) .* Range + Lower)]; %Phase_Set Init
%--------------------------------------------------------------------------
%QPSK=OFDM_Init; % OFDM Symbol Initialization --> QPSK Modulation
%QPSK_Set = [1 -1 1i -1i ]; % QPSK Modulation
%--------------------------------------------------------------------------
QAM_Set= [-3+3j, -3+1j, -3-1j, -3-3j,...
-1+3j, -1+1j, -1-1j, -1-3j, ...
1+3j, 1+1j, 1-1j, 1-3j,....
3+3j, 3+1j, 3-1j, 3-3j];
Index = randint(1,K,length(QAM_Set))+1; % Index for QPSK
QPSK=QAM_Set(Index);
ObjVal_Orignal=PAPR_Init(QPSK); % --------------------------PAPR Calculation for oringinal OFDM Symbol
PAPR_Orignal(nSymbol) = ObjVal_Orignal; % PAPR_Orignal(nSymbol)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
IFFT=PTS_Init_IFFT(QPSK,D,K);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ObjVal=PAPR_Val_Phase2(IFFT,Foods,L); % --------------------------PAPR Calculation for PTS based OFDM Symbol
Fitness=calculateFitness(ObjVal);
%reset trial counters
trial=zeros(1,FoodNumber);
%/*The best food source is memorized*/
BestInd=find(ObjVal==min(ObjVal));
BestInd=BestInd(end);
GlobalMin=ObjVal(BestInd);
GlobalParams=Foods(BestInd,:);
%--------------------------------------------------------------------------
Global_Tmp=GlobalParams; % For GBest ABC-PTS
%--------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
step = Max_Symbols /100; % Set the parameters of waitbar
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
iter=1;
while ((iter <= maxCycle)),
%%%%%%%%% EMPLOYED BEE PHASE %%%%%%%%%%%%%%%%%%%%%%%%
for i=1:(FoodNumber)
%/*The parameter to be changed is determined randomly*/
Param2Change=fix(rand*(D-1))+2;
%/*A randomly chosen solution is used in producing a mutant solution of the solution i*/
neighbour=fix(rand*(FoodNumber))+1;
%/*Randomly selected solution must be different from the solution i*/
while(neighbour==i)
neighbour=fix(rand*(FoodNumber))+1;
end;
sol=Foods(i,:);
% /*v_{ij}=x_{ij}+\phi_{ij}*(x_{kj}-x_{ij}) */
%sol(Param2Change)=fix(Foods(i,Param2Change)+(Foods(i,Param2Change)-Foods(neighbour,Param2Change))*(rand-0.5)*2); %fix to integer
%sol(Param2Change)=fix(Foods(i,Param2Change)*(1-rand)+Global_Tmp(Param2Change)*rand);
%%{
sol(Param2Change)=(Foods(neighbour,Param2Change)-Foods(i,Param2Change))*rand*(0.7*(maxCycle-iter)/maxCycle+0.3)+....
Global_Tmp(1,Param2Change)*(1-rand)*(0.3*iter/maxCycle+0.7);
sol(Param2Change)=fix(sol(Param2Change))+1;
%}
% /*if generated parameter value is out of boundaries, it is shifted onto the boundaries*/
if(sol(Param2Change)<1)
sol(Param2Change)=1;
end
if(sol(Param2Change)>2)
sol(Param2Change)=2;
end
%evaluate new solution
ObjValSol=PAPR_Val_Phase2(IFFT,sol,L); % -----------------PAPR Calculation for each solution
FitnessSol=calculateFitness(ObjValSol);
% /*a greedy selection is applied between the current solution i and its mutant*/
if (FitnessSol>Fitness(i))
Foods(i,:)=sol; %---------------------------------------------------- Foods updated
Fitness(i)=FitnessSol;
ObjVal(i)=ObjValSol; % -----------------PAPR Comparison for each solution
trial(i)=0;
else
trial(i)=trial(i)+1; %/*if the solution i can not be improved, increase its trial counter*/
end;
end;
%%%%%%%%%%%%%%%%%%%%%%%% CalculateProbabilities %%%%%%%%%%%%%%%%%%%%%%%%%%%
%/* A food source is chosen with the probability which is proportioal to its quality*/
%/*Different schemes can be used to calculate the probability values*/
%/*For example prob(i)=fitness(i)/sum(fitness)*/
%/*or in a way used in the metot below prob(i)=a*fitness(i)/max(fitness)+b*/
%/*probability values are calculated by using fitness values and normalized by dividing maximum fitness value*/
%prob=(0.9.*Fitness./max(Fitness))+0.1;
prob=Fitness/sum(Fitness);
%%%%%%%%%%%%%%%%%%%%%%%% ONLOOKER BEE PHASE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
i=1;
t=0;
while(t<FoodNumber)
%t=t+1; %%%%%%%%%%%%%%%%%%%%%%%%%%%%
if(rand<prob(i))
t=t+1;
%/*The parameter to be changed is determined randomly*/
Param2Change=fix(rand*(D-1))+2;
%/*A randomly chosen solution is used in producing a mutant solution of the solution i*/
neighbour=fix(rand*(FoodNumber))+1;
%--------------------------------------------Use Global_Tmp Instead
%%{
基于matlab的改进型人工蜂群算法
4星 · 超过85%的资源 需积分: 46 173 浏览量
2014-04-10
12:41:46
上传
评论 8
收藏 9KB ZIP 举报
spacehstar
- 粉丝: 4
- 资源: 7