无人机边缘计算中的计算卸载——Stackelberg博弈方法论文复现附matlab代码

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

个人主页:Matlab科研工作室

个人信条:格物致知。

更多Matlab仿真内容点击

智能优化算法  神经网络预测 雷达通信  无线传感器

信号处理 图像处理 路径规划 元胞自动机 无人机  电力系统

⛄ 内容介绍

基于物联网的服务受益于云,云提供了几乎无限的功能,如存储、处理和通信。然而,移动用户在满足服务质量(QoS)规定的情况下从云接收计算仍然面临挑战。在本文中,我们研究了使用边缘计算的计算卸载,这是一种将计算传递到移动用户附近的普及网络边缘的新范式。然而,如果没有强有力的激励措施,本地边缘服务器可能不愿意帮助卸载计算。为了激励云服务运营商和本地边缘服务器所有者参与计算卸载,我们将云服务运营方和边缘服务器所有者之间的交互表述为Stackelberg游戏,以通过获得最佳支付和计算卸载策略,最大化云服务运营和边缘服务器拥有者的效用。通过理论分析,我们证明了博弈保证达到唯一的纳什均衡。然后,我们设计了两种计算卸载算法,可以在低延迟和降低复杂性方面量化它们的效率。此外,我们通过考虑边缘服务器所有者动态加入或离开计算卸载来扩展我们的工作。数值结果表明,我们提出的算法在计算卸载方面表现良好,并有效地激励边缘服务器所有者为计算卸载做出贡献。

无人机边缘计算中的计算卸载——Stackelberg博弈方法论文复现附matlab代码_第1张图片

⛄ 部分代码

function [bs_income,uav_income,user_outcome] = stackelberg_price_determined(bs,uav,user,epoch)

global user_num uav_num bs_num D ...

       relay_ok selected_uav_relay ...%need_bs need_uav

       offload_bs offload_uav offload_relay selected_uav selected_bs

% global M_i M_j F_i m_i f_i

M_i = ones(bs_num,user_num);    % price to the user i @bs

M_j = ones(bs_num,uav_num);     % price to hire the uav j @bs

F_i = zeros(bs_num,user_num);   % the resource allocate to the user i @bs

m_i = ones(uav_num,user_num);   % price to the user i @uav

f_i = zeros(uav_num,user_num);  % reource allocate to the user i @uav

[bs_income,uav_income,user_outcome] = deal(zeros(epoch,bs_num),zeros(epoch,uav_num),zeros(epoch,user_num));

[local,offload_bs,offload_uav,offload_relay]=deal(0.25*ones(user_num,1),0.25*ones(user_num,1),0.25*ones(user_num,1),0.25*ones(user_num,1)); % 卸载比例初始化

[at_local,to_bs,to_uav,by_relay] = deal(zeros(user_num,1),zeros(user_num,1),zeros(user_num,1),zeros(user_num,1));

relay_ok = zeros(bs_num,uav_num); % whether the uav choose to be relay for base station g 

[selected_uav,selected_bs,selected_uav_relay] = deal(zeros(user_num,1),zeros(user_num,1),zeros(user_num,1));

[dis_user_uav,dis_uav_bs,dis_user_bs] = get_distance(uav,user,bs);

[Rate_i_g,Rate_i_j,Rate_j_g_i] = deal(ones(user_num,bs_num),ones(user_num,uav_num),ones(uav_num,bs_num));

[record_1,record_2,record_3,record_4] = deal(zeros(user_num,epoch),zeros(user_num,epoch),zeros(user_num,epoch),zeros(user_num,epoch));

%% The Data trans speed subject to the distance between the objects

for b = 1:bs_num

   for i = 1:user_num

       Rate_i_g(i,b) = 1000 / dis_user_bs(i,b);

   end

   for j = 1:uav_num

       Rate_j_g_i(j,b) = 1000 / dis_uav_bs(j,b);

   end

end

for i = 1:user_num

    for j = 1:uav_num

        Rate_i_j(i,j) = 1000 / dis_user_uav(i,j);

    end

end

%% The User associate to the bs & uav nearby

for u = 1:user_num

    [~,selected_bs(u)] = min(dis_user_bs(u,:));

    [~,selected_uav(u)] = min(dis_user_uav(u,:));

    selected_uav_relay(u) = selected_uav(u);

%     need_bs(selected_bs(u)) = 1;need_uav(selected_uav(u)) = 1;

end

%% Game Iteration

for episode = 1:epoch

    now = episode;

    %% Game of Leader layer: Base station

    for b = 1:bs_num

        % alter the price for user i: M_i && the suitable resource: F_i

        for i = 1:user_num

            F_i(b,i) = (offload_bs(i)+offload_relay(i)) * D(i);

            M_i(b,i) = 250;%D(i) / Rate_i_g(i,b);

        end

        % alter the price for uav j : M_j

        for j = 1:uav_num

            M_j(b,j) = 50 / Rate_j_g_i(j,b);

        end

        % compute the profit of the base station b

        bs_income(episode,b) = utility_base_station(M_i(b,:),M_j(b,:),F_i(b,:),b);

    end

    %% Game of Vice-leader Layer : UAVs   

    for u = 1:uav_num

        % alter the price for user i: m_i

        for i = 1:user_num

            f_i(u,i) = offload_uav(i) * D(i);

            m_i(u,i) = 70;% D(i) / Rate_i_j(i,u);

        end

        % compute the profit of the uav j

        uav_income(episode,u) = utility_uav(m_i(u,:),f_i(u,:),Rate_j_g_i(u,:),M_j(:,u),u);

    end

    %% Game of follower layer: Users

    for i = 1:user_num

        [at_local(i),to_bs(i),to_uav(i),by_relay(i)] = ...

        utility_user(M_i(:,i),m_i(:,i),F_i(:,i),f_i(:,i),Rate_i_g,Rate_i_j,Rate_j_g_i,i);

        % allocate the compute task

        [local(i),offload_bs(i),offload_uav(i),offload_relay(i)] ...

            = offload_allocate(at_local(i),to_bs(i),to_uav(i),by_relay(i),D,i);

        [record_1(i,now),record_2(i,now),record_3(i,now),record_4(i,now)]=...

            deal(local(i),offload_bs(i),offload_uav(i),offload_relay(i));

        if offload_relay(i) ~= 0

            relay_ok(selected_bs(i),selected_uav_relay(i)) = 1;

        else

            relay_ok(selected_bs(i),selected_uav_relay(i)) = 0;

        end

        user_outcome(episode,i) = ...

        local(i) * at_local(i) + offload_bs(i) * to_bs(i) + offload_uav(i) * to_uav(i) + offload_relay(i) * by_relay(i);

    end

save stackelberg_RL

end

end

⛄ 运行结果

无人机边缘计算中的计算卸载——Stackelberg博弈方法论文复现附matlab代码_第2张图片

⛄ 参考文献

​[1] Yang L ,  Xu C ,  Zhan Y , et al. Incentive mechanism for computation offloading using edge computing: A Stackelberg game approach[J]. Computer Networks, 2017, 129(DEC.24):399-409.

⛄ Matlab代码关注

❤️部分理论引用网络文献,若有侵权联系博主删除

❤️ 关注我领取海量matlab电子书和数学建模资料

你可能感兴趣的:(无人机,无人机,边缘计算,matlab)