欢迎关注
个人主页:我爱Matlab
点赞➕评论➕收藏 == 养成习惯(一键三连)希望大家多多支持~一起加油
语录:将来的我一定会感谢现在奋斗的自己!
自主式水下机器人(Autonomous Underwater Vehicle,简称AUV)是近世纪发展起来的具有一定的自主导航和规划能力的水下机器人,可广泛应用于海洋学勘测、地形地貌测量、目标搜索、海底管线检测维修等领域,甚至可以用于水下古迹勘探或水下影视特技,通常可以在危险或人力不可到达的海域活动,扩展载人潜器或有缆潜器/水下机器人的作业能力与探测范围,AUV的这种自主性表现之一是 具有基于环境模型的全局规划能力。
应用遗传算法(GA)对AUV在大范围海洋环境中的全局路径规划问题进行了研究。介绍了基于栅格的环境模型及其数据结构 ,通过仿真结果可以看出 :GA采用可变长编码方式使路径描述简单、清晰 ,具有收敛速度快、求解实际问题效率高的特点,满足系统实时性要求 。
clear all;
close all;
%% global variables
load ('coor.mat'); %Load data generated by RP_coordinate.m
Popsize =50; %Population size, should be an even integer
%Genetic parameters
%MIXRATE = 0.3;
ITERATION = 10000; %Number of iteration
THRESHOLD = 100;
Pcross = 0.7; %Crossover rate
Pmutation = 0.3; %Mutation rate
%Begin
Parentpop=InitPop(Popsize,RPNUM,adjacency);
Fitnesscurve=[];
Generation = 1;
Fitconst=0; %Number of generations that fitness values remain constant
%% Genetic algorithm
while(Generation <= ITERATION)
if (Fitconst<=THRESHOLD) %Stop iteration if fitness value is constant in threshold number of genreations
fitness = Fitness(Parentpop,adjacency); %Calculate fitness of parents
crossover = Crossover(Parentpop,Pcross); %Crossover
Childpop = Mutation(crossover,Pmutation); %Mutate and get chindren
combopop=[Parentpop;Childpop]; %Combine parents and chindren
combofitness=Fitness(combopop,adjacency); %Calculate overall fitness
nextpop=Select(combopop,combofitness); %Select the first half of best to get 2nd gen
Parentpop=nextpop.pop;
if(Generation ==1)
Best_GApath=Parentpop(1,:);
Best_Fitness=combofitness(nextpop.bestplan);
else
New_Best_Fitness=combofitness(nextpop.bestplan);%Evaluate best solution
New_Best_GApath=Parentpop(1,:);
if(New_Best_Fitness
Best_GApath=New_Best_GApath;
Fitconst = 0;
%%%%%%%%Visualize planning process%%%%%%%%
% GENERATION=[1:Generation-1];
% GAplancoor = [RP(Best_GApath).x;RP(Best_GApath).y; RP(Best_GApath).z].';
% figure(1);
% for i=1:RPNUM
% subplot(2,1,1); %Plot all rendezvous points
% plot3(RP(i).x,RP(i).y,RP(i).z,'o');
% text(RP(i).x,RP(i).y, RP(i).z,num2str(i));
% hold on;
% subplot(2,1,2);
% plot(RP(i).x,RP(i).y,'o');
% text(RP(i).x,RP(i).y,num2str(i));
% hold on;
% end
% subplot(2,1,1);
% plot3(GAplancoor(:,1),GAplancoor(:,2),GAplancoor(:,3),'r-.');
% title('3D Path of AUV');
% grid on;
% hold off;
% subplot(2,1,2);
% plot(GAplancoor(:,1),GAplancoor(:,2),'r-.');
% title('2D Path of AUV');
% grid on;
% hold off;
%%%%%%%%Visualize planning process%%%%%%%%
else
Fitconst=Fitconst+1;
end
end
完整代码:基于遗传算法的自主式水下潜器路径规划问题
[1]王宏健,边信黔,唐照东,施小成,丁福光.大范围环境下自主式水下潜器两种全局路径规划方法的研究[J].中国造船,2004(03):81-86.