Incorrect values when calculating the optimum value using while loop
Mostra commenti meno recenti
Dear all,
Please I'm trying to get the optimum power allocation Pk using while loop.. but it seems that I wrongly writing this algorithm and all values are equal to 1 without making alot of iterations... please can any one help me to correct the code.. I appreciate your help.




This is my code:
%parameters
TN=10
lamda=[5.3899,2.8511,1.0846,0.4003,2.8364,0.0988,0.0470,0.3417,0.5460,0.5992];
segma_squared=10^-9; %variance
tau=0.1;
Pt=1;
beta= [0.3414,0.1707,0.1138,0.0854,0.0683,0.0569,0.0488,0.0427,0.0379,0.0341];
epsilon=0.001
%%%%%%%%%%%starting of algorithm 1%%%%%%%%%%%%%%%
max_iterations=1000;
power_allocation_initial=[5.3899,4.435,1.1024,0.4004,2.854,0.109988,0.0470,0.3417,0.3450,0.6592];
for i=2:max_iterations
for k=1:TN
gamma_infinity(i,k)=(lamda(k)*(1-tau^2)*power_allocation_initial(k)*Pt)/(segma_squared); % calculation initial value of gamma_inf(0)
w_k(k)=log2(power_allocation_initial(k));
while (gamma_infinity(i,k)-gamma_infinity(i-1,k) >= epsilon)
i=i+1;
gamma_infinity(i,k)=gamma_infinity(i-1,k);
k_(k)=(gamma_infinity(i,k))/(1+gamma_infinity(i,k));
v_k(k)=log2(1+gamma_infinity(i,k))-((gamma_infinity(i,k))/(1+gamma_infinity(i,k)))*log2(gamma_infinity(i,k));
eita_wk(i,k)=-k_(k) *w_k(k)-k_(k)*log2(lamda(k)*(1-tau^2))*Pt + 2*k_(k)*log2(sqrt(segma_squared))-v_k(k);
w(i,k)=beta(k)*eita_wk(i,k);
ww(i)=sum(w(i,k));
[p_opt(k),fval] = linprog(ww(i),[],[],[],[],0,1);
end
end
end
6 Commenti
Torsten
il 20 Nov 2022
It would be helpful to know what problem (25) is.
bassant tolba
il 20 Nov 2022
You do the same mistake as before:
You try to decouple the problem and minimize one single ww(k):
[p_opt(k),fval] = linprog(ww(i),[],[],[],[],0,1);
although you are told to minimize sum(beta_k*gamma(ww(k))
So in short: Delete the loop over k - all values p(k) for k in K (so the complete vector p) have to be determined simulaneously by solving your optimization problem.
bassant tolba
il 20 Nov 2022
Modificato: bassant tolba
il 20 Nov 2022
Don't you see from the description of the algorithm that the optimization problem has to be solved within the while-loop and not outside ?
And now that you search for a vector p of length 10, your upper and lower bounds also have to be vectors of length 10. But you set them to 0 and 1 - so just one value.
And what is the for-loop good for ? Isn't it a superfluous duplicate of the while-loop ?
bassant tolba
il 20 Nov 2022
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
