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

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

✅作者简介:热爱科研的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电子书和数学建模资料



相关文章
|
9天前
|
传感器 机器学习/深度学习 算法
【UASNs、AUV】无人机自主水下传感网络中遗传算法的路径规划问题研究(Matlab代码实现)
【UASNs、AUV】无人机自主水下传感网络中遗传算法的路径规划问题研究(Matlab代码实现)
|
8天前
|
机器学习/深度学习 传感器 算法
【高创新】基于优化的自适应差分导纳算法的改进最大功率点跟踪研究(Matlab代码实现)
【高创新】基于优化的自适应差分导纳算法的改进最大功率点跟踪研究(Matlab代码实现)
89 14
|
8天前
|
存储 算法 安全
【多目标工程应用】基于MOGWO的地铁隧道上方基坑工程优化设计研究(Matlab代码实现)
【多目标工程应用】基于MOGWO的地铁隧道上方基坑工程优化设计研究(Matlab代码实现)
|
8天前
|
机器学习/深度学习 运维 算法
【微电网多目标优化调度】多目标学习者行为优化算法MOLPB求解微电网多目标优化调度研究(Matlab代码实现)
【微电网多目标优化调度】多目标学习者行为优化算法MOLPB求解微电网多目标优化调度研究(Matlab代码实现)
|
10天前
|
机器学习/深度学习 并行计算 算法
基于二进制粒子群优化(BPSO)最佳PMU位置(OPP)配置研究(Matlab代码实现)
基于二进制粒子群优化(BPSO)最佳PMU位置(OPP)配置研究(Matlab代码实现)
|
10天前
|
机器学习/深度学习 算法 Java
基于灰狼优化算法(GWO)解决柔性作业车间调度问题(Matlab代码实现)
基于灰狼优化算法(GWO)解决柔性作业车间调度问题(Matlab代码实现)
|
11天前
|
传感器 资源调度 算法
基于无迹卡尔曼滤波(UKF)与模型预测控制(MPC)的多无人机避撞研究(Matlab代码实现)
基于无迹卡尔曼滤波(UKF)与模型预测控制(MPC)的多无人机避撞研究(Matlab代码实现)
|
8天前
|
算法 数据可视化 异构计算
【车辆路径问题VRPTW】基于北极海鹦优化(APO)算法求解带时间窗的车辆路径问题VRPTW研究(Matlab代码实现)
【车辆路径问题VRPTW】基于北极海鹦优化(APO)算法求解带时间窗的车辆路径问题VRPTW研究(Matlab代码实现)
|
8天前
|
机器学习/深度学习 运维 算法
【复现】基于改进秃鹰算法的微电网群经济优化调度研究(Matlab代码实现)
【复现】基于改进秃鹰算法的微电网群经济优化调度研究(Matlab代码实现)
|
8天前
|
机器学习/深度学习 算法 安全
【无人机三维路径规划】基于非支配排序的鱼鹰优化算法NSOOA求解无人机三维路径规划研究(Matlab代码实现)
【无人机三维路径规划】基于非支配排序的鱼鹰优化算法NSOOA求解无人机三维路径规划研究(Matlab代码实现)

热门文章

最新文章