【无人机】基于粒子群的无人机车载网络优化UAV-VANET附matlab代码

该文提出了一种名为UVAR的UAV辅助VehicularAdhocNetworks(VANETs)路由协议。通过利用UAV收集地面交通密度和车辆连接性信息,改善城市环境中车辆间的通信连接。通过V2U通信增强整体连通性,从而提高路由效率。文章使用MATLAB进行仿真并评估了协议性能。
摘要由CSDN通过智能技术生成

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

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

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

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

⛄ 内容介绍

It is a challenging task to develop an efficient routing solution for a reliable data delivery in urban vehicular environments. Indeed, it is difficult to find a shortest end-to-end connected path especially in urban city given the mobility attern of the vehicles and the various obstructions to a clear transmission such as buildings. To overcome these difficulties, we investigate how unmanned aerial vehicles (UAVs) can assist vehicles on the ground in relaying in urban areas. In this paper, we propose UVAR (UAV-Assisted VANET Routing Protocol), a new routing technique for Vehicular Ad hoc Networks (VANets). This protocol is based on the use of the traffic density and the knowledge of vehicular connectivity in the streets. With this approach UAVs collect information about the traffic density on the ground and the state of vehicles connectivity, and exchange them with vehicles through Hello messages. These information allow UAV to place themselves so as to allow relaying data when connectivity between sole vehicles on the ground is not possible. Through vehicleto-UAV (V2U) communication, the overall connectivity between vehicles is improved and therefore the routing process is efficiently improved. The performance of the proposed protocol is evaluated and the results to different scenarios are discussed.

​⛄ 部分代码

