【优化求解】土狼算法matlab源码

 

clear all
close all
clc

% Optimization setup
FOBJ        = @(x) Rastrigin(x);      % Optimization problem
D           = 30;                     % Problem dimension
lu          = [zeros(1,D);ones(1,D)]; % Seach space
nfevalMAX   = 10000*D;                % Stopping criteria
Np          = 10;                     % Number of packs
Nc          = 10;                     % Number of coyotes
[GlobalParams,GlobalMin,ff] = COA(FOBJ, lu, nfevalMAX,Np,Nc); % Start process

% Show results
fprintf(1,'COA''s global optimum: %.4g\n',GlobalMin);
for i=1:D
    fprintf(1,'COA''s global parameters are x(%d): %.4f\n',i,GlobalParams(i));
end
figure
plot(ff)
xlabel('迭代次数')
ylabel('适应度值')
function y = Rastrigin (X)
% Rastrigin's Function
A = 10;
n = length(X);
m = 0;
for i = 1:n
    m = m + X(i)^2 - A*cos(2*pi*X(i));
end
y = 10*n + m;
end

【优化求解】土狼算法matlab源码_第1张图片

完整代码或者代写添加QQ1575304183

你可能感兴趣的:(matlab,优化求解)