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



相关文章
|
1天前
|
算法
基于遗传优化算法的风力机位置布局matlab仿真
本项目基于遗传优化算法(GA)进行风力机位置布局的MATLAB仿真,旨在最大化风场发电效率。使用MATLAB2022A版本运行,核心代码通过迭代选择、交叉、变异等操作优化风力机布局。输出包括优化收敛曲线和最佳布局图。遗传算法模拟生物进化机制,通过初始化、选择、交叉、变异和精英保留等步骤,在复杂约束条件下找到最优布局方案,提升风场整体能源产出效率。
|
1天前
|
机器学习/深度学习 数据采集 算法
基于WOA鲸鱼优化的CNN-GRU-SAM网络时间序列回归预测算法matlab仿真
本项目基于MATLAB 2022a实现时间序列预测,采用CNN-GRU-SAM网络结构,结合鲸鱼优化算法(WOA)优化网络参数。核心代码含操作视频,运行效果无水印。算法通过卷积层提取局部特征,GRU层处理长期依赖,自注意力机制捕捉全局特征,全连接层整合输出。数据预处理后,使用WOA迭代优化,最终输出最优预测结果。
|
4天前
|
算法
基于SOA海鸥优化算法的三维曲面最高点搜索matlab仿真
本程序基于海鸥优化算法(SOA)进行三维曲面最高点搜索的MATLAB仿真,输出收敛曲线和搜索结果。使用MATLAB2022A版本运行,核心代码实现种群初始化、适应度计算、交叉变异等操作。SOA模拟海鸥觅食行为,通过搜索飞行、跟随飞行和掠食飞行三种策略高效探索解空间,找到全局最优解。
|
2天前
|
传感器 算法
基于GA遗传算法的多机无源定位系统GDOP优化matlab仿真
本项目基于遗传算法(GA)优化多机无源定位系统的GDOP,使用MATLAB2022A进行仿真。通过遗传算法的选择、交叉和变异操作,迭代优化传感器配置,最小化GDOP值,提高定位精度。仿真输出包括GDOP优化结果、遗传算法收敛曲线及三维空间坐标点分布图。核心程序实现了染色体编码、适应度评估、遗传操作等关键步骤,最终展示优化后的传感器布局及其性能。
|
6天前
|
传感器 算法 物联网
基于粒子群算法的网络最优节点部署优化matlab仿真
本项目基于粒子群优化(PSO)算法,实现WSN网络节点的最优部署,以最大化节点覆盖范围。使用MATLAB2022A进行开发与测试,展示了优化后的节点分布及其覆盖范围。核心代码通过定义目标函数和约束条件,利用PSO算法迭代搜索最佳节点位置,并绘制优化结果图。PSO算法灵感源于鸟群觅食行为,适用于连续和离散空间的优化问题,在通信网络、物联网等领域有广泛应用。该算法通过模拟粒子群体智慧,高效逼近最优解,提升网络性能。
|
6天前
|
机器学习/深度学习 数据采集 算法
基于GWO灰狼优化的CNN-GRU-SAM网络时间序列回归预测算法matlab仿真
本项目基于MATLAB2022a,展示了时间序列预测算法的运行效果(无水印)。核心程序包含详细中文注释和操作视频。算法采用CNN-GRU-SAM网络,结合灰狼优化(GWO),通过卷积层提取局部特征、GRU处理长期依赖、自注意力机制捕捉全局特征,最终实现复杂非线性时间序列的高效预测。
|
6月前
|
安全
【2023高教社杯】D题 圈养湖羊的空间利用率 问题分析、数学模型及MATLAB代码
本文介绍了2023年高教社杯数学建模竞赛D题的圈养湖羊空间利用率问题,包括问题分析、数学模型建立和MATLAB代码实现,旨在优化养殖场的生产计划和空间利用效率。
272 6
【2023高教社杯】D题 圈养湖羊的空间利用率 问题分析、数学模型及MATLAB代码
|
6月前
|
存储 算法 搜索推荐
【2022年华为杯数学建模】B题 方形件组批优化问题 方案及MATLAB代码实现
本文提供了2022年华为杯数学建模竞赛B题的详细方案和MATLAB代码实现,包括方形件组批优化问题和排样优化问题,以及相关数学模型的建立和求解方法。
162 3
【2022年华为杯数学建模】B题 方形件组批优化问题 方案及MATLAB代码实现
|
6月前
|
数据采集 存储 移动开发
【2023五一杯数学建模】 B题 快递需求分析问题 建模方案及MATLAB实现代码
本文介绍了2023年五一杯数学建模竞赛B题的解题方法,详细阐述了如何通过数学建模和MATLAB编程来分析快递需求、预测运输数量、优化运输成本,并估计固定和非固定需求,提供了完整的建模方案和代码实现。
139 0
【2023五一杯数学建模】 B题 快递需求分析问题 建模方案及MATLAB实现代码
|
9月前
|
数据安全/隐私保护
耐震时程曲线,matlab代码,自定义反应谱与地震波,优化源代码,地震波耐震时程曲线
地震波格式转换、时程转换、峰值调整、规范反应谱、计算反应谱、计算持时、生成人工波、时频域转换、数据滤波、基线校正、Arias截波、傅里叶变换、耐震时程曲线、脉冲波合成与提取、三联反应谱、地震动参数、延性反应谱、地震波缩尺、功率谱密度

热门文章

最新文章