資源簡介
設定障礙物,通過蟻群算法完成路徑規劃!

代碼片段和文件信息
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%?Ant?system?(AS)?for?TSP.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear?all;
close?all
clc;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%?Data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nodesLocation?=?LoadNodesLocations();
trackWidth?=?5;
numberOfSection?=?length(nodesLocation)/trackWidth;
nodesFriction?=??ones(150);
i?=?[11?12?19?20?26?27?33?34?47?48?49?50];
nodesFriction(i)?=?99;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%?Parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
numberOfAnts?=?50;??%?To?do:?Set?to?appropriate?value.
alpha?=?1.0;????????%?To?do:?Set?to?appropriate?value.
beta?=?5.0;?????????%?To?do:?Set?to?appropriate?value.
rho?=?0.5;??????????%?To?do:?set?to?appropriate?value.
nearestNeighbourPathLength?=?GetNearestNeighbourPathLength(nodesLocation?nodesFriction?trackWidth);
tau0?=?numberOfAnts/nearestNeighbourPathLength;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Initialization
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
range?=?[0?20?0?20];
tspFigure?=?InitializeTspPlot(nodesLocation?range);
connection?=?InitializeConnections(nodesLocation?nodesLocation?nodesFriction);
pheromoneLevel?=?InitializePheromoneLevels(length(nodesLocation)?tau0);?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%?Main?loop
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
minimumPathLength?=?inf;
iIteration?=?0;
targetPathLength?=?0;
while?(minimumPathLength?>?targetPathLength)
?iIteration?=?iIteration?+?1;
?%%%%%%%%%%%%%%%%%%%%%%%%%%
?%?Generate?paths:
?%%%%%%%%%%%%%%%%%%%%%%%%%%
?pathCollection?=?[];
?pathLengthCollection?=?[];
?for?k?=?1:numberOfAnts
??[path?pathLength]?=?GeneratePath(pheromoneLevel?alpha?beta?trackWidth?nodesLocation?nodesFriction);
?????????????????
??if?(pathLength?????minimumPathLength?=?pathLength;
????disp(sprintf(‘Iteration?%d?ant?%d:?path?length?=?%.5f‘iIterationkminimumPathLength));
????PlotPath(connectionnodesLocationpath?trackWidth);
????bestPath?=?path;
??end
??pathCollection?=?[pathCollection;?path];???????????
??pathLengthCollection?=?[pathLengthCollection;?pathLength];
?end
?%%%%%%%%%%%%%%%%%%%%%%%%%%
?%?Update?pheromone?levels
?%%%%%%%%%%%%%%%%%%%%%%%%%%
?deltaPheromoneLevel?=?ComputeDeltaPheromoneLevels(pathCollectionpathLengthCollection?trackWidth);??%?To?do:?write?the?ComputeDeltaPheromoneLevels?function
?pheromoneLevel?=?UpdatePheromoneLevels(pheromoneLeveldeltaPheromoneLevelrho);??????????%?To?do:?write?the?UpdatePheromoneLevels?function
end
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2555??2018-02-06?20:00??AntRace-master\AntRace-master\AntSystem.m
?????文件????????824??2018-02-06?20:00??AntRace-master\AntRace-master\ComputeDeltaPheromoneLevels.m
?????文件?????????88??2018-02-06?20:00??AntRace-master\AntRace-master\EuclidianDistance.m
?????文件????????668??2018-02-06?20:00??AntRace-master\AntRace-master\GeneratePath.m
?????文件????????853??2018-02-06?20:00??AntRace-master\AntRace-master\GetNearestNeighbourPathLength.m
?????文件???????1360??2018-02-06?20:00??AntRace-master\AntRace-master\GetNode.m
?????文件????????280??2018-02-06?20:00??AntRace-master\AntRace-master\InitializeConnections.m
?????文件????????136??2018-02-06?20:00??AntRace-master\AntRace-master\InitializePheromoneLevels.m
?????文件????????355??2018-02-06?20:00??AntRace-master\AntRace-master\InitializeTspPlot.m
?????文件????????177??2018-02-06?20:00??AntRace-master\AntRace-master\LoadNodesLocations.m
?????文件????????751??2018-02-06?20:00??AntRace-master\AntRace-master\NearestNeighbourg.m
?????文件????????311??2018-02-06?20:00??AntRace-master\AntRace-master\PlotPath.m
?????文件????????392??2018-02-06?20:00??AntRace-master\AntRace-master\README.md
?????文件????????162??2018-02-06?20:00??AntRace-master\AntRace-master\UpdatePheromoneLevels.m
?????目錄??????????0??2018-09-28?08:08??AntRace-master\AntRace-master
?????目錄??????????0??2018-09-28?08:08??AntRace-master
-----------?---------??----------?-----??----
?????????????????8912????????????????????16
- 上一篇:基于蟻群算法的多機器人路徑規劃
- 下一篇:西門子PCS7仿真手冊
評論
共有 條評論