注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

being23

写给未来的自己

 
 
 

日志

 
 
关于我

真正的坚定,就是找到力量去做自己喜欢的事情,并为之努力,这样才会觉得生活是幸福的。

网易考拉推荐

类注水法和GS搜索法 功率分配  

2010-12-16 18:50:29|  分类: 研二上 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

%Approximate Water-Filling Power Allocation(AWFPA)
%Author: Qi.Coding
%Date: Dec.16,2010
%Add. Lab.907

% K: number of users
% P: power per user
function[Pk] = AWFPA(sinr, P, K)

Pt = P*K; %total transmitter power

%sort sinr in descending order
[sinr_des, i_sinr_des] = sort(sinr, 'descend');
nuser = K;

while(1)
    Pk = zeros(1, nuser);
    v_rep = (sum(1./sinr_des(1:K)) + Pt)/K;
    Pk(i_sinr_des(1:K)) = v_rep - 1./sinr_des(1:K);
    if Pk(i_sinr_des(1:K)) > 0
        break;
    end   
    K = K - 1;
end

%Modified Gauss-Seidel Power Allocation based on Grid Search(MGSPA)
%Author: Qi.Coding
%Date: Dec.21,2010
%Add. Lab.907

% K: number of users
% P: power per user

function [sumrate_new, SINR, pa] = MGSPA_v02(P, K, Nt, H, V, U, th, Np)

% Np = 100;
%assuming equal power allocation at first
pa = ones(1, K)*P;
sumrate_last = 0;
SINR = zeros(1, K);

while(1)

    sumrate = zeros(K, Np+1);   
    for i_usr = 1: K
        i_diff_vec = (1: K) - i_usr;
        %index to the rest users
        i_rest_vec = find(abs(i_diff_vec));
        %power of current user
        p_cur = P*K - sum(pa(i_rest_vec));
        step = p_cur/Np;
        %direct channel to current user
        H_cur = H(((1 + Nt*(i_usr - 1)):(Nt*i_usr)), ((1 + Nt*(i_usr - 1)):(Nt*i_usr)));
        for i_grid = 0: Np
            %current user
            pps = i_grid*step;
            sp_cur = pps*U(:, i_usr)'*H_cur*V(:, i_usr)*(U(:, i_usr)'*H_cur*V(:, i_usr))';
            ip_rest = 0;
            for i_inte = 1: K - 1           
                i_rest = i_rest_vec(i_inte);
                H_inte = H(((1 + Nt*(i_usr - 1)):(Nt*i_usr)),...
                           ((1 + Nt*(i_usr - 1)) + i_diff_vec(i_rest)*Nt:(Nt*i_usr) + i_diff_vec(i_rest)*Nt));
                ip_rest = ip_rest + pa(i_rest)*U(:, i_usr)'*H_inte*V(:, i_rest)*(U(:, i_usr)'*H_inte*V(:, i_rest))';
            end           
            sumrate_cur = log2(1 + abs(sp_cur)/(1 + abs(ip_rest)));
            %rest users
            sumrate_rest = 0;
            for i_inte = 1: K - 1
                %current user of all the rest users
                i_rest_cur = i_rest_vec(i_inte);
                H_rest_cur = H(((1 + Nt*(i_rest_cur - 1)):(Nt*i_rest_cur)), ((1 + Nt*(i_rest_cur - 1)):(Nt*i_rest_cur)));
                sp_rest_cur = pa(i_rest_cur)*U(:, i_rest_cur)'*H_rest_cur*V(:, i_rest_cur)*(U(:, i_rest_cur)'*H_rest_cur*V(:, i_rest_cur))';
                H_rest2_cur = H(((1 + Nt*(i_rest_cur - 1)):(Nt*i_rest_cur)), ((1 + Nt*(i_usr - 1)):(Nt*i_usr)));
                ip_cur = pps*U(:, i_rest_cur)'*H_rest2_cur*V(:, i_usr)*(U(:, i_rest_cur)'*H_rest2_cur*V(:, i_usr))';
                i_diff_rest_vec = i_rest_vec - i_rest_cur;
                i_rest_rest_vec = find(abs(i_diff_rest_vec));
                ip_rest2 = 0;
                for i_inte_rest = 1: K - 2;
                        i_rest_rest2 = i_rest_rest_vec(i_inte_rest);
                        H_inte_rest = H(((1 + Nt*(i_rest_cur - 1)):(Nt*i_rest_cur)),...
                           ((1 + Nt*(i_rest_cur - 1)) + i_diff_rest_vec(i_rest_rest2)*Nt:(Nt*i_rest_cur) + i_diff_rest_vec(i_rest_rest2)*Nt));
                        ip_rest2 = ip_rest2 + pa(i_rest_vec(i_rest_rest2))*U(:, i_rest_cur)'*H_inte_rest*V(:, i_rest_vec(i_rest_rest2))*...
                            (U(:, i_rest_cur)'*H_inte_rest*V(:, i_rest_vec(i_rest_rest2)))';
                end
                sumrate_rest = sumrate_rest + log2(1 + abs(sp_rest_cur)/(1 + abs(ip_rest2 + ip_cur)));
            end
            sumrate(i_usr, i_grid + 1) = sumrate_cur + sumrate_rest;   
        end
        [sumrate_max, i_max] = max(sumrate(i_usr, :));
        pa(i_usr) = (i_max - 1)*step;
    end
    sumrate_new = 0;
    for i_usr = 1: K
        i_diff_vec = (1: K) - i_usr;
        %index to the rest users
        i_rest_vec = find(abs(i_diff_vec));
        H_cur = H(((1 + Nt*(i_usr - 1)):(Nt*i_usr)), ((1 + Nt*(i_usr - 1)):(Nt*i_usr)));
        sp_cur = pa(i_usr)*U(:, i_usr)'*H_cur*V(:, i_usr)*(U(:, i_usr)'*H_cur*V(:, i_usr))';
        ip_rest = 0;
        for i_inte = 1: K - 1           
            i_rest = i_rest_vec(i_inte);
            H_inte = H(((1 + Nt*(i_usr - 1)):(Nt*i_usr)),...
                       ((1 + Nt*(i_usr - 1)) + i_diff_vec(i_rest)*Nt:(Nt*i_usr) + i_diff_vec(i_rest)*Nt));
            ip_rest = ip_rest + pa(i_rest)*U(:, i_usr)'*H_inte*V(:, i_rest)*(U(:, i_usr)'*H_inte*V(:, i_rest))';
        end
        SINR(i_usr) = abs(sp_cur)/(1 + abs(ip_rest));
        sumrate_new = sumrate_new + log2(1 + SINR(i_usr));
    end
    diff = sumrate_new - sumrate_last;
    if abs(diff) < th
        break;
    end
    sumrate_last = sumrate_new;
