当前位置:   article > 正文

2023年最新智能优化算法之——IBI逻辑优化算法(IBL),附MATLAB代码_最新的智能优化算法

最新的智能优化算法

今天给大家带来一个有意思的智能优化算法,IBL算法。

先说效果:在CEC2005函数集测试,基本上毫无压力,把把都能预测的很准确,而且速度极快。大家可以自行尝试哈。

为啥说这个算法有意思呢,大家看IBL的英文全称是:Incomprehensible but Intelligible-in-time logics,我在这里给大家直译成中文就是:难以理解但又能及时理解的逻辑。可能我翻译的不太准确啊,但是我又结合他的摘要,大概的理解就是:人类的思维不像计算机那样,人类的思维是可以随着时间、事物的变化而变化的,在之前看起来毫无逻辑的事情,在经过人类学习一段时间后,这个事情就会变得很有逻辑了。不得不说老外这个思维是真的奇特哈,根据这个也能提出一个新算法,而且效果还很不错。大家感兴趣的可以去看看原文。

参考文献:

Mirrashid, M.; Naderpour, H. Incomprehensible but Intelligible-in-time logics: Theory and optimization algorithm. Knowl.-Based Syst. 2023, 264, 110305. doi点击链接跳转原文 

废话不多说,依旧是2005函数集的测试,附上2005函数集的理论范围:

 大部分优化函数在F8上的表现是不太好的,也就寻优到-4000多,咱们试一下这个IBL:

WOW,直接就干到-9700多去了,看样子不错呀,回头了我会将2023年最新的算法做一个对比,决一雌雄一下。

再试一个F14的,理论值是1,能找到0.998004,还阔以

 

 最后再来一个:

