tic;
clear all;
clc;
%% Parameters
Pt = 1; % transmitter's power
sigma2 = 10^(-90*0.1); % antenna's noise -0 dB
N = 6; % 6 subcarriers
K = 3; % 3 users
M = 1; % 3 tranmist antennas
L = 4; % 4 channel delay taps
xi = 0.4; % harvesting efficiency
constraintE = 100e-6; % minimum required E
trials=700;
iter = 70;
inertia = rand; % w
coefficient = rand(1,2)*2; %c1,c2
numParticle = 200; %¨Ó¹Ç¹Í¹ØÀÒ¤
meansecrecy = 0;
penalty = 10000;
%% Fisrt round
h = (randn(M,L,K)+1i*randn(M,L,K))/sqrt(2*L); % uniform
H = fft(h,N,2);
rho=rand(numParticle,K);
Velocity=rand(numParticle,K);
pbest=rho;
for u=1:K
for m=1:numParticle
obtain(m,u)=(xi*rho(m,u)*Pt/N/M*sum(sum(abs(H(:,:,u)).^2))+ sigma2)+(constraintE - obtain(m,u))*penalty > 0.';
end
end
end
for indexStar = 1:K^N
%indexStar
kstar = dec2base(indexStar-1,K,N)-47;
for l=1:numParticle
if all(obtain(l,:))>=constraintE
for n=1:N
for k=1:K
r(k,n) = log2(1+Pt/N/M*(1-rho(l,k))/sigma2*abs(H(:,n,k))^2);
end
rTemp = r(:,n);
rTemp(kstar(n)) = 0;
new_secrecyrate(n) = max(r(kstar(n),n) - max(rTemp),0);
end
for u = 1:K
secrecyrateUser(:,u) = sum(new_secrecyrate(kstar==u));
end
meansecrecy(l)= mean(secrecyrateUser);
end
end
[dummy,bestrho] = max(meansecrecy);
gbest=pbest(bestrho,:);
r=rand(1,2);
Velocity=inertia*Velocity+coefficient(1)*r(1)*(pbest-rho)+coefficient(2)*r(2)*(repmat(gbest,numParticle,1)-rho);
rho=rho+Velocity;
end
toc
i want to intstall constain optimization and penalty help me please

댓글 수: 3

Sargondjani
Sargondjani 2019년 2월 5일
try fmincon. or if you want to program it yourself, check the references therein.
Siraphop K.
Siraphop K. 2019년 2월 5일
Thank you. We can't found line at install constainE in matlab. I try to repair. Can you recomment me again. This is constain (constraintE - all(obtain(l,:)) > 0)
Walter Roberson
Walter Roberson 2019년 2월 5일
that looks like a lb (lower bound) of eps(realmin)

댓글을 달려면 로그인하십시오.

답변 (0개)

태그

질문:

2019년 2월 5일

댓글:

2019년 2월 5일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by