end

=============================================

上面的程序,晦涩难懂,修改后如下:

%Modified Gauss-Seidel Power Allocation based on Grid Search(MGSPA)
%Author: Qi.Coder
%Date: Dec.28,2010
%Add. Lab.907

% K: number of users
% P: power per user

function [sumratevu, SINRVU, pa] = MGSPA_v03_PA(P, K, Nt, H, V, U, th, Np, iter_vec)
%assuming equal power allocation at beginning
pa = ones(1, K).*P;

i_order = 1;
sumratevu = zeros(length(iter_vec), 1);

for i_iter = 1: iter_vec(end)

    sumrate_last = 0;
    SINR = zeros(1, K);
    while(1)
        sumrate = zeros(K, Np+1);   
        for i_usr = 1: K
            i_diff_vec = (1: K) - i_usr;
            %index to the rest users
            i_rest_vec = find(abs(i_diff_vec));
            %power of current user
            p_cur = sum(P) - sum(pa(i_rest_vec));
            step = p_cur/Np;
            for i_grid = 0: Np
                pa(i_usr) = i_grid*step;
                sumrate(i_usr, i_grid + 1) = MGSPA_v03_SUMRATE(pa, K, Nt, H, V, U);
            end
            [sumrate_max, i_max] = max(sumrate(i_usr, :));
            pa(i_usr) = (i_max - 1)*step;
        end   
        sumrate_new = MGSPA_v03_SUMRATE(pa, K, Nt, H, V, U);
        diff = sumrate_new - sumrate_last;
        if abs(diff) < th
            break;
        end
        sumrate_last = sumrate_new;
    end
    if i_iter == iter_vec(i_order)
        [V, U, SINRVU, sumratevu(i_order)] = UpdateVU(H, Nt, pa, th);
        i_order = i_order + 1;
    end
end

function [sumrate] = MGSPA_v03_SUMRATE(PA, K, Nt, H, V, U)

sumrate = 0;
for i_usr = 1: K

    p_cur = PA(i_usr);
    H_cur = H(((1 + Nt*(i_usr - 1)):(Nt*i_usr)), ((1 + Nt*(i_usr - 1)):(Nt*i_usr)));
    sp_cur = p_cur*U(:, i_usr)'*H_cur*V(:, i_usr)*(U(:, i_usr)'*H_cur*V(:, i_usr))';
    ip_rst = 0;
    for i_rst = 1: K
        p_rst = PA(i_rst);
        H_rst = H(((1 + Nt*(i_usr - 1)):(Nt*i_usr)), ...
                  ((1 + Nt*(i_usr - 1) + Nt*(i_rst - i_usr)): ((Nt*i_usr) + Nt*(i_rst - i_usr)) ));
        ip_rst = ip_rst + p_rst*U(:, i_usr)'*H_rst*V(:, i_rst)*(U(:, i_usr)'*H_rst*V(:, i_rst))';
    end
    ip_rst = ip_rst - sp_cur;
    sumrate = sumrate + log2(1 + abs(sp_cur)/(1 + abs(ip_rst)));
end

 

  评论这张
 
阅读(269)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017