鼠群优化器RSO

目录

前言

算法原理

猎物追逐

猎物攻击

优缺点

鼠群算法伪代码

算法改进

DE-RSO混合策略

反向学习策略

改进算法伪代码

 实验结果与分析

​编辑

 结论

代码

MATLAB


前言

鼠群优化算法(Rat Swarm Optimizer, RSO) 是一种由Gaurav Dhiman等人在2020年提出的新型的仿生优化算法。RSO的灵感来自于自然界种鼠群追逐猎物和与猎物搏斗的行为。可以解决全局优化问题的新型仿生优化算法,它的灵感主要来自于自然界种鼠群追逐猎物和与猎物搏斗的行为。老鼠具有很丰富的社交智慧,它们通过追逐、跳跃和搏斗等各种行为相互沟通。它们具有很强的领土意识,当它们被侵犯时,就会变得非常有攻击性。

算法原理

猎物追逐

老鼠是一种社会性很强的动物,它们是通过社会群体行为来追逐猎物的。为了从数学上定义这种行为,将种群中最优个体的位置设定为猎物的位置,其他个体通过当前最优个体更新它们的位置。这个过程被定义为公式(1):

 参数R随机分布在区间[1, 5],参数C随机分布在区间[0, 2]。通过调整参数AC的取值,以在平衡算法局部搜索和全局搜索之间取得折衷。

猎物攻击

鼠群与猎物搏斗的过程可以被定义为公式(4):

优缺点

RSO在数学上模拟了自然界种鼠群追逐猎物和与猎物搏斗的行为,并可以有效解决全局优化问题,此外它还具有结构简单和参数较少的优点。由于RSO的新颖性,关于修改或应用RSO的文献很少,但是它已经开始被应用到医药领域 。

然而,由于模拟鼠群追逐猎物的过程过于随机且不够精确,因此,RSO具有速度过慢和容易陷入局部最优等缺点。

鼠群算法伪代码

算法改进

基于反向学习的DE-RSO混合优化算法,参考徐子岳,梁晓丹的论文

为了改善RSO的性能,本文提出了一种基于反向学习的DE-RSO混合优化算法(Opposition-Based Learning DE-RSO Hybrid Optimizer, OBLDE-RSO),该算法首先使用一种DE-RSO混合策略,将差分进化算法的变异机制应用到RSO中,以增加种群的多样性,然后用反向学习策略(Opposition-Based Learning, OBL),针对性地扩大个体的搜索范围,使个体以更高概率找到潜在的更加理想的求解区域。同时,为了加速算法收敛,对RSO本身的参数进行了调整优化。

DE-RSO混合策略

为了维持种群的多样性,将DE中的变异机制引入到RSO中,对种群中的个体进行振荡,同时在算法中引入一个参数B以提高算法的收敛速度。我们使用一个比例参数pcr来随机选择采用何种更新方式,所以鼠群搏斗的过程可以描述为公式(5):

反向学习策略

由公式(8)和公式(9)可以看出,随机的猜测点和猜测它的相反值可以同时以更高的概率来找到潜在的更加理想的求解区域,其中最优解就很有可能位于其中。

在得到一个个体的相反个体后,同时计算该个体与其相反个体的适应度值,比较两者的适应度值,若其相反个体的适应度值优于原个体的适应度值,原个体将被相反个体所替代,这样个体将会用更高的概率靠近最优个体,计算效率和计算精确度会得到明显提高

改进算法伪代码

 实验结果与分析

引入了IEEE CEC2017基准测试函数集,利用该测试函数集测试OBLDE-RSO算法。IEEE CEC2017基准测试函数集由29个函数组成,包括2个单峰函数(g1, g3),7个简单多峰函数(g4-g10),10个混合函数(g11-g20)和10个组合函数(g21-g30)。 。

在本实验中,为了进行公平的比较,操作环境保持不变,如下:

1) 每个函数独立运行30次。

2) 种群规模为150,个体维度为30。

3) 函数的评估总次数为45,000次。

4) 搜索范围为[−100, 100]。

这些实验都是在一台具有I7处理器、windows 10操作系统和8 GB内存的计算机上执行的,所有算法都是在Matlab2018b中进行编码的。

为了证明OBLDE-RSO性能的优越性,我们将基于反向学习的DE-RSO混合优化算法OBLDE-RSO同鼠群算法RSO、差分进化算法DE、狮群算法LSO和遗传算法GA进行比较。

