【优化求解】基于布谷鸟算法CS实现多目标求解matlab代码

231 阅读1分钟

1 简介

img

img

img

2 部分代码

% Script 布谷鸟算法,求解函数最小值

clear all 
close all ;
clc ;
N = 25; % Number of nests(The scale of solution)
D = 10 ; % Dimensionality of solution
T = 200 ; % Number of iterations
Xmax = 20 ;
Xmin = -20 ;
Pa = 0.25 ; % Probability of building a new nest(After host bird find exotic bird eggs)
nestPop = rand(N,D)*(Xmax-Xmin)+Xmin ;  % Random initial solutions
for t=1:T
  levy_nestPop =  func_levy(nestPop,Xmax,Xmin) ; % Generate new solutions by Levy flights
  nestPop = func_bestNestPop(nestPop,levy_nestPop);  % Choose a best nest among new and old nests     
  rand_nestPop = func_newBuildNest(nestPop,Pa,Xmax,Xmin); % Abandon(Pa) worse nests and build new nests by (Preference random walk )
  nestPop = func_bestNestPop(nestPop,rand_nestPop) ; % Choose a best nest among new and old nests
[~,index] = max(func_fitness(nestPop)) ; % Best nests
  trace(t) = func_objValue(nestPop(index,:)) 
end
figure 
plot(trace);
xlabel('迭代次数') ;
ylabel('适应度值') ;
title('适应度进化曲线') ;
img =gcf;  %获取当前画图的句柄
print(img, '-dpng', '-r600', './img.png')         %即可得到对应格式和期望dpi的图像

3 仿真结果

4 参考文献

[1]尚志勇. 基于改进布谷鸟搜索算法的配送中心选址问题研究. (Doctoral dissertation, 河南大学).

部分理论引用网络文献,若有侵权联系博主删除。

5 MATLAB代码与数据下载地址

见博客主页