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



相关文章
|
3天前
|
机器学习/深度学习 算法
基于改进遗传优化的BP神经网络金融序列预测算法matlab仿真
本项目基于改进遗传优化的BP神经网络进行金融序列预测,使用MATLAB2022A实现。通过对比BP神经网络、遗传优化BP神经网络及改进遗传优化BP神经网络,展示了三者的误差和预测曲线差异。核心程序结合遗传算法(GA)与BP神经网络,利用GA优化BP网络的初始权重和阈值,提高预测精度。GA通过选择、交叉、变异操作迭代优化,防止局部收敛,增强模型对金融市场复杂性和不确定性的适应能力。
110 80
|
9天前
|
机器学习/深度学习 算法 数据安全/隐私保护
基于yolov4深度学习网络的公共场所人流密度检测系统matlab仿真,带GUI界面
本项目使用 MATLAB 2022a 进行 YOLOv4 算法仿真,实现公共场所人流密度检测。通过卷积神经网络提取图像特征,将图像划分为多个网格进行目标检测和识别,最终计算人流密度。核心程序包括图像和视频读取、处理和显示功能。仿真结果展示了算法的有效性和准确性。
54 31
|
12天前
|
机器学习/深度学习 算法 PyTorch
基于图神经网络的大语言模型检索增强生成框架研究:面向知识图谱推理的优化与扩展
本文探讨了图神经网络(GNN)与大型语言模型(LLM)结合在知识图谱问答中的应用。研究首先基于G-Retriever构建了探索性模型,然后深入分析了GNN-RAG架构,通过敏感性研究和架构改进,显著提升了模型的推理能力和答案质量。实验结果表明,改进后的模型在多个评估指标上取得了显著提升,特别是在精确率和召回率方面。最后,文章提出了反思机制和教师网络的概念,进一步增强了模型的推理能力。
35 4
基于图神经网络的大语言模型检索增强生成框架研究:面向知识图谱推理的优化与扩展
|
9天前
|
域名解析 缓存 网络协议
优化Lua-cURL:减少网络请求延迟的实用方法
优化Lua-cURL:减少网络请求延迟的实用方法
|
9天前
|
数据采集 监控 安全
公司网络监控软件:Zig 语言底层优化保障系统高性能运行
在数字化时代,Zig 语言凭借出色的底层控制能力和高性能特性,为公司网络监控软件的优化提供了有力支持。从数据采集、连接管理到数据分析,Zig 语言确保系统高效稳定运行,精准处理海量网络数据,保障企业信息安全与业务连续性。
32 4
|
18天前
|
机器学习/深度学习 算法 Python
基于BP神经网络的金融序列预测matlab仿真
本项目基于BP神经网络实现金融序列预测,使用MATLAB2022A版本进行开发与测试。通过构建多层前馈神经网络模型,利用历史金融数据训练模型,实现对未来金融时间序列如股票价格、汇率等的预测,并展示了预测误差及训练曲线。
|
16天前
|
机器学习/深度学习 算法 信息无障碍
基于GoogleNet深度学习网络的手语识别算法matlab仿真
本项目展示了基于GoogleNet的深度学习手语识别算法,使用Matlab2022a实现。通过卷积神经网络(CNN)识别手语手势,如"How are you"、"I am fine"、"I love you"等。核心在于Inception模块,通过多尺度处理和1x1卷积减少计算量,提高效率。项目附带完整代码及操作视频。
|
19天前
|
机器学习/深度学习 算法 数据安全/隐私保护
基于深度学习网络的宝石类型识别算法matlab仿真
本项目利用GoogLeNet深度学习网络进行宝石类型识别,实验包括收集多类宝石图像数据集并按7:1:2比例划分。使用Matlab2022a实现算法,提供含中文注释的完整代码及操作视频。GoogLeNet通过其独特的Inception模块,结合数据增强、学习率调整和正则化等优化手段,有效提升了宝石识别的准确性和效率。
|
25天前
|
机器学习/深度学习 算法 数据安全/隐私保护
基于贝叶斯优化CNN-GRU网络的数据分类识别算法matlab仿真
本项目展示了使用MATLAB2022a实现的贝叶斯优化、CNN和GRU算法优化效果。优化前后对比显著,完整代码附带中文注释及操作视频。贝叶斯优化适用于黑盒函数,CNN用于时间序列特征提取,GRU改进了RNN的长序列处理能力。
|
3天前
|
机器学习/深度学习 人工智能 算法
基于GRNN广义回归网络和MFCC的语音情绪识别matlab仿真,对比SVM和KNN
该语音情绪识别算法基于MATLAB 2022a开发,可识别如悲伤等情绪,置信度高达0.9559。核心程序含中文注释及操作视频。算法采用MFCC特征提取与GRNN广义回归网络,通过预加重、分帧、加窗、FFT、梅尔滤波器组、对数运算和DCT等步骤处理语音信号,实现高效的情绪分类。

热门文章

最新文章