基于象鼻虫损害优化算法求解单目标无约束问题并可视化分析(Matlab代码实现)

发布于:2022-11-14 ⋅ 阅读:(517) ⋅ 点赞:(0)

 📝个人主页:研学社的博客 

💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码及文章阅读

💥1 概述

象鼻虫是一种长着细长鼻子的昆虫,来自Curculionoide超科,约有97000种。其中大多数认为害虫会造成环境破坏,但一些种类,如小麦象鼻虫、玉米象鼻虫和棉铃象鼻虫,以对农作物,尤其是谷物造成巨大破坏而闻名。这项研究提出了一种新的基于群的元启发式算法,称为象鼻虫损伤优化算法(WDOA),该算法模拟了象鼻虫的飞行能力、鼻部力量和对作物或农产品的损伤能力。用12个基准单峰和多峰人工景观或优化测试函数对所提出的算法进行了测试。此外,所提出的WDOA被用于五个工程问题,以检查其解决问题的鲁棒性。问题包括旅行推销员问题(TSP)、n-Queens问题、投资组合问题、最优库存控制问题(OIC)和装箱问题(BPP)。所有测试的功能都与广泛使用的粒子群优化(PSO)、遗传算法(GA)、和谐搜索(HS)算法、帝国主义竞争算法(ICA)、萤火虫算法(FA)和差分进化(DE)算法等基准算法进行了比较。此外,所有问题都用DE、FA和HS算法进行了测试,所提出的算法通过提供精确性和合理的速度,在所有函数和问题上表现出鲁棒性和速度。

算法文章来源:

📚2 运行结果

 

 

 

 

 

 

 

 

 

 

 

 

部分代码:

function ezimage(fun)

prevpath = path;
path(path, genpath(fileparts(mfilename('fullpath'))));

try

% EZIMAGE() takes no input, or a function handle
if (nargin == 0)

% available functions
functions = dir([fileparts(mfilename('fullpath')) filesep 'single-objective-unconstrained']);
functions = cellfun(@(x) x(1:end-2), {functions.name}, 'uniformoutput', false);
functions = functions(3:end);

% show list
clc
fprintf(1, 'Single-objective functions:\n');
for ii = 1:numel(functions)
fprintf(1, ['[', num2str(ii), '] ', functions{ii}, '\n']);
end
fprintf(1, '\n');

% select one
while true
num = str2double(input('Type the number of the function you wish to plot: ', 's'));
if isfinite(num) && (num <= numel(functions)), break, end
end

% set proper function
evalc(['fun = @', functions{num}]);

else
if ~isa(fun, 'function_handle')
path(prevpath);
error('ezimage:no_function', ...
'Please provide a function handle to the function to plot.');
end
end

% evaluate function with no argument to get some
% info about the function
[dims, lb, ub, solution, minimum] = feval(fun);

% if the number of dimensions exceeds 3, we can't plot
if (dims > 2) || ~isfinite(dims) % [inf] means arbitrary # dimensions
path(prevpath);
error('ezimage:too_many_dimensions',...
'Given function requires %d dimensions to be plotted, and we live in a 3-D world.', dims+1);
end

% initialize
x1 = linspace(lb(1), ub(1), 150);
x2 = linspace(lb(2), ub(2), 150);
x3 = zeros(length(x1), length(x2));

% simply loop through the function (most functions expect
% [N x 2] vectors as input, so meshgrid does not work)
for ii = 1:length(x1)
for jj = 1:length(x2)
x3(ii, jj) = fun([x1(ii), x2(jj)]);
end
end

% build simple grid for axes
[x1, x2] = meshgrid(x1, x2);

% draw surface
figure, hold on
surf(x1', x2', x3, 'Linestyle', 'none')

% draw minima
if ~isnan(solution)
plot3(solution(:,1), solution(:,2), repmat(minimum, size(solution,1), 1), ...
'r.', 'MarkerSize', 20);
end

% tiles, labels, legend
xlabel('x_1'), ylabel('x_2'), zlabel('F(x_1, x_2)')
ax = gca; 
ax.FontSize = 14; 
ax.FontWeight='bold';
if (size(solution,1) > 1)
legend([func2str(fun), '-function'], 'Global Minima')
else
legend([func2str(fun), '-function'], 'Global Minimum')
end

% finalize
view(-40, 30)
set(gcf, 'renderer', 'openGl');

% something's wrong
catch ME
path(prevpath);
rethrow(ME);
end

% reset previous path
path(prevpath);

end
 

🎉3 参考文献

部分理论来源于网络,如有侵权请联系删除。

🌈4 Matlab代码及文章阅读

本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到