function out = PSOSearch(param, position)

    % Import trace file(SUMO)

    filename = param.filename;

    filename_obj = param.filename_obj;

    filename_connec = param.filename_connec;

    % Number of vehicles available in the dataset(SUMO)

    nVehicle = param.nVehicle; % Have to change according to the trace file

    niter =param.niter;

    % Infrastructure Position

    pos = position; % Have to change according to the trace file

    infRadius = 500;

    % Reading table

    T = readtable(filename);

    T_obj = readtable(filename_obj);

    T_connec = readtable(filename_connec);

    % Number of rows in the table

    n_rows_obj = height(T_obj);

    % Finding minimum and maximum of Position X and Y

    minPosX = min(T{:,4});

    minPosY = min(T{:,5});

    maxPosX = max(T{:,4});

    maxPosY = max(T{:,5});

    % Vehicle template

    empty_vehicle.id = [];

    empty_vehicle.Position = [];

    empty_vehicle.angle = [];

    % Creating templates for storing Previous connectivity history of vehicles

    empty_pre_conection.id = [];

    empty_pre_conection.id1 = [];

    empty_pre_conection.t1 = 0;

    empty_pre_conection.id2 = [];

    empty_pre_conection.t2 = 0;

    empty_pre_conection.id3 = [];

    empty_pre_conection.t3 = 0;

    empty_pre_conection.id4 = [];

    empty_pre_conection.t4 = 0;

    empty_pre_conection.id5 = [];

    empty_pre_conection.t5 = 0;

    % Create vehicles connections history array

    pre_conection = repmat(empty_pre_conection, nVehicle, 1);

    % Create vehicles array

    object_vehicle = repmat(empty_vehicle, nVehicle, 1);

    for i=1:n_rows_obj

        for j=1:nVehicle

            if strcmp(T_obj{i,1},['veh' num2str((j-1),'%d')])

                object_vehicle(j).id = T_obj{i,1};

                object_vehicle(j).angle = T_obj{i,2};

                object_vehicle(j).Position = [T_obj{i,3}, T_obj{i,4}];

            end

        end

    end

    % Creating vehicles id for 'connection history' data structure

    for i=1:nVehicle

        pre_conection(i).id = ['veh' num2str((i-1), '%d')];

        pre_conection(i).id1 = T_connec{i,1};

        pre_conection(i).t1 = T_connec{i,2};

        pre_conection(i).id2 = T_connec{i,3};

        pre_conection(i).t2 = T_connec{i,4};

        pre_conection(i).id3 = T_connec{i,5};

        pre_conection(i).t3 = T_connec{i,6};

        pre_conection(i).id4 = T_connec{i,7};

        pre_conection(i).t4 = T_connec{i,8};

        pre_conection(i).id5 = T_connec{i,9};

        pre_conection(i).t5 = T_connec{i,10};

    end

    % Storing available vehicle's position in this time-slot (For scatter

    % ploting only)

    counter = 1;

    for i=1:nVehicle

        if ~isempty(object_vehicle(i).id)

            x(counter) = object_vehicle(i).Position(1);

            y(counter) = object_vehicle(i).Position(2);

            all_vehicle(counter).id = object_vehicle(i).id;

            all_vehicle(counter).angle = object_vehicle(i).angle;

            all_vehicle(counter).Position = object_vehicle(i).Position;

            all_vehicle(counter).x = object_vehicle(i).Position(1);

            all_vehicle(counter).y = object_vehicle(i).Position(2);

            all_vehicle(counter).connec_sum = pre_conection(i).t1 + pre_conection(i).t2 + pre_conection(i).t3 ...

                + pre_conection(i).t4 + pre_conection(i).t5;

            counter = counter + 1;

        end

    end

    % Number of vehicles both covered and uncovered

    uncovered_vehicle = all_vehicle;

    nall_vehicle = size(uncovered_vehicle, 2);

    counter1 = 1;

    % Finding all the uncovered vehicles

    for j = 1:niter

        for i = 1:nall_vehicle

            dist(j).inf = sqrt(sum((pos(j).inf - uncovered_vehicle(i).Position) .^2));

            if dist(j).inf > infRadius

                uncovered_vehicle(counter1).id = uncovered_vehicle(i).id;

                uncovered_vehicle(counter1).angle = uncovered_vehicle(i).angle;

                uncovered_vehicle(counter1).Position = uncovered_vehicle(i).Position;

                uncovered_vehicle(counter1).connec_sum = uncovered_vehicle(i).connec_sum;

                counter1 = counter1 + 1;

            end

        end

        uncovered_vehicle = uncovered_vehicle(1:counter1-1);

        nall_vehicle = size(uncovered_vehicle, 2);

        counter1 = 1;

    end

    % Number of uncovered vehicles

    nuncovered_vehicle = size(uncovered_vehicle, 2);

    % Problem Definition

    nVar = 2;   % Decision Variable

    VarSize = [1 nVar]; % Matrix Size of Decision Variables

    VarMin = min(minPosX, minPosY);   % Lower Bound of Decision Variables

    VarMax = max(maxPosX, maxPosY);    % Upper Bound of Decision Variables

    % Parameters of PSO

    MaxIt = param.MaxIt;    % Maximum Number of Iterations

    nPop = param.nPop;  % Population Size

    w = 1;      % Intertia Coefficient

    wdamp = 0.99; % Damping Ratio of Intertia Coefficient

    c1 = 2;     % Personal Acceleration Coefficient

    c2 = 2;     % Social Acceleration Coefficient

    MaxVelocity = 0.15*(VarMax-VarMin);

    MinVelocity = -MaxVelocity;

    % Initialization

    % The particle template

    empty_particle.Position = [];

    empty_particle.Velocity = [];

    empty_particle.Cost = [];

    empty_particle.Best.Position = [];

    empty_particle.Best.Cost = [];

    % create population array

    particle = repmat(empty_particle, nPop, 1);

    % Initialize Global Best

    GlobalBest.Cost = -inf;

    GlobalBest.Position = [0,0];

    % Initialize population members

    for i=1:nPop

        % Generate Random Solution

        particle(i).Position = unifrnd(VarMin, VarMax, VarSize);

        % Initialize Velociy

        particle(i).Velocity = zeros(VarSize);

        % Evaluation

        evaluation = objfuntest(particle(i).Position, nuncovered_vehicle, uncovered_vehicle, pos, niter);

        particle(i).Cost = evaluation.Fitness;

        nMi = evaluation.M;

        nNi = evaluation.N;

        % Update the Personal Best

        particle(i).Best.Position = particle(i).Position;

        particle(i).Best.Cost = particle(i).Cost;

        % Update Global Best

        if particle(i).Best.Cost > GlobalBest.Cost

            GlobalBest = particle(i).Best;

        end

    end

    % Array to Hold Best Cost Value on Each Iteration

    BestCosts = zeros(MaxIt, 1);

    

    nM = 0;

    nN = 0;

    %  Main Loop of PSO

    for it=1:MaxIt

        for i=1:nPop

            % Update Velocity

            particle(i).Velocity = w*particle(i).Velocity ...

                + c1*rand(VarSize).*(particle(i).Best.Position - particle(i).Position) ...

                + c2*rand(VarSize).*(GlobalBest.Position -particle(i).Position);

            % Apply Velocity Limits

            particle(i).Velocity = max(particle(i).Velocity, MinVelocity);

            particle(i).Velocity = min(particle(i).Velocity, MaxVelocity);

            % Update Position

            particle(i).Position = particle(i).Position + particle(i).Velocity;

            % Apply Lower and Upper Bound Limits

            particle(i).Position = max(particle(i).Position, VarMin);

            particle(i).Position = min(particle(i).Position, VarMax);

            % Evaluation

            evaluation = objfuntest(particle(i).Position, nuncovered_vehicle, uncovered_vehicle, pos, niter);

            particle(i).Cost = evaluation.Fitness;

            % Update Personal Best

            if particle(i).Cost > particle(i).Best.Cost

                particle(i).Best.Position = particle(i).Position;

                particle(i).Best.Cost = particle(i).Cost;

                % Update Global Best

                if particle(i).Best.Cost > GlobalBest.Cost

                    GlobalBest = particle(i).Best;

                    nM = evaluation.M;

                    nN = evaluation.N;

                end

            end

        end

        % Store the Best Cost Value

        BestCosts(it) = GlobalBest.Cost;

        % Damping Intertia Coefficient

        w = w * wdamp;

    end

    out.Fitness = GlobalBest.Cost;

    out.Position = GlobalBest.Position;

    out.Uncov_veh = evaluation.V;

    out.nM = nM;

    out.nN = nN;

    out.x = x;

    out.y = y;

    out.VarMin = VarMin;

    out.VarMax = VarMax;

    out.Total_vehicle = size(all_vehicle, 2);

    out.Best_cost = BestCosts;