上核心代码!

  1. function [Bests_Results,n_it_phase1,n_it_phase2,n_it_phase3,costs1,costs2,costs3] = ILA (CostFunction,Vmin,Vmax,nV,nNL,nModel,nIt,mIt_Phase1,mIt_Phase2,Bmin,Bmax,nRep,nIt_classification)
  2. %% Initialization
  3. Empty.NL = []; % Current NL
  4. Empty.NLprevious = []; % Previous NL
  5. Empty.Cost = inf;
  6. Empty1.NL = []; % Current NL
  7. Empty1.Average = []; % Previous NL
  8. Empty1.Cost = inf;
  9. Empty1.Members = [];
  10. Experts = repmat (Empty, nNL, 1); % Experts
  11. n_it_phase1 = round(nIt*mIt_Phase1); % Number of iterations in phase 1
  12. n_it_phase2 = round(nIt*mIt_Phase2); % Number of iterations in phase 2
  13. n_it_phase3 = nIt-n_it_phase1-n_it_phase2; % Number of iterations in phase 3
  14. costs1 = zeros(n_it_phase1,1); % Costs of the phase 1
  15. costs2 = zeros(n_it_phase2,1); % Costs of the phase 2
  16. costs3 = zeros(n_it_phase3,1); % Costs of the phase 3
  17. n_Groups = zeros(nModel,1);
  18. Em.NL = [];
  19. Em1.NL = [];
  20. Em1.Cost = inf;
  21. Expert_IbI = repmat (Em1, 1, 1); % The best solution of the current generation
  22. Logic = repmat (Em1, 1, 1); % The best solution before the current generation
  23. Expert_new = repmat (Em1, 1, 1);
  24. K0 = repmat (Em, nNL, 1); % Knowledge 0
  25. K1 = repmat (Em, nNL, 1); % Knowledge 1
  26. Expert_new.NL = [];
  27. Expert_new.Cost = inf;
  28. Knowledge_Phase1 = K0;
  29. Knowledge_Phase2 = K0;
  30. Knowledge_Phase3 = K0;
  31. GroupNumber = ones(nNL,1);
  32. Em2.NL = [];
  33. Em2.Cost = inf;
  34. Bests_Results = repmat (Em2, nIt, 1);
  35. if length(Vmin) ~= (nV)
  36. Vmin=Vmin.*ones(1,nV);
  37. Vmax=Vmax.*ones(1,nV);
  38. end
  39. for i = 1:nNL
  40. Experts(i).NL = unifrnd(Vmin,Vmax,1,nV);
  41. Experts(i).NLprevious = unifrnd(Vmin,Vmax,1,nV);
  42. Experts(i).Cost = CostFunction(Experts(i).NL);
  43. end
  44. % Extract the Logic (Best NL in the previous solutions)
  45. for i = 1:nNL
  46. if CostFunction(Experts(i).NLprevious) <= Logic.Cost
  47. Logic.Cost = CostFunction(Experts(i).NLprevious); % The best solution of before the current generation
  48. Logic.NL = Experts(i).NLprevious;
  49. end
  50. if Experts(i).Cost <= Expert_IbI.Cost
  51. Expert_IbI.Cost = Experts(i).Cost; % The best solution of the current generation
  52. Expert_IbI.NL = Experts(i).NL;
  53. end
  54. end
  55. n_t = zeros(nModel,1);
  56. nt = round((n_it_phase1)/nModel);
  57. for m = 1:nModel
  58. n_t(m,1) = nt;
  59. end
  60. n_t(nModel,1) = (n_it_phase1)-(nModel-1)*nt;
  61. for m = 1:nModel
  62. n_Groups(m,1) = randi(round(nNL/2)); % Number of workgropus in each model
  63. end
  64. %% Phase 0: Grouping (Clustering)
  65. for m = 1:nModel
  66. % Clustering
  67. MAT = zeros(nNL,nV);
  68. for i = 1:nNL
  69. MAT(i,:) = Experts(i).NL;
  70. end
  71. opts = statset('MaxIter',nIt_classification);
  72. lastwarn('Success');
  73. GroupNumber0 = GroupNumber;
  74. GroupNumber = kmeans(MAT,n_Groups(m,1),'Distance','sqeuclidean','Replicates',nRep,'Options',opts);
  75. [warningMessage, warningMessageID] = lastwarn;
  76. if contains(warningMessage, 'Failed to converge')
  77. warnStruct = warning('off');
  78. GroupNumber = GroupNumber0;
  79. if m ==1
  80. n_Groups(m,1) = 1;
  81. else
  82. n_Groups(m,1) = n_Groups(m-1,1);
  83. end
  84. end
  85. Experts_Groups = repmat (Empty1, n_Groups(m,1),1);
  86. n_members = zeros(n_Groups(m,1),1);
  87. for c = 1:n_Groups(m,1)
  88. nn=0;
  89. for i = 1:nNL
  90. if GroupNumber(i,1) == c
  91. nn = nn+1;
  92. end
  93. end
  94. n_members(c,1) = nn;
  95. Experts_Groups(c).Members = repmat (Em, n_members(c,1), 1);
  96. end
  97. %% Phase 1: Workgropus
  98. for it_phase1 = 1:n_t(m,1)
  99. for c = 1:n_Groups(m,1)
  100. SUM = 0;
  101. num = 0;
  102. for i = 1:nNL
  103. if GroupNumber(i,1) == c
  104. num = num+1;
  105. SUM = Experts(i).NL + SUM;
  106. Experts_Groups(c).Members(num).NL = Experts(i).NL;
  107. if Experts(i).Cost <= Experts_Groups(c).Cost
  108. Experts_Groups(c).NL = Experts(i).NL;
  109. Experts_Groups(c).Cost = Experts(i).Cost;
  110. end
  111. end
  112. end
  113. Experts_Groups(c).Average = SUM./n_members(c,1);
  114. end
  115. % Calculate the ratios
  116. D = zeros(nNL,1);
  117. P = zeros(nNL,1);
  118. C = zeros(nNL,1);
  119. for i = 1:nNL
  120. C(i,1) = sqrt(sum((Experts(i).NL-Logic.NL).^2));
  121. D(i,1) = sqrt(sum((Experts(i).NL-Experts(i).NLprevious).^2));
  122. P(i,1) = sqrt(sum((Experts(i).NL-Experts_Groups(GroupNumber(i,1)).NL).^2));
  123. end
  124. min_D = min(D); max_D = max(D);
  125. min_P = min(P); max_P = max(P);
  126. min_C = min(C); max_C = max(C);
  127. Rc = (C-min_C)./(max_C-min_C);
  128. Rp = (P-min_P)./(max_P-min_P);
  129. RD = (D-min_D)./(max_D-min_D);
  130. Bc = Bmin + (Bmax-Bmin)*rand();
  131. Bp = Bmin + (Bmax-Bmin)*rand();
  132. BD = Bmin + (Bmax-Bmin)*rand();
  133. for i = 1:nNL
  134. B = Bmin + (Bmax-Bmin)*rand();
  135. if (Rc(i,1) <= Bc) && (Rp(i,1) <= Bp)
  136. random_member = randi (n_members(GroupNumber(i,1),1));
  137. K0(i).NL = Rp(i,1).*(Experts(i).NL + Experts_Groups(GroupNumber(i,1)).Members(random_member).NL)./2;
  138. elseif (Rc(i,1) <= Bc) && (Rp(i,1) > Bp)
  139. K0(i).NL = Rp(i,1).*(Experts(i).NL + Experts_Groups(GroupNumber(i,1)).Average)./2;
  140. elseif (Rc(i,1) > Bc) && (Rp(i,1) <= Bp)
  141. random_member = randi (n_members(GroupNumber(i,1),1));
  142. K0(i).NL = Rp(i,1).*(Experts_Groups(GroupNumber(i,1)).NL + Experts_Groups(GroupNumber(i,1)).Members(random_member).NL)./2;
  143. elseif (Rc(i,1) > Bc) && (Rp(i,1) > Bp)
  144. K0(i).NL = Rp(i,1).*(Experts_Groups(GroupNumber(i,1)).NL + Experts_Groups(GroupNumber(i,1)).Average)./2;
  145. end
  146. if RD(i,1)<= BD
  147. K1(i).NL = (rand()).*(Experts_Groups(GroupNumber(i,1)).Average);
  148. else
  149. K1(i).NL = (rand()).*(unifrnd(Vmin,Vmax,1,nV));
  150. end
  151. Knowledge_Phase1(i).NL = abs(K0(i).NL + K1(i).NL)./2;
  152. % Update the NL
  153. alpha1 = -1.5+3.*rand(1,nV);
  154. Expert_new.NL = Experts(i).NL + alpha1.*(Knowledge_Phase1(i).NL);
  155. Expert_new.NL = max(Expert_new.NL, Vmin);
  156. Expert_new.NL = min(Expert_new.NL, Vmax);
  157. E1 = Experts(i).NL;
  158. Expert_new.Cost = CostFunction(Expert_new.NL);
  159. COEF = -1.5+3*rand();
  160. K = rand().*Experts_Groups(GroupNumber(i,1)).NL;
  161. NEW.NL = COEF.*(Expert_new.NL) + K;
  162. NEW.NL = max(NEW.NL, Vmin);
  163. NEW.NL = min(NEW.NL, Vmax);
  164. NEW.Cost = CostFunction(NEW.NL);
  165. if NEW.Cost < Expert_new.Cost
  166. Expert_new = NEW;
  167. end
  168. if Expert_new.Cost < Experts(i).Cost
  169. Experts(i).NL = Expert_new.NL;
  170. Experts(i).Cost = Expert_new.Cost;
  171. end
  172. if Experts(i).NL ~= E1
  173. Experts(i).NLprevious = E1;
  174. end
  175. E1 = Expert_IbI.NL;
  176. if Experts(i).Cost < Expert_IbI.Cost
  177. Expert_IbI.Cost = Experts(i).Cost;
  178. Expert_IbI.NL = Experts(i).NL;
  179. end
  180. if Expert_IbI.NL ~= E1
  181. Logic.NL = E1;
  182. end
  183. end
  184. costs1((m-1)*(n_t(1,1))+it_phase1,1) = Expert_IbI.Cost;
  185. Bests_Results((m-1)*(n_t(1,1))+it_phase1).NL = Expert_IbI.NL;
  186. Bests_Results((m-1)*(n_t(1,1))+it_phase1).Cost = Expert_IbI.Cost;
  187. end
  188. end
  189. NUM = n_it_phase1;
  190. for it_phase2 = 1:n_it_phase2
  191. NUM = NUM+1;
  192. % Calculate the ratios
  193. for i = 1:nNL
  194. C(i,1) = sqrt(sum((Experts(i).NL-Logic.NL).^2));
  195. D(i,1) = sqrt(sum((Experts(i).NL-Experts(i).NLprevious).^2));
  196. P(i,1) = sqrt(sum((Experts(i).NL-Expert_IbI.NL).^2));
  197. end
  198. min_D = min(D); max_D = max(D);
  199. min_P = min(P); max_P = max(P);
  200. min_C = min(C); max_C = max(C);
  201. Rc = (C-min_C)./(max_C-min_C);
  202. Rp = (P-min_P)./(max_P-min_P);
  203. RD = (D-min_D)./(max_D-min_D);
  204. Bc = Bmin + (Bmax-Bmin)*rand();
  205. Bp = Bmin + (Bmax-Bmin)*rand();
  206. BD = Bmin + (Bmax-Bmin)*rand();
  207. for i = 1:nNL
  208. B = Bmin + (Bmax-Bmin)*rand();
  209. if (Rc(i,1) <= Bc) && (Rp(i,1) <= Bp)
  210. random_member = randi (nNL);
  211. K0(i).NL = Rp(i,1).*(Experts(i).NL + Experts(random_member).NL)./2;
  212. elseif (Rc(i,1) <= Bc) && (Rp(i,1) > Bp)
  213. SUM = 0;
  214. for ii = 1:nNL
  215. SUM = Experts(ii).NL + SUM;
  216. end
  217. Average = SUM./nNL;
  218. K0(i).NL = Rp(i,1).*(Experts(i).NL + Average)./2;
  219. elseif (Rc(i,1) > Bc) && (Rp(i,1) <= Bp)
  220. random_member = randi (nNL);
  221. K0(i).NL = Rp(i,1).*(Expert_IbI.NL + Experts(random_member).NL)./2;
  222. elseif (Rc(i,1) > Bc) && (Rp(i,1) > Bp)
  223. SUM = 0;
  224. for ii = 1:nNL
  225. SUM = Experts(ii).NL + SUM;
  226. end
  227. Average = SUM./nNL;
  228. K0(i).NL = Rp(i,1).*(Expert_IbI.NL + Average)./2;
  229. end
  230. if RD(i,1)<= BD
  231. SUM = 0;
  232. for ii = 1:nNL
  233. SUM = Experts(ii).NL + SUM;
  234. end
  235. Average = SUM./nNL;
  236. K1(i).NL = (rand()).*(Average);
  237. else
  238. K1(i).NL = (rand()).*(unifrnd(Vmin,Vmax,1,nV));
  239. end
  240. % Update the NL
  241. Knowledge_Phase2(i).NL = abs(K0(i).NL + K1(i).NL)./2;
  242. alpha2 = -0.75+1.5.*rand(1,nV);
  243. Expert_new.NL = Experts(i).NL + alpha2.*(Knowledge_Phase2(i).NL);
  244. Expert_new.NL = max(Expert_new.NL, Vmin);
  245. Expert_new.NL = min(Expert_new.NL, Vmax);
  246. E1 = Experts(i).NL;
  247. Expert_new.Cost = CostFunction(Expert_new.NL);
  248. COEF = -0.75+1.5*rand();
  249. K = rand().*(Expert_IbI.NL);
  250. NEW.NL = COEF.*(Expert_new.NL) + K;
  251. NEW.NL = max(NEW.NL, Vmin);
  252. NEW.NL = min(NEW.NL, Vmax);
  253. NEW.Cost = CostFunction(NEW.NL);
  254. if NEW.Cost < Expert_new.Cost
  255. Expert_new = NEW;
  256. end
  257. if Expert_new.Cost < Experts(i).Cost
  258. Experts(i).NL = Expert_new.NL;
  259. Experts(i).Cost = Expert_new.Cost;
  260. end
  261. if Experts(i).NL ~= E1
  262. Experts(i).NLprevious = E1;
  263. end
  264. E1 = Expert_IbI.NL;
  265. if Experts(i).Cost < Expert_IbI.Cost
  266. Expert_IbI.Cost = Experts(i).Cost;
  267. Expert_IbI.NL = Experts(i).NL;
  268. end
  269. if Expert_IbI.NL ~= E1
  270. Logic.NL = E1;
  271. end
  272. end
  273. costs2(it_phase2,1) = Expert_IbI.Cost;
  274. Bests_Results(NUM).NL = Expert_IbI.NL;
  275. Bests_Results(NUM).Cost = Expert_IbI.Cost;
  276. end
  277. %% Phase 3: IbI Logic Search
  278. for it_phase3 = 1:n_it_phase3
  279. NUM = NUM+1;
  280. for i = 1:nNL
  281. SUM = 0;
  282. for ii = 1:nNL
  283. SUM = SUM + Experts(ii).NL;
  284. end
  285. Average = SUM./nNL;
  286. factor = randi(2);
  287. if factor == 1
  288. Knowledge_Phase3(i).NL = abs(Average - Experts(randi(nNL)).NL);
  289. else
  290. Knowledge_Phase3(i).NL = abs(Average - Expert_IbI.NL);
  291. end
  292. alpha3 = -0.25+0.5.*rand(1,nV);
  293. Expert_new.NL = Experts(i).NL + alpha3.*(Knowledge_Phase3(i).NL);
  294. Expert_new.NL = max(Expert_new.NL, Vmin);
  295. Expert_new.NL = min(Expert_new.NL, Vmax);
  296. Expert_new.Cost = CostFunction(Expert_new.NL);
  297. COEF = -0.25+0.5*rand();
  298. K = rand().*(Expert_IbI.NL);
  299. NEW.NL = COEF.*(Expert_new.NL) + K;
  300. NEW.NL = max(NEW.NL, Vmin);
  301. NEW.NL = min(NEW.NL, Vmax);
  302. NEW.Cost = CostFunction(NEW.NL);
  303. if NEW.Cost < Expert_new.Cost
  304. Expert_new = NEW;
  305. end
  306. if Expert_new.Cost < Experts(i).Cost
  307. Experts(i).NL = Expert_new.NL;
  308. Experts(i).Cost = Expert_new.Cost;
  309. end
  310. if Experts(i).Cost < Expert_IbI.Cost
  311. Expert_IbI.Cost = Experts(i).Cost;
  312. Expert_IbI.NL = Experts(i).NL;
  313. end
  314. end
  315. costs3(it_phase3,1) = Expert_IbI.Cost;
  316. Bests_Results(NUM).NL = Expert_IbI.NL;
  317. Bests_Results(NUM).Cost = Expert_IbI.Cost;
  318. end
  319. %% Extract the results
  320. Expert_IbI.Cost = CostFunction(Expert_IbI.NL);
  321. end

 下方小卡片回复关键词:2023,免费获取2023年智能优化算法合集matlab代码。

后续会继续发布2023年其他最新优化算法,敬请关注。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/415967
推荐阅读
相关标签
  

闽ICP备14008679号