【无人机】基于粒子群的无人机车载网络优化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天前
|
算法 网络安全 Python
sqlmap性能优化_sqlmap 优化 不接受请求体,阿里巴巴网络安全面试题答案
sqlmap性能优化_sqlmap 优化 不接受请求体,阿里巴巴网络安全面试题答案
|
1天前
|
算法
MATLAB|【免费】融合正余弦和柯西变异的麻雀优化算法SCSSA-CNN-BiLSTM双向长短期记忆网络预测模型
这段内容介绍了一个使用改进的麻雀搜索算法优化CNN-BiLSTM模型进行多输入单输出预测的程序。程序通过融合正余弦和柯西变异提升算法性能,主要优化学习率、正则化参数及BiLSTM的隐层神经元数量。它利用一段简单的风速数据进行演示,对比了改进算法与粒子群、灰狼算法的优化效果。代码包括数据导入、预处理和模型构建部分,并展示了优化前后的效果。建议使用高版本MATLAB运行。
|
2天前
|
缓存 监控 UED
CDN(内容分发网络):加速网站加载与优化用户体验
CDN(内容分发网络):加速网站加载与优化用户体验
|
3天前
|
机器学习/深度学习 算法 数据挖掘
基于GWO灰狼优化的CNN-LSTM-Attention的时间序列回归预测matlab仿真
摘要: 本文介绍了使用matlab2022a中优化后的算法,应用于时间序列回归预测,结合CNN、LSTM和Attention机制,提升预测性能。GWO算法用于优化深度学习模型的超参数,模拟灰狼社群行为以求全局最优。算法流程包括CNN提取局部特征,LSTM处理序列依赖,注意力机制聚焦相关历史信息。GWO的灰狼角色划分和迭代策略助力寻找最佳解。
|
3天前
|
资源调度 算法 块存储
m基于遗传优化的LDPC码OMS译码算法最优偏移参数计算和误码率matlab仿真
MATLAB2022a仿真实现了遗传优化的LDPC码OSD译码算法,通过自动搜索最佳偏移参数ΔΔ以提升纠错性能。该算法结合了低密度奇偶校验码和有序统计译码理论,利用遗传算法进行全局优化,避免手动调整,提高译码效率。核心程序包括编码、调制、AWGN信道模拟及软输入软输出译码等步骤,通过仿真曲线展示了不同SNR下的误码率性能。
9 1
|
3天前
|
网络安全 数据安全/隐私保护 计算机视觉
2024蓝桥杯网络安全-图片隐写-缺失的数据(0基础也能学会-含代码解释)
2024蓝桥杯网络安全-图片隐写-缺失的数据(0基础也能学会-含代码解释)
|
3天前
|
算法 Serverless
m基于遗传优化的LDPC码NMS译码算法最优归一化参数计算和误码率matlab仿真
MATLAB 2022a仿真实现了遗传优化的归一化最小和(NMS)译码算法,应用于低密度奇偶校验(LDPC)码。结果显示了遗传优化的迭代过程和误码率对比。遗传算法通过选择、交叉和变异操作寻找最佳归一化因子,以提升NMS译码性能。核心程序包括迭代优化、目标函数计算及性能绘图。最终,展示了SNR与误码率的关系,并保存了关键数据。
16 1
|
3天前
|
数据安全/隐私保护
耐震时程曲线,matlab代码,自定义反应谱与地震波,优化源代码,地震波耐震时程曲线
地震波格式转换、时程转换、峰值调整、规范反应谱、计算反应谱、计算持时、生成人工波、时频域转换、数据滤波、基线校正、Arias截波、傅里叶变换、耐震时程曲线、脉冲波合成与提取、三联反应谱、地震动参数、延性反应谱、地震波缩尺、功率谱密度
|
3天前
|
数据安全/隐私保护
地震波功率谱密度函数、功率谱密度曲线,反应谱转功率谱,matlab代码
地震波格式转换、时程转换、峰值调整、规范反应谱、计算反应谱、计算持时、生成人工波、时频域转换、数据滤波、基线校正、Arias截波、傅里叶变换、耐震时程曲线、脉冲波合成与提取、三联反应谱、地震动参数、延性反应谱、地震波缩尺、功率谱密度
基于混合整数规划的微网储能电池容量规划(matlab代码)
基于混合整数规划的微网储能电池容量规划(matlab代码)