1 简介 2 部分代码 %% ABC + PSO Path Planning Problem % Here, system tries to find the most optimal path between starting point % and destination point with aid of Artificial Bee Colony (ABC) algorithm % and Particle Swarm Optimization
1 简介
2 部分代码
%% ABC + PSO Path Planning Problem% Here, system tries to find the most optimal path between starting point
% and destination point with aid of Artificial Bee Colony (ABC) algorithm
% and Particle Swarm Optimization algorithm combined. It is good strategy
% in robotics path finding. In each run new obstacles in new positions
% defines and a curved line tries to find the best path. Run multiple times
% to find the best result.
% Hope this code help you :)
%% Cleaning The Stage
clc;
clear;
warning('off');
%% Start ABC + PSO Optimal Path Finder
model=Basics();
model.n=6; % number of Handle Points
CostFunction=@(x) Cost(x,model); % Cost Function
nVar=model.n; % Number of Decision Variables
VarSize=[1 nVar]; % Size of Decision Variables Matrix
VarMin.x=model.xmin; % Lower Bound of Variables
VarMax.x=model.xmax; % Upper Bound of Variables
VarMin.y=model.ymin; % Lower Bound of Variables
VarMax.y=model.ymax; % Upper Bound of Variables
%% PSO + ABC Parameters
MaxIt=150; % Maximum Number of Iterations
nPop=20; % Population Size (Swarm Size)
w=1; % Inertia Weight
wdamp=0.98; % Inertia Weight Damping Ratio
c1=1.5; % Personal Learning Coefficient
end
end
% Update Best Solution Ever Found
for i = 1:nPop
if pop(i).Cost <= BestSol.Cost
BestSol = pop(i);
end
end
tOfTheRange)=-particle(i).Velocity.y(OutOfTheRange);
% Update Position Bounds
particle(i).Position.y = max(particle(i).Position.y,VarMin.y);
particle(i).Position.y = min(particle(i).Position.y,VarMax.y);
%
Flag=[', Violation = ' num2str(GlobalBest.Sol.Violation)];
end
disp(['In Iteration Number ' num2str(it) ':ABC+PSO Fittest Value Is = ' num2str(BestCost(it)) Flag]);
% Plot Solution
figure(1);
Plotting(GlobalBest.Sol,model);
pause(0.01);
end
%% Plot Train Stage
figure;
plot(sort(BestCost,'descend'),'r.','LineWidth',3);
title ('ABC + PSO Training');
xlabel('Itr');
ylabel('ABC+PSO Fittest Value');
grid on;
3 仿真结果
4 参考文献
[1]宋彬. 结合粒子群算法和改进蚁群算法的机器人混合路径规划[D]. 中国矿业大学.