当前位置: 首页 > article >正文

2025年SCI一区智能优化算法:真菌生长优化算法(Fungal Growth Optimizer,FGO),提供MATLAB代码

一. 真菌生长优化算法(FGO)

真菌生长优化算法(Fungal Growth Optimizer,FGO)是一种新型的自然启发式元启发式算法,其灵感来源于自然界中真菌的生长行为。该算法通过模拟真菌的菌丝尖端生长、分支和孢子萌发等行为,提供了一系列的探索和开发操作符,以解决复杂的优化问题。FGO算法在多个领域展现出了良好的性能,尤其是在解决高维问题和避免陷入局部最优方面具有显著优势。
在这里插入图片描述

1、算法原理

FGO算法的核心在于模拟真菌的三种主要生长行为:菌丝尖端生长、分支和孢子萌发。这些行为在算法中分别对应不同的搜索策略,以实现对解空间的有效探索和开发。

  1. 菌丝尖端生长(Hyphal Tip Growth)
    菌丝尖端生长是真菌寻找营养物质的主要方式。在FGO算法中,这一行为通过模拟菌丝在搜索空间中的线性生长来实现。菌丝会根据环境中的营养浓度调整其生长方向,以找到营养丰富的区域。这种行为在算法中提供了主要的探索能力,帮助算法在解空间中广泛搜索。

  2. 分支(Branching)
    分支行为允许真菌从现有的菌丝侧枝上生长出新的菌丝,以进一步探索周围的环境。在FGO算法中,分支行为通过在现有解的基础上生成新的解来实现,从而增强了算法的探索能力。这种机制有助于算法在解空间中发现更多的潜在最优解。

  3. 孢子萌发(Spore Germination)
    孢子萌发是真菌繁殖的重要方式。在FGO算法中,孢子萌发行为通过在搜索空间中随机生成新的解来实现。这些新的解在算法的早期阶段具有较高的随机性,随着算法的进行,它们的位置会逐渐调整到更接近当前最优解的区域。这种机制有助于算法在保持种群多样性的同时,逐步收敛到最优解。

2、算法流程

输入:种群规模 N N N,最大迭代次数 t max ⁡ t_{\max} tmax,随机数 r 0 , r 10 , r 2 , r 8 r_0, r_{10}, r_2, r_8 r0,r10,r2,r8,以及其他相关参数。

输出:最优解 S ∗ S^* S

  1. 初始化

    • 使用公式 (1) 初始化 N N N 个菌丝个体 S i t S_i^t Sit
    • 评估每个 S i t S_i^t Sit 的适应度值,并确定适应度值最高的个体作为当前最优解 S ∗ S^* S
    • 设置迭代计数器 t = 1 t = 1 t=1
  2. 迭代过程

    • t < t max ⁡ t < t_{\max} t<tmax 时,执行以下步骤:
      • 生成两个随机数 r 0 r_0 r0 r 10 r_{10} r10,取值范围为 [0, 1]。
      • 如果 r 0 < r 10 r_0 < r_{10} r0<r10,执行菌丝尖端生长行为:
        • 对于每个菌丝个体 i = 1 i = 1 i=1 N N N
          • 根据公式 (24) 和 (23) 计算能量 E i E_i Ei 和概率 p i p_i pi
          • 如果 p i < E i p_i < E_i pi<Ei(探索阶段 I):
            • 使用公式 (8) 更新 S i t + 1 S_i^{t+1} Sit+1
          • 否则(开发阶段 I):
            • 使用公式 (22) 更新 S i t + 1 S_i^{t+1} Sit+1
          • 如果新解 S i t + 1 S_i^{t+1} Sit+1 的适应度值小于当前解 S i t S_i^t Sit 的适应度值:
            • 更新当前解 S i t = S i t + 1 S_i^t = S_i^{t+1} Sit=Sit+1
        • 迭代计数器加 1, t = t + 1 t = t + 1 t=t+1
      • 否则,执行菌丝分支和孢子萌发行为:
        • 对于每个菌丝个体 i = 1 i = 1 i=1 N N N
          • 生成两个随机数 r 2 r_2 r2 r 8 r_8 r8,取值范围为 [0, 1]。
          • 如果 r 2 < 0.5 r_2 < 0.5 r2<0.5(菌丝分支):
            • 使用公式 (30) 更新 S i t + 1 S_i^{t+1} Sit+1
          • 否则(孢子萌发):
            • 使用公式 (31) 更新 S i t + 1 S_i^{t+1} Sit+1
          • 如果新解 S i t + 1 S_i^{t+1} Sit+1 的适应度值小于当前解 S i t S_i^t Sit 的适应度值:
            • 更新当前解 S i t = S i t + 1 S_i^t = S_i^{t+1} Sit=Sit+1
        • 迭代计数器加 1, t = t + 1 t = t + 1 t=t+1
  3. 结束条件

    • 当迭代次数 t t t 达到最大迭代次数 t max ⁡ t_{\max} tmax 时,算法结束。
    • 输出最优解 S ∗ S^* S

