【路径规划】基于matlab无线充电车辆路径和速度预测【含Matlab源码 1473期】
【摘要】
一、获取代码方式
获取代码方式1: 完整代码已上传我的资源:【路径规划】基于matlab无线充电车辆路径和速度预测【含Matlab源码 1473期】
获取代码方式2: 通过订阅紫极神光博客付费专栏,凭...
一、获取代码方式
获取代码方式1:
完整代码已上传我的资源:【路径规划】基于matlab无线充电车辆路径和速度预测【含Matlab源码 1473期】
获取代码方式2:
通过订阅紫极神光博客付费专栏,凭99.9元支付凭证,私信博主,可获得此代码。
备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);
二、部分源代码
clc;
clear all;
close all;
global Qk ax ay Dik tou beta indA indB
%% Intialization
Nnodes=1;
Emax=1000;
Emin=5;
nk=8;
V=20;
Ra=10+(100-10).*rand(1,nk); % data rate
%% New
T=50; %patrolling cycle time constraint
% v,a---velocity and accelration
%% Charging behavior eqn 1
Ptx=10;
Gtx=3;
Grx=2;
lamda=20e-3;
Lp=0.3;
eta=0.9;
beta=0.2316;
tou= ((Gtx.*Grx.*eta./Lp).*(lamda./4.*pi).^2).*Ptx
% Distance4 bw node and chaerger
d=10; %--- Modified
Prx=@(d)(tou./(d+beta).^2)
Prx(2)
% Tx power of Charger
D=15;
itr=5;
for i1=1:itr
noOfNodes=nk;
figure(1);
axis tight manual
clf;
hAx1 = axes;
hold on;
a=1;
b=nk;
r =floor( a + (b-a).*(rand(2,1)));
while(r(1)==r(2))
r =floor( a + (b-a).*(rand(2,1)));
end
sor =r(1);%source node
des=r(2);%destination node
R =5.5; %node transmission range
a=1;
b=noOfNodes;
%X=floor(a + (b-a).*rand(1,noOfNodes));
%Y=floor(a + (b-a).*rand(1,noOfNodes));
X = 1+(30-1)*rand(1,nk);
Y = 1+(30-1)*rand(1,nk);
X1= 10+(20-10)*rand(1,1);
Y1= 10+(20-5)*rand(1,1);
%
X2= 5+(15-5)*rand(1,1);
Y2= 10+(10-5)*rand(1,1);
%Z =[1 0.1 0.6 0.8 0.6 0 0.1 1 1 1];
%plotting network topology
%i2=1;
for i2 = 1:noOfNodes
plot(X(i2),Y(i2),'o','LineWidth',1,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','y',...
'MarkerSize',8');
xlabel('X in m')
ylabel('Y in m')
text(X(i2), Y(i2), num2str(i2),'FontSize',10);
%% Destination
plot(X2,Y2,'^','LineWidth',1,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','r',...
'MarkerSize',14');
hold on
end
axis([0 40 -5 40])
M_max = 14; %// number of cells in vertical direction
N_max = 10; %// number of cells in horizontal direction
trans = 1; %// hexagon orientation (0 or 1)
%// Do the plotting:
hold on
C11={};
C={};
ab=1;
ik=1;
for x=0:7%:2;
ik=x;
for y=0:5
if(mod(ik,2))
x0=3+4.3*x;
y0=3+3*2*y;
hexagon(2,x0,y0);
C11{x+1,y+1}=[x0;y0];
% C{ab}=[x0;y0];
hold on
plot(x0,y0,'ok','MarkerFaceColor','k')
cote=2;
x1=cote*sqrt(2)*[-1 -0.5 0.5 1 0.5 -0.5 -1]+x0;
y1=cote*sqrt(9)*[0 -0.5 -0.5 0 0.5 0.5 0]+y0;
else
x0=3+4.3*x;
y0=3*2*y;
hexagon(2,x0,y0);
C11{x+1,y+1}=[3+4.3*x;3*2*y];
hold on
plot(3+4.3*x,3*2*y,'ok', 'MarkerFaceColor','k')
cote=2;
x1=cote*sqrt(2)*[-1 -0.5 0.5 1 0.5 -0.5 -1]+x0;
y1=cote*sqrt(9)*[0 -0.5 -0.5 0 0.5 0.5 0]+y0;
end
C{ab}=[x0,y0];
%% Inside the polygon or not
[in,on] = inpolygon(X,Y,x1,y1);
Nk(ab)=numel(find(in==1));% set of sensor node
ind=[];
ind=find(in==1);
if(isempty(ind))
Dik{ab}=0;
Qk(ab)=0;
else
Dik{ab}=sqrt((X(ind)-x0).^2 +(Y(ind)-y0).^2 ); % distance froom node i to its cell center
Qk(ab)=1;
end
%Tk --> Time stays of WCV
ab=ab+1;
end
end
% axis([0 30 0 30])
% grid
%% Travelling path Model
k=ab-1;
Z=ones(1,k); %% important
aa=cell2mat(C.');
Xa=aa(:,1);
Ya=aa(:,2);
%% WCV
plot(Xa(1)+2,Ya(1)+2,'o','LineWidth',1,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',12');
plot(Xa(1),Ya(1),'o','LineWidth',1,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','k',...
'MarkerSize',14');
xlabel('X in m')
ylabel('Y in m')
hold on
text(Xa(1), Ya(1),'Vechile Stay Room','FontSize',10);
hold on
saveas(gcf,'fileint.fig','fig')
% %% Existing Routing
s=cell2mat(C.');
ax=s(:,1);
ay=s(:,2);
%% Routing
indA=find(Qk==1);
indB=find(Qk~=1);
G=randperm(numel(indA));
path1 = indA(G);
%% OPTIMIZATION
% %% Problem Definition
CostFunction=@(x) Sphere(x); % Cost Function
ik=1;
%cost1=1000;
eff1=inf;
while(ik<=4000)
T1=1000.*rand(1);
T=CostFunction(T1);
eff=(T);
if(eff<=eff1)
eff1=eff;
TT=T1;
end
costh1(ik)=eff1;
costh(ik)=eff;
ik=ik+1;
end
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,2016.
[2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,2017.
文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。
原文链接:qq912100926.blog.csdn.net/article/details/121054731
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)