表4是OBLDE-RSO,RSO,DE,LSO和GA的对比结果,结果包括各算法在测试函数集中独立运行30次的平均值(Mean)和标准差(Std)。

表4 OBLDE-RSO,RSO,DE,LSO和GA的对比结果

由表4可知,在大部分情况下OBLDE-RSO的性能优于RSO、DE、LSO、GA。具体来说,在29个测试函数中,OBLDE-RSO在其中的27个对RSO、DE、LSO、GA表现出了更加出色的性能。OBLDE-RSO在单峰函数、简单多峰函数和混合函数上,在求解的精确度上比其他比较算法具有绝对的优势。在组合函数上,OBLDE-RSO也具有十分优异的性能。这说明DE-RSO混合策略和反向学习策略的使用也可以提高RSO的性能。

另外,在四类测试函数中各挑取一个代表函数(g1, g6, g16, g24)绘制收敛图和盒型图,以进一步分析实验结果。图1和图2分别是算法在四个函数中的测试后的收敛图和盒型图。

图1中可以直观地展示出OBLDE-RSO,RSO,LSO,DE和GA的收敛性能。OBLDE-RSO的收敛趋势线比其他比较算法的收敛速度更快,同时,OBLDE-RSO的收敛精度也高于其他比较算法,这进一步证实了使用两种策略可以提高算法的收敛速度和收敛精度。

在图2中,盒型图展示出4次实验得到的实验结果。由图可以看出,在绝大多数情况下,OBLDE-RSO的结果优于其他比较算法,说明OBLDE-RSO具有更加优越和稳定的数据结构。

 

 图1 各算法的收敛曲线对比图

 

 图2 算法的盒图对比结果

 结论

 基于反向学习的DE-RSO混合优化算法,算法使用了DE-RSO混合策略和反向学习策略以提高算法的性能。DE-RSO混合策略使用变异机制以保持种群多样性并降低算法陷入局部最优的可能性,可以有效改善RSO过早收敛的缺点。OBL策略可以针对性地扩大个体的搜索范围,使个体以更高概率找到潜在的更加理想的求解区域。同时添加一个参数B以控制算法在搜索前期和后期的不同搜索任务。通过对比OBLDE-RSO和其它比较算法在IEEE CEC2017测试函数集上的实验数据和图像,证明了使用了两种策略后,算法的局部搜索能力和全局搜索能力都得到了很大的提升。

代码

MATLAB