3、 详细步骤说明

  1. 初始化

    • 随机生成 N N N 个初始菌丝个体,每个个体代表一个潜在的解。
    • 评估每个个体的适应度值,找到当前最优解 S ∗ S^* S
  2. 菌丝尖端生长行为

    • 通过比较随机数 r 0 r_0 r0 r 10 r_{10} r10,决定是否执行菌丝尖端生长行为。
    • 对于每个菌丝个体,计算其能量 E i E_i Ei 和概率 p i p_i pi
    • 根据 p i p_i pi E i E_i Ei 的关系,决定是进行探索阶段 I 还是开发阶段 I。
    • 使用相应的公式更新菌丝个体的位置。
    • 如果新位置的适应度值更好,则接受新位置。
  3. 菌丝分支和孢子萌发行为

    • 如果不执行菌丝尖端生长行为,则执行菌丝分支和孢子萌发行为。
    • 对于每个菌丝个体,生成随机数 r 2 r_2 r2 r 8 r_8 r8
    • 根据 r 2 r_2 r2 的值,决定是进行菌丝分支还是孢子萌发。
    • 使用相应的公式更新菌丝个体的位置。
    • 如果新位置的适应度值更好,则接受新位置。
  4. 迭代更新

    • 每次更新后,检查是否满足终止条件(达到最大迭代次数)。
    • 如果满足条件,则输出最优解;否则,继续下一次迭代。
      参考文献:
      [1]Abdel-Basset M, Mohamed R, Abouhawwash M. Fungal growth optimizer: A novel nature-inspired metaheuristic algorithm for stochastic optimization[J]. Computer Methods in Applied Mechanics and Engineering, 2025, 437: 117825.

二、核心MATLAB代码

