|
基于布谷鸟算法的导航波束形成问题:
百度网盘链接:
链接:http://pan.baidu.com/s/1hsmpdJ2
具体链接在halcom.cn论坛,联系人QQ:3283892722
该论坛是一个学习交流平台,我会逐一的和大家分享学习。
欢迎大家录制视频,你可在论坛进行打赏分享。
视频专用播放器:http://halcom.cn/forum.php?mod=viewthread&tid=258&extra=page%3D1\
具体的代码如下:- % 布谷鸟函数优化分析
- % cuckoo_search -- CS算法
- %% 清空环境
- clc % 清屏
- clear all; % 删除workplace变量
- close all; % 关掉显示图形窗口
- warning off; % 消除警告
- tic
- %% 参数初始化
- maxiter = 20; % 迭代次数
- sizepop = 20; % 种群规模
- pa=0.25; % 发现新巢的概率Discovery rate of alien eggs/solutions
- % M K phi
- popmin = [2, 0, 331, 31, 91, 151, 211, 271]; % x 最小值
- popmax = [6, 1, 390, 90, 150, 210, 270, 330]; % x 最大值
- nvar = 8; % 未知量个数
- % 导航-波束形成问题
- theta_signal=50; % 俯仰角
- phi_signal=200; % 方位角
- % 产生初始粒子
- for i=1:sizepop
- nest(i,:)= popmin+(popmax-popmin).*rand(size(popmin)) ;
- fitness(i)= fun( [nest(i,1), nest(i,2)*50000, nest(i,3:nvar)], theta_signal,phi_signal ); % 适应度函数值--目标函数值--求解全局的极大值
- end
- % 找当前最好的个体
- [fmax,bestindex]=max(fitness);
- bestnest=nest(bestindex,:); % 全局最佳
- %% 寻优
- for i=1:maxiter
- disp(['Iteration ' num2str(i)]);
- % 粒子位置更新
- new_nest=get_cuckoos(nest,bestnest,popmin,popmax); % Levy flights 粒子位置更新
- % 比较更新
- [fnew,best,nest,fitness]=get_best_nest(nest,new_nest,fitness, theta_signal,phi_signal);
- % 发现新巢、随机粒子的位置
- new_nest=empty_nests(nest,popmin,popmax,pa) ;
- % 继续评估新巢的适应度值
- [fnew,best,nest,fitness]=get_best_nest(nest,new_nest,fitness, theta_signal,phi_signal);
- % 寻找全局最优解
- if fnew>fmax,
- fmax=fnew;
- bestnest=best;
- end
-
- CS_yy(i)=fmax; % 保存极大值
- end % 结束迭代循环
- CS_fitness_iter = CS_yy;
- time = toc
- save CS_fitness_iter.mat
- %% 结果分析
- plot(CS_yy,'bo-','Linewidth',2)
- title(['适应度曲线 ' '终止代数=' num2str(maxiter)]);
- grid on
- xlabel('进化代数');ylabel('适应度');
- % 结果输出
- disp('最优解')
- zbest_result = fix( [ bestnest(1),bestnest(2)*50000, bestnest(3:nvar)] );
- disp(zbest_result) % 最佳个体值
- fprintf('\n')
- %% 结果
- tic
- [fitness_zbest, F]= fun(zbest_result, theta_signal, phi_signal);
- time1 = toc
- figure,
- plot(0:359, F(:,50)); grid on %截面图:
- xlabel('方位角');
- ylabel('增益(dB)');
- title('俯仰角50度时截面')
复制代码 寻找新的解:
- function new_nest=empty_nests(nest,Lb,Ub,pa)
- % A fraction of worse nests are discovered with a probability pa
- n=size(nest,1);
- % Discovered or not -- a status vector
- K=rand(size(nest))>pa;
- %% New solution by biased/selective random walks
- stepsize=rand*(nest(randperm(n),:)-nest(randperm(n),:));
- new_nest= nest+stepsize.*K;
- for j=1:size(new_nest,1)
-
- for k=1:length(nest(j,:))
- if new_nest(j,k)>Ub(k)
- new_nest(j,k)=Ub(k);
- end
- if new_nest(j,k)<Lb(k)
- new_nest(j,k)=Lb(k);
- end
- end
-
- end
复制代码 寻找当前最优的解:
- function [fmax,best,nest,fitness]=get_best_nest(nest,newnest,fitness, theta_signal,phi_signal)
- % Evaluating all new solutions
- for j=1:size(nest,1),
- % fnew=Ackley_Fun(newnest(j,:)); % 适应度值
- fnew= fun( [newnest(j,1), newnest(j,2)*50000,newnest(j, 3:end) ], theta_signal,phi_signal ); % 适应度函数值--目标函数值--求解全局的极大值
-
- if fnew>=fitness(j),
- fitness(j)=fnew;
- nest(j,:)=newnest(j,:);
- end
- end
- % Find the current best
- [fmax,K]=max(fitness) ;
- best=nest(K,:);
复制代码 位置更新:
- % 位置更新
- function nest=get_cuckoos(nest,best,Lb,Ub)
- % Levy flights
- n=size(nest,1);
- % Levy exponent and coefficient
- beta=3/2;
- sigma=(gamma(1+beta)*sin(pi*beta/2)/(gamma((1+beta)/2)*beta*2^((beta-1)/2)))^(1/beta);
- for j=1:n,
- s=nest(j,:);
- % implementing Levy flights
- % For standard random walks, use step=1;
- %% Levy flights by Mantegna's algorithm
- u=randn(size(s))*sigma;
- v=randn(size(s));
- step=u./abs(v).^(1/beta);
- stepsize=0.01*step.*(s-best);
- nest(j,:) = s+stepsize.*randn(size(s));
- % Apply simple bounds/limits
- for k=1:length(nest(j,:))
- if nest(j,k)>Ub(k)
- nest(j,k)=Ub(k);
- end
- if nest(j,k)<Lb(k)
- nest(j,k)=Lb(k);
- end
- end
-
- end
复制代码
适应度函数:
- function [fitness, F]= fun(x, theta_signal, phi_signal)
- % 输入:
- % theta_signal=50; % 俯仰角
- % phi_signal=200; % 方位角
- % x:
- % N=7; % 阵元数目
- % M=6; % 延迟数目
- % K=5000; % 快拍数
- % 输出:
- % fitness:适应度值,主瓣-旁瓣的差值最大
- % F:输出的beampattern
- % x=fix(x); % 取整
- N = 7; % 阵元数目
- M = fix(x(1)); % 延迟数目
- K = fix(x(2)); % 快拍数
- m=[0:M-1]';
- c=3*10^8; % 光速
- f0=1.26852*10^9; % 信号中心频率
- fs=5*10^9; % 采样频率
- Ts=1/fs; % 单位时延
- t = 0:Ts:(K*Ts-Ts);
- wl=c/f0; % 信号波长
- r=wl/2; % 圆阵半径
- % phi1=[0, 60, 120, 180, 240, 300]; % 圆周上阵元角度位置 6围1圆阵
- % phi1 = 0:360/(N-1):360-360/(N-1);
- phi1 = fix( x(3:end) );
- P=[zeros(2,1), r*[cos(phi1*pi/180);sin(phi1*pi/180)]]; % 位置
- % theta_signal=50; % 俯仰角
- % phi_signal=200; % 方位角
- theta_inter=40; % 干扰1
- phi_inter=50;
- theta_inter2=60; % 干扰2
- phi_inter2=250;
- theta_inter3=50; % 干扰3
- phi_inter3=60;
- theta_inter4=30; % 干扰4
- phi_inter4=120;
- theta_inter5=30; % 干扰5
- phi_inter5=80;
- waven_signal=[sin(theta_signal*pi/180)*cos(phi_signal*pi/180), sin(theta_signal*pi/180)*sin(phi_signal*pi/180) ]; % 信号波数(wavenumber)
- waven_inter=[sin(theta_inter*pi/180)*cos(phi_inter*pi/180), sin(theta_inter*pi/180)*sin(phi_inter*pi/180)];
- waven_inter2=[sin(theta_inter2*pi/180)*cos(phi_inter2*pi/180), sin(theta_inter2*pi/180)*sin(phi_inter2*pi/180)];
- waven_inter3=[sin(theta_inter3*pi/180)*cos(phi_inter3*pi/180), sin(theta_inter3*pi/180)*sin(phi_inter3*pi/180)];
- waven_inter4=[sin(theta_inter4*pi/180)*cos(phi_inter4*pi/180), sin(theta_inter4*pi/180)*sin(phi_inter4*pi/180)];
- waven_inter5=[sin(theta_inter5*pi/180)*cos(phi_inter5*pi/180), sin(theta_inter5*pi/180)*sin(phi_inter5*pi/180)];
- snr1=-20; % 信噪比
- inr1=30; % 干噪比
- inr2=30;
- inr3=30;
- inr4=30;
- inr5=30;
- s_a0=exp(j*2*pi/wl*(waven_signal*P)'); % 期望信号1
- s_a1=exp(j*2*pi/wl*(waven_inter*P)'); % 干扰1
- s_a2=exp(j*2*pi/wl*(waven_inter2*P)'); % 干扰2
- s_a4=exp(j*2*pi/wl*(waven_inter3*P)');
- s_a5=exp(j*2*pi/wl*(waven_inter4*P)');
- s_a6=exp(j*2*pi/wl*(waven_inter5*P)');
- t_a=exp(j*2*pi*f0*Ts*m);
- steer_signal=kron(t_a,s_a0); % Kronecker积,期望及干扰导向矢量
- steer_jamming1=kron(t_a,s_a1);
- steer_jamming2=kron(t_a,s_a2);
- steer_jamming3=kron(t_a,s_a4);
- steer_jamming4=kron(t_a,s_a5);
- steer_jamming5=kron(t_a,s_a6);
- C=[steer_signal]; % 构造线性约束 C'W=G
- g=[1]; % 两个目标的无失真约束
- amp_signal=sqrt(2*10^(snr1/10))*cos(2*pi*f0*t+randn); % 信号加上个随机相位
- %白噪声干扰,同时也属于宽带干扰
- amp_jamming1=sqrt(10^(inr1/10))*randn(1,K);
- amp_jamming2=sqrt(10^(inr2/10))*randn(1,K);
- amp_jamming3=sqrt(10^(inr3/10))*randn(1,K);
- amp_jamming4=sqrt(10^(inr4/10))*randn(1,K);
- amp_jamming5=sqrt(10^(inr5/10))*randn(1,K);
- %amp_jamming1=sqrt(10^(inr1/10))*wgn(1,K,0,'complex');
- %amp_jamming2=sqrt(10^(inr2/10))*wgn(1,K,0,'complex');
- %amp_jamming3=sqrt(10^(inr3/10))*wgn(1,K,0,'complex');
- %amp_jamming4=sqrt(10^(inr4/10))*wgn(1,K,0,'complex');
- %amp_jamming5=sqrt(10^(inr5/10))*wgn(1,K,0,'complex');
- % 单音干扰
- %amp_jamming1= sqrt(2*10^(inr1/10))*sin(2*pi*f0*t+randn);
- %amp_jamming2= sqrt(2*10^(inr2/10))*sin(2*pi*f0*t+randn);
- %amp_jamming3= sqrt(2*10^(inr3/10))*sin(2*pi*f0*t+randn);
- %amp_jamming4= sqrt(2*10^(inr4/10))*sin(2*pi*f0*t+randn);
- %amp_jamming5= sqrt(2*10^(inr5/10))*sin(2*pi*f0*t+randn);
- noise=(randn(N*M,K));
- jam=steer_jamming1*amp_jamming1+steer_jamming2*amp_jamming2+steer_jamming3*amp_jamming3...
- +steer_jamming4*amp_jamming4+steer_jamming5*amp_jamming5;
- %jam=steer_jamming2*amp_jamming2;
- SS=steer_signal*amp_signal;
- X=SS+jam+noise; % 接收信号(信号+干扰+噪声)
- OO=jam+noise;
- Rs = 1/K*SS*SS';
- Rni=1/K*OO*OO';
- Rn=1/K*noise*noise';
- Ri=1/K*jam*jam';
- Rr=Rn+Ri;
- Rx = 1/K*X*X';
- invR=inv(Rx);
- W_LCMV=g'*inv(C'*invR*C)*C'*invR;
- theta=(0:1:89)*pi/180;
- phi =(0:1:359)*pi/180;
- beam = zeros(360, 90);
- for ii=1:length(phi)
- tempphi=phi(ii);
- waven_sweep=[(sin(theta).*cos(tempphi))', (sin(theta)*sin(tempphi))'];
- svsweep=exp(j*2*pi/wl*(waven_sweep*P)');
- steer = kron(t_a, svsweep);
- beam(ii,:)=W_LCMV*steer;
- end
-
- F=20*log10(abs(beam)/max((max(abs(beam))))); % beampattern
- % ref_point = 200; % 该坐标位置值越大越好
- % fitness1 = fun_F(F, 70, ref_point);
- % fitness2 = fun_F(F, 60, ref_point);
- % fitness3 = fun_F(F, 50, ref_point);
- % fitness4 = fun_F(F, 40, ref_point);
- % fitness5 = fun_F(F, 30, ref_point);
- % fitness = fitness1 + fitness2 + fitness3 + fitness4 + fitness5;
- ref_point = phi_signal; % 该坐标位置值越大越好
- fitness = fun_F(F, theta_signal, ref_point);
- clear invR jam C c beam amp_jamming1 amp_jamming2 amp_jamming3 amp_jamming4 amp_jamming5 SS
- clear steer_jamming1 steer_jamming2 steer_jamming3 steer_jamming4 steer_jamming5
复制代码 funF极值求解函数:
参考文献:【1】Symmetric Linear Antenna Array Geometry Synthe
【2】THINNING OF PLANAR CIRCULAR ARRAY ANTENNAS USING FIREFLY ALGORITHM
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|