受精优化算法(Fertilization Optimization algorithm, FO)

受精优化算法(Fertilization Optimization algorithm, FO)

基本原理:受精优化算法(Fertilization Optimization algorithm,FO)是一种受哺乳动物繁殖过程中卵子受精启发的生物学算法,用以解决现实世界中的复杂优化问题。
参考文献:Fertilization optimization algorithm on CEC2015 and large-scale problems.
该博客主要分享FO算法的代码,并带有中文注释!
分享不易,喜欢的请大家点赞加收藏,谢谢!
FO算法主程序如下:

% Fertilization optimization algorithm(FO)
% Reference:Fertilization optimization algorithm on CEC2015 and large scale problems
% Code by Luzhenhui Yangtze University
clc
clear
%% 优化问题定义(测试函数)
CostFunction = @(x) Sphere(x);  % 目标方程
nVar = 25;                      % 变量数目
v_size = [1 nVar];              % 变量矩阵大小
v_min = -10;                    % 变量取值下界
v_max = 10;                     % 变量取值上界
%% 算法参数
nPop = 50;                      % 算法种群个体数目
MaxIt = 1000;                   % 算法最大迭代次数
%% 算法初始化
empty_sperm.Position = [];
empty_sperm.velocity = [];
empty_sperm.Cost = [];
sperm = repmat(empty_sperm, nPop, 1);    
for i = 1:nPop    
    % 种群个体位置信息的初始化
    sperm(i).Position = unifrnd(v_min, v_max, v_size); 
    sperm(i).velocity = sperm(i).Position;
    % 种群个体所对应的适应度值
    sperm(i).Cost = CostFunction(sperm(i).Position);    
end
bestfits = zeros(MaxIt, 1);      % 用于记录每次迭代的最优值 
%% 算法的主要流程
x=1;
d=0.95;
for it=1:MaxIt
     newsperm = [];    
        for i = 1:nPop
           K= (sperm(1).Position+sperm(round(nPop/2)).Position+sperm(end).Position)/3;           
            newsol = empty_sperm;
            L = Levy(nVar);  
            newsol.velocity =  exp(-1/x)*sperm(i).velocity; 
            ds=L.*(sperm(i).Position-sperm(i).velocity);             
            newsol.Position = sperm(i).Position - newsol.velocity+ds-K;           
       
            newsol.Position = max(newsol.Position, v_min);
            newsol.Position = min(newsol.Position, v_max);                
            newsol.Cost = CostFunction(newsol.Position);        
            newsperm = [newsperm
                      newsol];                         
        end
    sperm = [sperm
           newsperm ];    
    [~, SortOrder]=sort([sperm.Cost]);
    sperm = sperm(SortOrder);
    if numel(sperm)>nPop
        sperm = sperm(1:nPop);
    end    
    BestSol = sperm(1);    
    bestfits(it) = BestSol.Cost;
    x=x*d;
disp(['It ' num2str(it) ': Best Cost = ' num2str(bestfits(it))]);
end
figure;
semilogy(bestfits,'LineWidth',3);
xlabel('Iteration');
ylabel('Best Cost');
grid on;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值