【无人机】基于粒子群的无人机车载网络优化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电子书和数学建模资料



相关文章
|
4天前
|
机器学习/深度学习 算法 关系型数据库
基于PSO-SVM的乳腺癌数据分类识别算法matlab仿真,对比BP神经网络和SVM
本项目展示了利用粒子群优化(PSO)算法优化支持向量机(SVM)参数的过程,提高了分类准确性和泛化能力。包括无水印的算法运行效果预览、Matlab2022a环境下的实现、核心代码及详细注释、操作视频,以及对PSO和SVM理论的概述。PSO-SVM结合了PSO的全局搜索能力和SVM的分类优势,特别适用于复杂数据集的分类任务,如乳腺癌诊断等。
|
12天前
|
数据采集 网络协议 算法
移动端弱网优化专题(十四):携程APP移动网络优化实践(弱网识别篇)
本文从方案设计、代码开发到技术落地,详尽的分享了携程在移动端弱网识别方面的实践经验,如果你也有类似需求,这篇文章会是一个不错的实操指南。
32 1
|
1月前
|
机器学习/深度学习 网络架构 计算机视觉
目标检测笔记(一):不同模型的网络架构介绍和代码
这篇文章介绍了ShuffleNetV2网络架构及其代码实现,包括模型结构、代码细节和不同版本的模型。ShuffleNetV2是一个高效的卷积神经网络,适用于深度学习中的目标检测任务。
72 1
目标检测笔记(一):不同模型的网络架构介绍和代码
|
26天前
|
缓存 监控 前端开发
优化网络应用的性能
【10月更文挑战第21天】优化网络应用的性能
17 2
|
27天前
|
机器学习/深度学习 算法 数据安全/隐私保护
基于贝叶斯优化CNN-LSTM网络的数据分类识别算法matlab仿真
本项目展示了基于贝叶斯优化(BO)的CNN-LSTM网络在数据分类中的应用。通过MATLAB 2022a实现,优化前后效果对比明显。核心代码附带中文注释和操作视频,涵盖BO、CNN、LSTM理论,特别是BO优化CNN-LSTM网络的batchsize和学习率,显著提升模型性能。
|
1月前
|
运维 监控 安全
连锁药店网络优化策略:一站式融合方案提升竞争力
在数字化浪潮下,线上药店通过技术创新和线上线下融合,正重塑购药体验,提供24小时服务和医保结算便利。面对激烈竞争,连锁药店和中小药店纷纷通过优化网络架构、提升服务质量和加强合规管理来增强竞争力,实现高效、安全的数字化转型。
|
1月前
|
机器学习/深度学习 算法 数据挖掘
基于GWO灰狼优化的GroupCNN分组卷积网络时间序列预测算法matlab仿真
本项目展示了基于分组卷积神经网络(GroupCNN)和灰狼优化(GWO)的时间序列回归预测算法。算法运行效果良好,无水印展示。使用Matlab2022a开发,提供完整代码及详细中文注释。GroupCNN通过分组卷积减少计算成本,GWO则优化超参数,提高预测性能。项目包含操作步骤视频,方便用户快速上手。
|
1月前
|
机器学习/深度学习 算法 数据安全/隐私保护
基于WOA鲸鱼优化的GroupCNN分组卷积网络时间序列预测算法matlab仿真
本项目展示了一种基于WOA优化的GroupCNN分组卷积网络时间序列预测算法。使用Matlab2022a开发,提供无水印运行效果预览及核心代码(含中文注释)。算法通过WOA优化网络结构与超参数,结合分组卷积技术,有效提升预测精度与效率。分组卷积减少了计算成本,而WOA则模拟鲸鱼捕食行为进行优化,适用于多种连续优化问题。
|
1月前
|
机器学习/深度学习 算法 5G
基于BP神经网络的CoSaMP信道估计算法matlab性能仿真,对比LS,OMP,MOMP,CoSaMP
本文介绍了基于Matlab 2022a的几种信道估计算法仿真,包括LS、OMP、NOMP、CoSaMP及改进的BP神经网络CoSaMP算法。各算法针对毫米波MIMO信道进行了性能评估,通过对比不同信噪比下的均方误差(MSE),展示了各自的优势与局限性。其中,BP神经网络改进的CoSaMP算法在低信噪比条件下表现尤为突出,能够有效提高信道估计精度。
40 2
|
18天前
|
机器学习/深度学习 存储 算法
基于Actor-Critic(A2C)强化学习的四旋翼无人机飞行控制系统matlab仿真
基于Actor-Critic强化学习的四旋翼无人机飞行控制系统,通过构建策略网络和价值网络学习最优控制策略。MATLAB 2022a仿真结果显示,该方法在复杂环境中表现出色。核心代码包括加载训练好的模型、设置仿真参数、运行仿真并绘制结果图表。仿真操作步骤可参考配套视频。
38 0