欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3246|回復(fù): 1
收起左側(cè)

蟻群算法的路徑規(guī)劃matlab源碼

[復(fù)制鏈接]
ID:427057 發(fā)表于 2018-11-15 14:20 | 顯示全部樓層 |閱讀模式
蟻群優(yōu)化算法源代碼1、蟻群算法的優(yōu)化計算-旅行商問題(TSP)優(yōu)化-MATLAB源代碼; 2、基于蟻群算法的二維路徑規(guī)劃算法-MATLAB源代碼; 3、基于蟻群算法的三維路徑規(guī)劃算法-MATLAB源代碼;
0.png

matlab源程序如下:
  1. %% 該函數(shù)用于演示基于蟻群算法的三維路徑規(guī)劃算法

  2. %% 清空環(huán)境
  3. clc
  4. clear

  5. %% 數(shù)據(jù)初始化

  6. %下載數(shù)據(jù)
  7. load  HeightData HeightData

  8. %網(wǎng)格劃分
  9. LevelGrid=10;
  10. PortGrid=21;

  11. %起點(diǎn)終點(diǎn)網(wǎng)格點(diǎn)
  12. starty=10;starth=4;
  13. endy=8;endh=5;
  14. m=1;
  15. %算法參數(shù)
  16. PopNumber=10;         %種群個數(shù)
  17. BestFitness=[];    %最佳個體

  18. %初始信息素
  19. pheromone=ones(21,21,21);

  20. %% 初始搜索路徑
  21. [path,pheromone]=searchpath(PopNumber,LevelGrid,PortGrid,pheromone, ...
  22.     HeightData,starty,starth,endy,endh);
  23. fitness=CacuFit(path);                          %適應(yīng)度計算
  24. [bestfitness,bestindex]=min(fitness);           %最佳適應(yīng)度
  25. bestpath=path(bestindex,:);                     %最佳路徑
  26. BestFitness=[BestFitness;bestfitness];          %適應(yīng)度值記錄

  27. %% 信息素更新
  28. rou=0.2;
  29. cfit=100/bestfitness;
  30. for i=2:PortGrid-1
  31.     pheromone(i,bestpath(i*2-1),bestpath(i*2))= ...
  32.         (1-rou)*pheromone(i,bestpath(i*2-1),bestpath(i*2))+rou*cfit;
  33. end
  34.    
  35. %% 循環(huán)尋找最優(yōu)路徑
  36. for kk=1:100
  37.      
  38.     %% 路徑搜索
  39.     [path,pheromone]=searchpath(PopNumber,LevelGrid,PortGrid,...
  40.         pheromone,HeightData,starty,starth,endy,endh);
  41.    
  42.     %% 適應(yīng)度值計算更新
  43.     fitness=CacuFit(path);                              
  44.     [newbestfitness,newbestindex]=min(fitness);     
  45.     if newbestfitness<bestfitness
  46.         bestfitness=newbestfitness;
  47.         bestpath=path(newbestindex,:);
  48.     end
  49.     BestFitness=[BestFitness;bestfitness];
  50.    
  51.     %% 更新信息素
  52.     cfit=100/bestfitness;
  53.     for i=2:PortGrid-1
  54.         pheromone(i,bestpath(i*2-1),bestpath(i*2))=(1-rou)* ...
  55.             pheromone(i,bestpath(i*2-1),bestpath(i*2))+rou*cfit;
  56.     end

  57. end

  58. %% 最佳路徑
  59. for i=1:21
  60.     a(i,1)=bestpath(i*2-1);
  61.     a(i,2)=bestpath(i*2);
  62. end
  63. figure(1)
  64. x=1:21;
  65. y=1:21;
  66. [x1,y1]=meshgrid(x,y);
  67. mesh(x1,y1,HeightData)
  68. axis([1,21,1,21,0,2000])
  69. hold on
  70. k=1:21;
  71. plot3(k(1)',a(1,1)',a(1,2)'*200,'--o','LineWidth',2,...
  72.                        'MarkerEdgeColor','k',...
  73.                        'MarkerFaceColor','g',...
  74.                        'MarkerSize',10)
  75. plot3(k(21)',a(21,1)',a(21,2)'*200,'--o','LineWidth',2,...
  76.                        'MarkerEdgeColor','k',...
  77.                        'MarkerFaceColor','g',...
  78.                        'MarkerSize',10)
  79.                    text(k(1)',a(1,1)',a(1,2)'*200,'S');
  80. text(k(21)',a(21,1)',a(21,2)'*200,'T');
  81. xlabel('km','fontsize',12);
  82. ylabel('km','fontsize',12);
  83. zlabel('m','fontsize',12);
  84. title('三維路徑規(guī)劃空間','fontsize',12)
  85. set(gcf, 'Renderer', 'ZBuffer')
  86. hold on
  87. plot3(k',a(:,1)',a(:,2)'*200,'--o')

  88. %% 適應(yīng)度變化
  89. figure(2)
  90. plot(BestFitness)
  91. title('最佳個體適應(yīng)度變化趨勢')
  92. xlabel('迭代次數(shù)')
  93. ylabel('適應(yīng)度值')
復(fù)制代碼

所有資料51hei提供下載:
蟻群優(yōu)化算法源代碼1、蟻群算法的優(yōu)化計算-旅行商問題(TSP)優(yōu)化-MATLAB源代碼; 2、.rar (11.71 KB, 下載次數(shù): 45)


回復(fù)

使用道具 舉報

ID:499737 發(fā)表于 2019-3-28 10:54 | 顯示全部樓層
bucuo
回復(fù)

使用道具 舉報

無效樓層,該帖已經(jīng)被刪除
您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表