fun_info


   
   
  1. function [lowerbound,upperbound,dimension,fitness] = fun_info(F)
  2. switch F
  3. case 'F1'
  4. fitness = @F 1;
  5. lowerbound =- 100;
  6. upperbound = 100;
  7. dimension = 30;
  8. case 'F2'
  9. fitness = @F 2;
  10. lowerbound =- 10;
  11. upperbound = 10;
  12. dimension = 30;
  13. case 'F3'
  14. fitness = @F 3;
  15. lowerbound =- 100;
  16. upperbound = 100;
  17. dimension = 30;
  18. case 'F4'
  19. fitness = @F 4;
  20. lowerbound =- 100;
  21. upperbound = 100;
  22. dimension = 30;
  23. case 'F5'
  24. fitness = @F 5;
  25. lowerbound =- 30;
  26. upperbound = 30;
  27. dimension = 30;
  28. case 'F6'
  29. fitness = @F 6;
  30. lowerbound =- 100;
  31. upperbound = 100;
  32. dimension = 30;
  33. case 'F7'
  34. fitness = @F 7;
  35. lowerbound =- 1.28;
  36. upperbound = 1.28;
  37. dimension = 30;
  38. case 'F8'
  39. fitness = @F 8;
  40. lowerbound =- 500;
  41. upperbound = 500;
  42. dimension = 30;
  43. case 'F9'
  44. fitness = @F 9;
  45. lowerbound =- 5.12;
  46. upperbound = 5.12;
  47. dimension = 30;
  48. case 'F10'
  49. fitness = @F 10;
  50. lowerbound =- 32;
  51. upperbound = 32;
  52. dimension = 30;
  53. case 'F11'
  54. fitness = @F 11;
  55. lowerbound =- 600;
  56. upperbound = 600;
  57. dimension = 30;
  58. case 'F12'
  59. fitness = @F 12;
  60. lowerbound =- 50;
  61. upperbound = 50;
  62. dimension = 30;
  63. case 'F13'
  64. fitness = @F 13;
  65. lowerbound =- 50;
  66. upperbound = 50;
  67. dimension = 30;
  68. case 'F14'
  69. fitness = @F 14;
  70. lowerbound =- 65.536;
  71. upperbound = 65.536;
  72. dimension = 2;
  73. case 'F15'
  74. fitness = @F 15;
  75. lowerbound =- 5;
  76. upperbound = 5;
  77. dimension = 4;
  78. case 'F16'
  79. fitness = @F 16;
  80. lowerbound =- 5;
  81. upperbound = 5;
  82. dimension = 2;
  83. case 'F17'
  84. fitness = @F 17;
  85. lowerbound =[- 5,0];
  86. upperbound =[ 10,15];
  87. dimension = 2;
  88. case 'F18'
  89. fitness = @F 18;
  90. lowerbound =- 2;
  91. upperbound = 2;
  92. dimension = 2;
  93. case 'F19'
  94. fitness = @F 19;
  95. lowerbound = 0;
  96. upperbound = 1;
  97. dimension = 3;
  98. case 'F20'
  99. fitness = @F 20;
  100. lowerbound = 0;
  101. upperbound = 1;
  102. dimension = 6;
  103. case 'F21'
  104. fitness = @F 21;
  105. lowerbound = 0;
  106. upperbound = 10;
  107. dimension = 4;
  108. case 'F22'
  109. fitness = @F 22;
  110. lowerbound = 0;
  111. upperbound = 10;
  112. dimension = 4;
  113. case 'F23'
  114. fitness = @F 23;
  115. lowerbound = 0;
  116. upperbound = 10;
  117. dimension = 4;
  118. end
  119. end
  120. % F 1
  121. function R = F 1(x)
  122. R = sum(x.^ 2);
  123. end
  124. % F 2
  125. function R = F 2(x)
  126. R = sum(abs(x)) +prod(abs(x));
  127. end
  128. % F 3
  129. function R = F 3(x)
  130. dimension = size(x, 2);
  131. R = 0;
  132. for i = 1:dimension
  133. R =R + sum(x( 1:i))^ 2;
  134. end
  135. end
  136. % F 4
  137. function R = F 4(x)
  138. R =max(abs(x));
  139. end
  140. % F 5
  141. function R = F 5(x)
  142. dimension = size(x, 2);
  143. R = sum( 100 *(x( 2:dimension)-(x( 1:dimension- 1).^ 2)).^ 2 +(x( 1:dimension- 1)- 1).^ 2);
  144. end
  145. % F 6
  146. function R = F 6(x)
  147. R = sum(abs((x +. 5)).^ 2);
  148. end
  149. % F 7
  150. function R = F 7(x)
  151. dimension = size(x, 2);
  152. R = sum([ 1:dimension]. *(x.^ 4)) +rand;
  153. end
  154. % F 8
  155. function R = F 8(x)
  156. R = sum(-x. *sin(sqrt(abs(x))));
  157. end
  158. % F 9
  159. function R = F 9(x)
  160. dimension = size(x, 2);
  161. R = sum(x.^ 2- 10 *cos( 2 *pi. *x)) + 10 *dimension;
  162. end
  163. % F 10
  164. function R = F 10(x)
  165. dimension = size(x, 2);
  166. R =- 20 *exp(-. 2 *sqrt( sum(x.^ 2) /dimension))-exp( sum(cos( 2 *pi. *x)) /dimension) + 20 +exp( 1);
  167. end
  168. % F 11
  169. function R = F 11(x)
  170. dimension = size(x, 2);
  171. R = sum(x.^ 2) / 4000-prod(cos(x. /sqrt([ 1:dimension]))) + 1;
  172. end
  173. % F 12
  174. function R = F 12(x)
  175. dimension = size(x, 2);
  176. R =(pi /dimension) *( 10 *((sin(pi *( 1 +( x(1) + 1) / 4)))^ 2) + sum((((x( 1:dimension- 1) + 1). / 4).^ 2). *...
  177. ( 1 + 10. *((sin(pi. *( 1 +(x( 2:dimension) + 1). / 4)))).^ 2)) +((x(dimension) + 1) / 4)^ 2) + sum(Ufun(x, 10,100,4));
  178. end
  179. % F 13
  180. function R = F 13(x)
  181. dimension = size(x, 2);
  182. R =. 1 *((sin( 3 *pi * x(1)))^ 2 + sum((x( 1:dimension- 1)- 1).^ 2. *( 1 +(sin( 3. *pi. *x( 2:dimension))).^ 2)) +...
  183. ((x(dimension)- 1)^ 2) *( 1 +(sin( 2 *pi *x(dimension)))^ 2)) + sum(Ufun(x, 5,100,4));
  184. end
  185. % F 14
  186. function R = F 14(x)
  187. aS =[- 32 - 16 0 16 32 - 32 - 16 0 16 32 - 32 - 16 0 16 32 - 32 - 16 0 16 32 - 32 - 16 0 16 32;,...
  188. - 32 - 32 - 32 - 32 - 32 - 16 - 16 - 16 - 16 - 16 0 0 0 0 0 16 16 16 16 16 32 32 32 32 32];
  189. for j = 1: 25
  190. bS(j) = sum((x '-aS(:,j)).^6);
  191. end
  192. R=(1/500+sum(1./([1:25]+bS))).^(-1);
  193. end
  194. % F15
  195. function R = F15(x)
  196. aK=[.1957 .1947 .1735 .16 .0844 .0627 .0456 .0342 .0323 .0235 .0246];
  197. bK=[.25 .5 1 2 4 6 8 10 12 14 16];bK=1./bK;
  198. R=sum((aK-((x(1).*(bK.^2+x(2).*bK))./(bK.^2+x(3).*bK+x(4)))).^2);
  199. end
  200. % F16
  201. function R = F16(x)
  202. R=4*(x(1)^2)-2.1*(x(1)^4)+(x(1)^6)/3+x(1)*x(2)-4*(x(2)^2)+4*(x(2)^4);
  203. end
  204. % F17
  205. function R = F17(x)
  206. R=(x(2)-(x(1)^2)*5.1/(4*(pi^2))+5/pi*x(1)-6)^2+10*(1-1/(8*pi))*cos(x(1))+10;
  207. end
  208. % F18
  209. function R = F18(x)
  210. R=(1+(x(1)+x(2)+1)^2*(19-14*x(1)+3*(x(1)^2)-14*x(2)+6*x(1)*x(2)+3*x(2)^2))*...
  211. (30+(2*x(1)-3*x(2))^2*(18-32*x(1)+12*(x(1)^2)+48*x(2)-36*x(1)*x(2)+27*(x(2)^2)));
  212. end
  213. % F19
  214. function R = F19(x)
  215. aH=[3 10 30;.1 10 35;3 10 30;.1 10 35];cH=[1 1.2 3 3.2];
  216. pH=[.3689 .117 .2673;.4699 .4387 .747;.1091 .8732 .5547;.03815 .5743 .8828];
  217. R=0;
  218. for i=1:4
  219. R=R-cH(i)*exp(-(sum(aH(i,:).*((x-pH(i,:)).^2))));
  220. end
  221. end
  222. % F20
  223. function R = F20(x)
  224. aH=[10 3 17 3.5 1.7 8;.05 10 17 .1 8 14;3 3.5 1.7 10 17 8;17 8 .05 10 .1 14];
  225. cH=[1 1.2 3 3.2];
  226. pH=[.1312 .1696 .5569 .0124 .8283 .5886;.2329 .4135 .8307 .3736 .1004 .9991;...
  227. .2348 .1415 .3522 .2883 .3047 .6650;.4047 .8828 .8732 .5743 .1091 .0381];
  228. R=0;
  229. for i=1:4
  230. R=R-cH(i)*exp(-(sum(aH(i,:).*((x-pH(i,:)).^2))));
  231. end
  232. end
  233. % F21
  234. function R = F21(x)
  235. aSH=[4 4 4 4;1 1 1 1;8 8 8 8;6 6 6 6;3 7 3 7;2 9 2 9;5 5 3 3;8 1 8 1;6 2 6 2;7 3.6 7 3.6];
  236. cSH=[.1 .2 .2 .4 .4 .6 .3 .7 .5 .5];
  237. R=0;
  238. for i=1:5
  239. R=R-((x-aSH(i,:))*(x-aSH(i,:))' +cSH(i))^(- 1);
  240. end
  241. end
  242. % F 22
  243. function R = F 22(x)
  244. aSH =[ 4 4 4 4; 1 1 1 1; 8 8 8 8; 6 6 6 6; 3 7 3 7; 2 9 2 9; 5 5 3 3; 8 1 8 1; 6 2 6 2; 7 3.6 7 3.6];
  245. cSH =[. 1 . 2 . 2 . 4 . 4 . 6 . 3 . 7 . 5 . 5];
  246. R = 0;
  247. for i = 1: 7
  248. R =R-((x-aSH(i,:)) *(x-aSH(i,:)) '+cSH(i))^(-1);
  249. end
  250. end
  251. % F23
  252. function R = F23(x)
  253. aSH=[4 4 4 4;1 1 1 1;8 8 8 8;6 6 6 6;3 7 3 7;2 9 2 9;5 5 3 3;8 1 8 1;6 2 6 2;7 3.6 7 3.6];
  254. cSH=[.1 .2 .2 .4 .4 .6 .3 .7 .5 .5];
  255. R=0;
  256. for i=1:10
  257. R=R-((x-aSH(i,:))*(x-aSH(i,:))' +cSH(i))^(- 1);
  258. end
  259. end
  260. function R =Ufun(x,a,k,m)
  261. R =k. *((x-a).^m). *(x >a) +k. *((-x-a).^m). *(x <(-a));
  262. end

fun_plot


   
   
  1. function fun_plot(fun_name)
  2. [lowerbound,upperbound,dimension,fitness] =fun_info(fun_name);
  3. switch fun_name
  4. case 'F1'
  5. x =- 100: 2: 100; y =x; %[- 100,100]
  6. case 'F2'
  7. x =- 100: 2: 100; y =x; %[- 10,10]
  8. case 'F3'
  9. x =- 100: 2: 100; y =x; %[- 100,100]
  10. case 'F4'
  11. x =- 100: 2: 100; y =x; %[- 100,100]
  12. case 'F5'
  13. x =- 200: 2: 200; y =x; %[- 5,5]
  14. case 'F6'
  15. x =- 100: 2: 100; y =x; %[- 100,100]
  16. case 'F7'
  17. x =- 1: 0.03: 1; y =x %[- 1,1]
  18. case 'F8'
  19. x =- 500: 10: 500;y =x; %[- 500,500]
  20. case 'F9'
  21. x =- 5: 0.1: 5; y =x; %[- 5,5]
  22. case 'F10'
  23. x =- 20: 0.5: 20; y =x;%[- 500,500]
  24. case 'F11'
  25. x =- 500: 10: 500; y =x;%[- 0.5,0.5]
  26. case 'F12'
  27. x =- 10: 0.1: 10; y =x;%[-pi,pi]
  28. case 'F13'
  29. x =- 5: 0.08: 5; y =x;%[- 3,1]
  30. case 'F14'
  31. x =- 100: 2: 100; y =x;%[- 100,100]
  32. case 'F15'
  33. x =- 5: 0.1: 5; y =x;%[- 5,5]
  34. case 'F16'
  35. x =- 1: 0.01: 1; y =x;%[- 5,5]
  36. case 'F17'
  37. x =- 5: 0.1: 5; y =x;%[- 5,5]
  38. case 'F18'
  39. x =- 5: 0.06: 5; y =x;%[- 5,5]
  40. case 'F19'
  41. x =- 5: 0.1: 5; y =x;%[- 5,5]
  42. case 'F20'
  43. x =- 5: 0.1: 5; y =x;%[- 5,5]
  44. case 'F21'
  45. x =- 5: 0.1: 5; y =x;%[- 5,5]
  46. case 'F22'
  47. x =- 5: 0.1: 5; y =x;%[- 5,5]
  48. case 'F23'
  49. x =- 5: 0.1: 5; y =x;%[- 5,5]
  50. end
  51. L = length(x);
  52. f =[];
  53. for i = 1:L
  54. for j = 1:L
  55. if strcmp(fun_name, 'F15') = = 0 & & strcmp(fun_name, 'F19') = = 0 & & strcmp(fun_name, 'F20') = = 0 & & strcmp(fun_name, 'F21') = = 0 & & strcmp(fun_name, 'F22') = = 0 & & strcmp(fun_name, 'F23') = = 0
  56. f(i,j) =fitness([x(i),y(j)]);
  57. end
  58. if strcmp(fun_name, 'F15') = = 1
  59. f(i,j) =fitness([x(i),y(j), 0,0]);
  60. end
  61. if strcmp(fun_name, 'F19') = = 1
  62. f(i,j) =fitness([x(i),y(j), 0]);
  63. end
  64. if strcmp(fun_name, 'F20') = = 1
  65. f(i,j) =fitness([x(i),y(j), 0,0,0,0]);
  66. end
  67. if strcmp(fun_name, 'F21') = = 1 || strcmp(fun_name, 'F22') = = 1 ||strcmp(fun_name, 'F23') = = 1
  68. f(i,j) =fitness([x(i),y(j), 0,0]);
  69. end
  70. end
  71. end
  72. surfc(x,y,f, 'LineStyle', 'none');
  73. end

init


   
   
  1. function Pos =init(SearchAgents,dimension,upperbound,lowerbound)
  2. Boundary = size(upperbound, 2);
  3. if Boundary = = 1
  4. Pos =rand(SearchAgents,dimension). *(upperbound-lowerbound) +lowerbound;
  5. end
  6. if Boundary > 1
  7. for i = 1:dimension
  8. ub_i =upperbound(i);
  9. lb_i =lowerbound(i);
  10. Pos(:,i) =rand(SearchAgents, 1). *(ub_i-lb_i) +lb_i;
  11. end
  12. end

main


   
   
  1. % Published paper: G. Dhiman et al. %
  2. % A novel algorithm for global optimization: Rat Swarm Optimizer %
  3. % Jounral of Ambient Intelligence and Humanized Computing %
  4. % DOI: https: / /doi.org / 10.1007 /s 12652- 020- 02580- 0 %
  5. clear all
  6. clc
  7. SearchAgents = 30;
  8. Fun_name = 'F1';
  9. Max_iterations = 1000;
  10. [lowerbound,upperbound,dimension,fitness] =fun_info(Fun_name);
  11. [Best_score,Best_pos,SHO_curve] =rso(SearchAgents,Max_iterations,lowerbound,upperbound,dimension,fitness);
  12. figure( 'Position',[ 500 500 660 290])
  13. %Draw search space
  14. subplot( 1,2,1);
  15. fun_plot(Fun_name);
  16. title( 'Parameter space')
  17. xlabel( 'x_1');
  18. ylabel( 'x_2');
  19. zlabel([Fun_name, '( x_1 , x_2 )'])
  20. %Draw objective space
  21. subplot( 1,2,2);
  22. plots =semilogy(SHO_curve, 'Color', 'g');
  23. set(plots, 'linewidth', 2)
  24. title( 'Objective space')
  25. xlabel( 'Iterations');
  26. ylabel( 'Best score');
  27. axis tight
  28. grid on
  29. box on
  30. legend( 'RSO')
  31. display([ 'The best optimal value of the objective function found by RSO is : ', num 2str(Best_score)]);

RSO


   
   
  1. function[Score,Position,Convergence] =rso( Search_Agents,Max_iterations,Lower_bound,Upper_bound,dimension,objective)
  2. Position = zeros( 1,dimension);
  3. Score =inf;
  4. Positions =init( Search_Agents,dimension,Upper_bound,Lower_bound);
  5. Convergence = zeros( 1,Max_iterations);
  6. l = 0;
  7. x = 1;
  8. y = 5;
  9. R = floor((y-x). *rand( 1,1) + x);
  10. while l <Max_iterations
  11. for i = 1: size(Positions, 1)
  12. Flag 4Upper_bound =Positions(i,:) >Upper_bound;
  13. Flag 4Lower_bound =Positions(i,:) <Lower_bound;
  14. Positions(i,:) =(Positions(i,:). *(~(Flag 4Upper_bound +Flag 4Lower_bound))) +Upper_bound. *Flag 4Upper_bound +Lower_bound. *Flag 4Lower_bound;
  15. fitness =objective(Positions(i,:));
  16. if fitness <Score
  17. Score =fitness;
  18. Position =Positions(i,:);
  19. end
  20. end
  21. A =R-l *((R) /Max_iterations);
  22. for i = 1: size(Positions, 1)
  23. for j = 1: size(Positions, 2)
  24. C = 2 *rand();
  25. P_vec =A *Positions(i,j) +abs(C *((Position(j)-Positions(i,j))));
  26. P_ final =Position(j)-P_vec;
  27. Positions(i,j) =P_ final;
  28. end
  29. end
  30. l =l + 1;
  31. Convergence(l) =Score;
  32. end

@[TOC](这里写自定义目录标题)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值