% The Fungal Growth Optimizer
function [Gb_Fit,Gb_Sol,Conv_curve]=FGO(N,Tmax,ub,lb,dim,Fun_No,fhd)
%%%%-------------------Definitions--------------------------%%
%%
Gb_Sol=zeros(1,dim); % A vector to include the best-so-far solution
Gb_Fit=inf; % A Scalar variable to include the best-so-far score
Conv_curve=zeros(1,Tmax);
%%-------------------Controlling parameters--------------------------%%
%%
M=0.6; %% Determines the tradeoff percent between exploration and exploitation operators.
Ep=0.7; %% Determines the probability of environmental effect on hyphal growth
R=0.9; %% Determines the speed of convergence to the best-so-far solution
%%---------------Initialization----------------------%%
%%
S=initialization(N,dim,ub,lb); % Initialize the S of crested porcupines
t=0; %% Function evaluation counter
%%---------------------Evaluation-----------------------%%
for i=1:N
    %% Test suites of CEC-2014, CEC-2017, CEC-2020, and CEC-2022
    fit(i)=feval(fhd, S(i,:)',Fun_No);
end
% Update the best-so-far solution
[Gb_Fit,index]=min(fit);
Gb_Sol=S(index,:);
%% A new vector to store the best-so-far position for each hyphae
Sp=S;
opt=Fun_No*100; %% Best-known fitness
%%  Optimization Process of FGO
while t<Tmax && opt~=Gb_Fit
    %% ----------------------------------------------------------------------------- %%
    if t <= Tmax/2 %% Compute the the nutrient allocation according to (12)
        nutrients = rand(N); % Allocate more randomly to encourage fluctuation exploitation
    else
        nutrients = fit;  % Exploitation phase: allocate based on fitness
    end
    nutrients = nutrients / sum(nutrients)+2*rand; % Normalize nutrient allocation according to (13)
    %% ----------------------------------------------------------------------------- %%
    if rand<rand %% Hyphal tip growth behavior %%
        for i=1:N
            a=randi(N);
            b=randi(N);
            c=randi(N);
            while a==i | a==b | c==b | c==a ||c==i |b==i
                a=randi(N);
                b=randi(N);
                c=randi(N);
            end
            p=(fit(i)-min(fit))/(max(fit)-min(fit)+eps); %%% Compute p_i according to (23)
            Er=M+(1-t/(Tmax)).*(1-M); %%% Compute Er according to (24)
            if p<Er
                F=(fit(i)/(sum(fit))).*rand*(1-t/(Tmax))^(1-t/(Tmax)); %% Calculate F according to (5) and (6)
                E=exp(F);  %% Calculate E according to (4)
                r1=rand(1,dim);
                r2=rand;
                U1=r1<r2; %% Binary vector
                S(i,:) = (U1).*S(i,:)+(1-U1).*(S(i,:)+E.*(S(a,:)-S(b,:))); %% Generate the new hyphal growth according to (9)
            else
                Ec = (rand(1, dim) - 0.5) .* rand.*(S(a,:)-S(b,:)); % Compute the additional exploratory step using (17)
                if rand<rand %% Hypha growing in the opposite direction of nutrient-rich areas %
                    De2 = rand(1,dim).* (S(i,:) - Gb_Sol).*(rand(1,dim)>rand); %% Compute De2 according to (16) %%
                    S(i,:) = S(i,:) + De2 .* nutrients(i)+Ec*(rand>rand); %% Compute the new growth for the ith hyphal using (15)
                else %% Growth direction toward nutrient-rich area
                    De = rand.* (S(a, :) - S(i, :)) + rand(1,dim).* ((rand>rand*2-1).*Gb_Sol - S(i, :)).*(rand()>R); %% Compute De according to (11) %%
                    S(i,:) = S(i,:) + De .* nutrients(i)+Ec*(rand>Ep); %% Compute the new growth for the ith hyphal using (14)
                end
            end
            %% Return the search agents that exceed the search space's bounds
            for j=1:size(S,2)
                if  S(i,j)>ub(j)
                    S(i,j)=lb(j)+rand*(ub(j)-lb(j));
                elseif  S(i,j)<lb(j)
                    S(i,j)=lb(j)+rand*(ub(j)-lb(j));
                end
                
            end
            % Calculate the fitness value of the newly generated solution
            nF=feval(fhd, S(i,:)',Fun_No);
            %% update Global & Local best solution
            if  fit(i)<nF
                S(i,:)=Sp(i,:);    % Update local best solution
            else
                Sp(i,:)=S(i,:);
                fit(i)=nF;
                %% update Global best solution
                if  fit(i)<=Gb_Fit
                    Gb_Sol=S(i,:);    % Update global best solution
                    Gb_Fit=fit(i);
                end
            end
            t=t+1; % Move to the next generation
            if t>Tmax
                break
            end
            Conv_curve(t)=Gb_Fit;
        end
        if  t>Tmax
            break;
        end
    else
        r5=rand;
        for i=1:N
            rr=rand(1,dim);
            a=randi(N);
            b=randi(N);
            c=randi(N);
            while a==i | a==b | c==b | c==a ||c==i |b==i
                a=randi(N);
                b=randi(N);
                c=randi(N);
            end
            if rand<0.5 %% Hyphal branching
                EL=1+exp(fit(i)/(sum(fit)))*(rand>rand); %% Compute the growth rate of the hypha produced via lateral branching using (29)
                Dep1=(S(b,:)-S(c,:)); %% Compute Dep1 using (26)
                Dep2=(S(a,:)-Gb_Sol); %% Compute Dep1 using (27)
                r1=rand(1,dim);
                r2=rand;
                U1=r1<r2; %% Binary vector
                S(i,:)= S(i,:).*U1+(S(i,:)+ r5.*Dep1.*EL+ (1-r5).*Dep2.*EL).*(1-U1); % Generate the new branch for the ith hyphal using (30)
            else %% Spore germination
                sig=(rand>rand*2-1); %% 1 or -1
                F=(fit(i)/(sum(fit))).*rand*(1-t/(Tmax))^(1-t/(Tmax)); %% Calculate F according to (5) and (6)
                E=exp(F);  %% Calculate E according to (4)
                for j=1:size(S,2)
                    mu=sig.*rand.*E;
                    if rand>rand
                        S(i,j)=(((t/(Tmax))*Gb_Sol(j)+(1-t/(Tmax))*S(a,j))+S(b,j))/2.0 + mu * abs((S(c,j)+S(a,j)+S(b,j))/3.0-S(i,j));      % Eq. (31)
                    end
                end
            end
            %% Return the search agents that exceed the search space's bounds
            for j=1:size(S,2)
                if  S(i,j)>ub(j)
                    S(i,j)=lb(j)+rand*(ub(j)-lb(j));
                elseif  S(i,j)<lb(j)
                    S(i,j)=lb(j)+rand*(ub(j)-lb(j));
                end
                
            end
            % Calculate the fitness value of the newly generated solution
            nF=feval(fhd, S(i,:)',Fun_No);
            %% update Global & Local best solution
            if  fit(i)<nF
                S(i,:)=Sp(i,:);    % Update local best solution
            else
                Sp(i,:)=S(i,:);
                fit(i)=nF;
                %% update Global best solution
                if  fit(i)<=Gb_Fit
                    Gb_Sol=S(i,:);    % Update global best solution
                    Gb_Fit=fit(i);
                end
            end
            t=t+1; % Move to the next generation
            if t>Tmax
                break
            end
            Conv_curve(t)=Gb_Fit;
        end %% End for i
    end %% End If
    if  t>Tmax
        break;
    end
end%% End while
end
%_________________________________________________________________________%
%  Fungal Growth Optimizer source code demo 1.0               %
%  Developed in MATLAB R2019A                                      %
%                                                                         %
%                                                                         %
%   Main paper: Fungal Growth Optimizer: A Novel Nature-inspired Metaheuristic Algorithm for Stochastic Optimization                       %
%                  %
%                                                                         %
%_________________________________________________________________________%
% This function initialize the first population of search agents
function Positions=initialization(SearchAgents_no,dim,ub,lb)
Boundary_no= length(ub); % numnber of boundaries
% If the boundaries of all variables are equal and user enter a signle
% number for both ub and lb
if Boundary_no==1
     Positions=rand(SearchAgents_no,dim).*(ub-lb)+lb;
end
% If each variable has a different lb and ub
if Boundary_no>1
    for i=1:dim
        ub_i=ub(i);
        lb_i=lb(i);
        Positions(:,i)=rand(SearchAgents_no,1).*(ub_i-lb_i)+lb_i;      
    end
end

http://www.kler.cn/a/563688.html

相关文章:

  • SQL获取数据库中包含某个字段的表
  • Java注解的原理
  • Deepseek开源周,第二天:Deep EP
  • C++ gtest框架
  • 【react】TypeScript在react中的使用
  • kafka的ACL配置的sasl.kerberos.principal.to.local.rules配置解释
  • 简单易懂,解析Go语言中的struct结构体
  • Spring 源码硬核解析系列专题(五):Spring Boot 自动装配的原理
  • Fiddler在Windows下抓包Https
  • 支持自动化数据回放
  • spirng相关面试题
  • 云原生(五十七) | 阿里云CDN基本概念
  • 力扣LeetCode:1472 设计浏览器历史记录
  • Ubuntu 下 nginx-1.24.0 源码分析 - pool->cleanup
  • Graph and GNN——图的表示与图神经网络的介绍与应用
  • 青少年编程与数学 02-010 C++程序设计基础 11课题、程序结构
  • 手机放兜里,支付宝“碰一下”被盗刷?
  • Selenium八大元素定位方式
  • Docker 基本概念[SpringBoot之Docker实战系列] - 第536篇
  • 机试刷题_NC52 有效括号序列【python】