📄 objective_function.m
字号:
%目标函数-——状态评估函数
function E=objective_function(Location_frequency,frequency,N,coordinate,d0,d1,d2,m,dir)
%注:(d2<d1<d0)为同频、邻频、同址频率约束门限,
%m为信道之间的间隔不能等于的几个整数值
p_vio=0 ; %代表违反的约束条件的个数
p_sum=0 ; %代表各个约束条件被违反的次数总和
p_num=length(frequency) ; %代表使用的不同频率的个数
p_wav=0;
p_three=0;
p_same=0;
p_near=0;
p_address=0;
I_vio=0 ; %两频率之间的差值用I_vio表示
i=1;
u1=2; %目标函数的权值,反映不同参数的相对重要性
u2=10;
u3=4;
u4=2;
u5=2;
u6=4;
u7=4;
x=zeros(2,1);
number=0;
angle=0;
diatance1=0;
distance2=0;
distance3=0;
M=0;
xx=Location_frequency(3,:);
r=length(xx);
yy=[];
while i<=N
for j=(i+1):N
distance1=norm(coordinate(:,i)-coordinate(:,j)); %计算任意两个移动站i和j之间的距离
I_vio=abs(Location_frequency(3,i)-Location_frequency(3,j)); %计算两个移动站i和j所发射频率的差值
%同信道约束
if distance1<100
if distance1<d0 %如果两个发射机相隔的距离小于某个指定值d0时,
%分配给它们的频率不能相同
if Location_frequency(3,i)==Location_frequency(3,j)
p_vio=p_vio+1;
p_sum=p_sum+1;
p_same=p_same+1;
same_frequency(i,:)=[i;j];
end
end
%相邻信道约束
if distance1<d1 %当两个发射台的距离小于某一指定值d1 时,
if I_vio<=1 %分配给这对发射台的信道不能为相邻信道
p_vio=p_vio+1;
p_sum=p_sum+1;
p_near=p_near+1;
number=number+1;
near_frequency(i,:)=[i;j];
x=coordinate(:,j);
distance2=distance1;
end
%最小方向角度间隔
if number>1
distance3=norm(coordinate(:,j)-x(:));
angle=acos((distance1^2+distance2^2-distance3^2)/(2*distance1*distance2));
if angle>(dir*pi/180)
p_wav=p_wav+1;
wav_frequency(i,:)=[i,j];
number=1;
end
end
end
%同址频率间隔
if distance1<d2 %同址的任意一对发射机的频率之间必须间
%隔一定数量的信道
if I_vio<=m
p_vio=p_vio+1;
p_sum=p_sum+1;
p_address=p_address+1;
address_frequency(i,:)=[i;j];
end
end
end
end
i=i+1;
end
%无三阶互调干扰
while p_num~=0
p_num=p_num-1;
M=M+p_num;
end
while r>1
for p=1:(r-1)
q=p+1;
xx(1,p)=abs(xx(p)-xx(q));
yy=[yy xx(1,p)];
end
r=r-1;
end
for i=1:(length(yy)-1)
for j=(i+1):length(yy)
if yy(i)==yy(j)
p_three=p_three+1;
end
end
end
E=u1*p_vio+u2*p_sum+u3*p_same+u4*p_near+u5*p_address+u6*p_wav+u7*p_three ; %状态评估函数
% fprintf('\t\t\t同频干扰个数=%d\n',p_same);
%
% fprintf('\t\t\t邻频干扰个数=%d\n',p_near);
%
% fprintf('\t\t\t违犯同址间隔个数=%d\n',p_address);
%
% fprintf('\t\t\t方向性干扰个数=%d\n',p_wav);
%
% fprintf('\t\t\t互调干扰个数=%d\n',p_three);
return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -