MATLAB アルゴリズムの実際の適用事例を徹底解説 - [最適化アルゴリズム] ハイブリッド リーダーシップ最適化アルゴリズム (HLBO) (MATLAB と Python コードの実装付き)

コード

MATLAB

HLBO.m


function[Best_score,Best_pos,HLBO_curve]=HLBO(SearchAgents,Max_iterations,lowerbound,upperbound,dimension,fitness)

lowerbound=ones(1,dimension).*(lowerbound);                              % Lower limit for variables
upperbound=ones(1,dimension).*(upperbound);                              % Upper limit for variables

%%
for i=1:dimension
    X(:,i) = lowerbound(i)+rand(SearchAgents,1).*(upperbound(i) - lowerbound(i));                   % Initial population
end

for i =1:SearchAgents
    L=X(i,:);
    fit(i)=fitness(L);
end
%%

for t=1:Max_iterations
    %% update the best member
    [best , blocation]=min(fit);
    [fworst , ~]=max(fit);

    %% Phase 1: Exploration phase
    % candidate solution
    for i=1:SearchAgents
    Q(i,:)=fit-fworst/fit(i)-fworst;              %eqn(4)
    end

    if t==1
        Xbest=X(blocation,:);                       

おすすめ

転載: blog.csdn.net/qq_36130719/article/details/133355002