end

⛄ 运行结果

⛄ 参考文献

[1] Oubbati O S ,  Lakas A ,  Lagraa N , et al. UVAR: An intersection UAV-assisted VANET routing protocol[C]// 2016 IEEE Wireless Communications and Networking Conference (WCNC). IEEE, 2016.

[2] Wang X ,  Fu L ,  Zhang Y , et al. VDNet: an infrastructure‐less UAV‐assisted sparse VANET system with vehicle location prediction[J]. Wireless Communications & Mobile Computing, 2016.

[3]Gan, Xiaoying, Wang,等. VDNet: an infrastructure-less UAV-assisted sparse VANET system with vehicle location prediction[J]. Wireless Communications & Mobile Computing, 2016.

⛳️ 完整代码

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

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

Originally reactive protocols were not design for the characteristic of highly mobility during route discovery. Due to dynamically modification to the VANET this changes very often due to breakdown which causing excessive broadcasting and flooding the entire network in order for new routes to be discovered. In additional, the initial of routing need some time and this latency can easily change everything. Due to these reasons, the typical reactive protocols, in their current format, do not totally appropriate for time critical applications such as cooperative collision avoidance (CCA). The Cooperative Collision Avoidance is an important class of safety applications in VANETs, which aims at offering earlier warning to drivers using vehicle-to-vehicle (V2V) communication [13]. Ad Hoc On Demand Distance Vector (AODV) is an reactive routing protocolwhich capable of both unicast and multicast. In AODV, like all reactive protocols,topology information is only transmitted by nodes on-demand. When source hassomething to send then initially it propagates RREQ message which is forwarded byintermediate node until destination is reached. A route reply message is unicastedback to the source if the receiver is either the node using the requested address, or ithas a valid route to the requested address. This repository provides a MATLAB simulaiton of VANET enviornment and rsults comparison in terms of throughput, packet drop ratio etc. More information can be reached at https://www.youtube.com/watch?v=2QeSYOgJo9s&t=32s
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值