🚅座右铭:行百里者,半于九十。
🏆代码获取方式:
CSDN Matlab武动乾坤—代码获取方式
更多Matlab路径规划仿真内容点击👇
①Matlab路径规划(进阶版)
⛳️关注CSDN Matlab武动乾坤,更多资源等你来!!
%clearing variables
clc,clear
close all
%declaring nodes, desired distance and other parameters
n = 100;
dim = 2;
d = 15;
k = 1.2;
r = k * d;
h = 0.2;
neigh = {};
%Optional paramters
epsilon = 0.1;
delta_t = 0.009;
t = 0:delta_t:7;% Set simulation time
c1 = 30;
c2 = 2 * sqrt(c1);
%Randomely generating the points
x = rand(n,1).*50;
y = rand(n,1).*50;
%Calculating neighbors and plotting the graph connecting neighbors
[x,y,neigh] = compute(x,y,r,n,neigh);
plotgraph(x,y,neigh,n);
%Declaring variables required for movement of the nodes
old_x = x;
old_y = y;
p_nodes = zeros(n,dim);
u_nodes = zeros(n,dim);
sum1 = zeros(n,dim);
sum2 = zeros(n,dim);
%Variables for keeping track of the node parameters for each iteration
x_iter = zeros(n,length(t));
y_iter = zeros(n,length(t));
p_iter = zeros(length(t),n);
n_iter = ones(length(t),1);
rk_iter = zeros(length(t),1);
%Loop for movement of the flock
for iter = 1:length(t)
p_nodes(:,1) = (x - old_x)/delta_t; %Calculating velocity of the nod閟
p_nodes(:,2) = (y - old_y)/delta_t;
if (iter > 1)
p_iter(iter,:) = ((p_nodes(:,1).^2) + (p_nodes(:,2).^2)); %Saving node velocity values for each iteration
n_iter(iter) = iter; %saving the no: of iterations
end
old_x = x; %Saving old x and y values for the purpose of calculating velocity
old_y = y;
[x,y,neigh] = compute(x,y,r,n,neigh); %Computing neighbors
[adij] = adjacent(neigh,n); %Computing the adjacency matrix (For Connectivity)
rk_iter(iter) = rank(adij)/n; %Computing connectivity
[adj] = fadj(x,y,neigh,r,n);
[grad] = GBT(x,y,r,d,neigh,n); %Computing the Gradient base Term
[adjterm] = CBT(p_nodes,neigh,adj,n);%Computing the Concensus base Term
grad = c1 * grad;
adjterm = c2 * adjterm;
u_nodes = grad + adjterm; %Calculating accelaration
x = old_x + (delta_t * p_nodes(:,1)) + (((delta_t^2)/2) * u_nodes(:,1)); %Changing the position of the nodes
y = old_y + (delta_t * p_nodes(:,2)) + (((delta_t^2)/2) * u_nodes(:,2));
x_iter(:,iter) = x; %Saving the position for every iteration
y_iter(:,iter) = y;
hold off;
plotgraph(x,y,neigh,n); %Plotting the graph
drawnow;
end
%Plotting the velocity
figure(2)
for i = 1:n
plot(n_iter,p_iter(:,i));
hold on;
end
%Plotting the connectivity
figure(3)
plot(n_iter,rk_iter);
%Plotting the trajectory
figure(4)
for i = 1:length(t)
if(i == length(t))
plot(x_iter(:,i),y_iter(:,i),‘m>’);
else
plot(x_iter(:,i),y_iter(:,i),‘k.’);
end
hold on;
end
1 matlab版本
2014a
2 参考文献
[1] 刘婵,朱永川,白园,何健辉.基于flocking的多智能体群集与避障算法研究与仿真[J].通信技术. 2019,52(07)
3 备注
简介此部分摘自互联网,仅供参考,若侵权,联系删除
🍅 仿真咨询
1 各类智能优化算法改进及应用
生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化
2 机器学习和深度学习方面
卷积神经网络(CNN)、LSTM、支持向量机(SVM)、最小二乘支持向量机(LSSVM)、极限学习机(ELM)、核极限学习机(KELM)、BP、RBF、宽度学习、DBN、RF、RBF、DELM、XGBOOST、TCN实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断
3 图像处理方面
图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知
4 路径规划方面
旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划、天线线性阵列分布优化、车间布局优化
5 无人机应用方面
无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配
6 无线传感器定位及布局方面
传感器部署优化、通信协议优化、路由优化、目标定位优化、Dv-Hop定位优化、Leach协议优化、WSN覆盖优化、组播优化、RSSI定位优化
7 信号处理方面
信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号、信号配时优化
8 电力系统方面
微电网优化、无功优化、配电网重构、储能配置
9 元胞自动机方面
交通流 人群疏散 病毒扩散 晶体生长