2023年最新智能优化算法之——IBI逻辑优化算法(IBL),附MATLAB代码

今天给大家带来一个有意思的智能优化算法,IBL算法。

先说效果:在CEC2005函数集测试,基本上毫无压力,把把都能预测的很准确,而且速度极快。大家可以自行尝试哈。

为啥说这个算法有意思呢,大家看IBL的英文全称是:Incomprehensible but Intelligible-in-time logics,我在这里给大家直译成中文就是:难以理解但又能及时理解的逻辑。可能我翻译的不太准确啊,但是我又结合他的摘要,大概的理解就是:人类的思维不像计算机那样,人类的思维是可以随着时间、事物的变化而变化的,在之前看起来毫无逻辑的事情,在经过人类学习一段时间后,这个事情就会变得很有逻辑了。不得不说老外这个思维是真的奇特哈,根据这个也能提出一个新算法,而且效果还很不错。大家感兴趣的可以去看看原文。

参考文献:

Mirrashid, M.; Naderpour, H. Incomprehensible but Intelligible-in-time logics: Theory and optimization algorithm. Knowl.-Based Syst. 2023, 264, 110305. doi点击链接跳转原文 

废话不多说,依旧是2005函数集的测试,附上2005函数集的理论范围:

2023年最新智能优化算法之——IBI逻辑优化算法(IBL),附MATLAB代码_第1张图片

 大部分优化函数在F8上的表现是不太好的,也就寻优到-4000多,咱们试一下这个IBL:

2023年最新智能优化算法之——IBI逻辑优化算法(IBL),附MATLAB代码_第2张图片

WOW,直接就干到-9700多去了,看样子不错呀,回头了我会将2023年最新的算法做一个对比,决一雌雄一下。

再试一个F14的,理论值是1,能找到0.998004,还阔以

2023年最新智能优化算法之——IBI逻辑优化算法(IBL),附MATLAB代码_第3张图片 

 最后再来一个:

2023年最新智能优化算法之——IBI逻辑优化算法(IBL),附MATLAB代码_第4张图片

上核心代码!

function [Bests_Results,n_it_phase1,n_it_phase2,n_it_phase3,costs1,costs2,costs3] = ILA (CostFunction,Vmin,Vmax,nV,nNL,nModel,nIt,mIt_Phase1,mIt_Phase2,Bmin,Bmax,nRep,nIt_classification)

%% Initialization
Empty.NL = [];                                % Current NL
Empty.NLprevious = [];                        % Previous NL
Empty.Cost = inf;
Empty1.NL = [];                               % Current NL
Empty1.Average = [];                          % Previous NL
Empty1.Cost = inf;
Empty1.Members = [];
Experts = repmat (Empty, nNL, 1);             % Experts
n_it_phase1 = round(nIt*mIt_Phase1);          % Number of iterations in phase 1
n_it_phase2 = round(nIt*mIt_Phase2);          % Number of iterations in phase 2
n_it_phase3 = nIt-n_it_phase1-n_it_phase2;    % Number of iterations in phase 3
costs1 = zeros(n_it_phase1,1);                        % Costs of the phase 1
costs2 = zeros(n_it_phase2,1);                        % Costs of the phase 2
costs3 = zeros(n_it_phase3,1);                        % Costs of the phase 3
n_Groups = zeros(nModel,1);
Em.NL = [];
Em1.NL = [];
Em1.Cost = inf;
Expert_IbI = repmat (Em1, 1, 1);            % The best solution of the current generation
Logic = repmat (Em1, 1, 1);                 % The best solution before the current generation
Expert_new = repmat (Em1, 1, 1);
K0 = repmat (Em, nNL, 1);                   % Knowledge 0
K1 = repmat (Em, nNL, 1);                   % Knowledge 1
Expert_new.NL = [];
Expert_new.Cost = inf;
Knowledge_Phase1 = K0;
Knowledge_Phase2 = K0;
Knowledge_Phase3 = K0;
GroupNumber = ones(nNL,1);
Em2.NL = [];
Em2.Cost = inf;
Bests_Results = repmat (Em2, nIt, 1);

if length(Vmin) ~= (nV)
    Vmin=Vmin.*ones(1,nV);
    Vmax=Vmax.*ones(1,nV);
end

for i = 1:nNL
    Experts(i).NL = unifrnd(Vmin,Vmax,1,nV);
    Experts(i).NLprevious = unifrnd(Vmin,Vmax,1,nV);
    Experts(i).Cost = CostFunction(Experts(i).NL);
end

% Extract the Logic (Best NL in the previous solutions)
for i = 1:nNL
    if CostFunction(Experts(i).NLprevious) <= Logic.Cost
        Logic.Cost = CostFunction(Experts(i).NLprevious); % The best solution of before the current generation
        Logic.NL = Experts(i).NLprevious;
    end
    if Experts(i).Cost <= Expert_IbI.Cost
        Expert_IbI.Cost = Experts(i).Cost;    % The best solution of the current generation
        Expert_IbI.NL = Experts(i).NL;
    end
end

n_t = zeros(nModel,1);
nt = round((n_it_phase1)/nModel);
for m = 1:nModel
    n_t(m,1) = nt;
end
n_t(nModel,1) = (n_it_phase1)-(nModel-1)*nt;

for m = 1:nModel
    n_Groups(m,1) = randi(round(nNL/2));     % Number of workgropus in each model
end

%% Phase 0: Grouping (Clustering)

for m = 1:nModel
    
    % Clustering
    MAT = zeros(nNL,nV);
    for i = 1:nNL
        MAT(i,:) = Experts(i).NL;
    end
    opts = statset('MaxIter',nIt_classification);
    lastwarn('Success');
    GroupNumber0 = GroupNumber;
    GroupNumber = kmeans(MAT,n_Groups(m,1),'Distance','sqeuclidean','Replicates',nRep,'Options',opts);
    [warningMessage, warningMessageID] = lastwarn;
    if contains(warningMessage, 'Failed to converge')
        warnStruct = warning('off');
        GroupNumber = GroupNumber0;
        if m ==1
            n_Groups(m,1) = 1;
        else
            n_Groups(m,1) = n_Groups(m-1,1);
        end
    end
    Experts_Groups = repmat (Empty1, n_Groups(m,1),1);
    n_members = zeros(n_Groups(m,1),1);
    
    for c = 1:n_Groups(m,1)
        nn=0;
        for i = 1:nNL
            if GroupNumber(i,1) == c
                nn = nn+1;
            end
        end
        n_members(c,1) = nn;
        Experts_Groups(c).Members = repmat (Em, n_members(c,1), 1);
    end
    
    %% Phase 1: Workgropus
    for it_phase1 = 1:n_t(m,1)
        
        for c = 1:n_Groups(m,1)
            SUM = 0;
            num = 0;
            for i = 1:nNL
                if GroupNumber(i,1) == c
                    num = num+1;
                    SUM = Experts(i).NL + SUM;
                    Experts_Groups(c).Members(num).NL = Experts(i).NL;
                    if Experts(i).Cost <= Experts_Groups(c).Cost
                        Experts_Groups(c).NL = Experts(i).NL;
                        Experts_Groups(c).Cost = Experts(i).Cost;
                    end
                end
            end
            Experts_Groups(c).Average = SUM./n_members(c,1);
        end
        
        % Calculate the ratios
        D = zeros(nNL,1);
        P = zeros(nNL,1);
        C = zeros(nNL,1);
        for i = 1:nNL
            C(i,1) = sqrt(sum((Experts(i).NL-Logic.NL).^2));
            D(i,1) = sqrt(sum((Experts(i).NL-Experts(i).NLprevious).^2));
            P(i,1) = sqrt(sum((Experts(i).NL-Experts_Groups(GroupNumber(i,1)).NL).^2));
        end
        min_D = min(D); max_D = max(D);
        min_P = min(P); max_P = max(P);
        min_C = min(C); max_C = max(C);
        
        Rc = (C-min_C)./(max_C-min_C);
        Rp = (P-min_P)./(max_P-min_P);
        RD = (D-min_D)./(max_D-min_D);
        Bc = Bmin + (Bmax-Bmin)*rand();
        Bp = Bmin + (Bmax-Bmin)*rand();
        BD = Bmin + (Bmax-Bmin)*rand();
        
        for i = 1:nNL
            B = Bmin + (Bmax-Bmin)*rand();
            if (Rc(i,1) <= Bc) && (Rp(i,1) <= Bp)
                random_member = randi (n_members(GroupNumber(i,1),1));
                K0(i).NL = Rp(i,1).*(Experts(i).NL + Experts_Groups(GroupNumber(i,1)).Members(random_member).NL)./2;
            elseif (Rc(i,1) <= Bc) && (Rp(i,1) > Bp)
                K0(i).NL = Rp(i,1).*(Experts(i).NL + Experts_Groups(GroupNumber(i,1)).Average)./2;
            elseif (Rc(i,1) > Bc) && (Rp(i,1) <= Bp)
                random_member = randi (n_members(GroupNumber(i,1),1));
                K0(i).NL = Rp(i,1).*(Experts_Groups(GroupNumber(i,1)).NL + Experts_Groups(GroupNumber(i,1)).Members(random_member).NL)./2;
            elseif (Rc(i,1) > Bc) && (Rp(i,1) > Bp)
                K0(i).NL = Rp(i,1).*(Experts_Groups(GroupNumber(i,1)).NL + Experts_Groups(GroupNumber(i,1)).Average)./2;
            end
            
            if RD(i,1)<= BD
                K1(i).NL = (rand()).*(Experts_Groups(GroupNumber(i,1)).Average);
            else
                K1(i).NL = (rand()).*(unifrnd(Vmin,Vmax,1,nV));
            end
            
            Knowledge_Phase1(i).NL = abs(K0(i).NL + K1(i).NL)./2;
            
            % Update the NL
            alpha1 = -1.5+3.*rand(1,nV);
            Expert_new.NL = Experts(i).NL + alpha1.*(Knowledge_Phase1(i).NL);
            Expert_new.NL = max(Expert_new.NL, Vmin);
            Expert_new.NL = min(Expert_new.NL, Vmax);
            E1 = Experts(i).NL;
            Expert_new.Cost = CostFunction(Expert_new.NL);
            
            COEF = -1.5+3*rand();
            K = rand().*Experts_Groups(GroupNumber(i,1)).NL;
            NEW.NL = COEF.*(Expert_new.NL) + K;
            NEW.NL = max(NEW.NL, Vmin);
            NEW.NL = min(NEW.NL, Vmax);
            NEW.Cost = CostFunction(NEW.NL);
            if NEW.Cost < Expert_new.Cost
                Expert_new = NEW;
            end
            
            
            if Expert_new.Cost < Experts(i).Cost
                Experts(i).NL = Expert_new.NL;
                Experts(i).Cost = Expert_new.Cost;
            end
            if Experts(i).NL ~= E1
                Experts(i).NLprevious = E1;
            end
            E1 = Expert_IbI.NL;
            if Experts(i).Cost < Expert_IbI.Cost
                Expert_IbI.Cost = Experts(i).Cost;
                Expert_IbI.NL = Experts(i).NL;
            end
            if Expert_IbI.NL ~= E1
                Logic.NL = E1;
            end
        end
        
        costs1((m-1)*(n_t(1,1))+it_phase1,1) = Expert_IbI.Cost;
        Bests_Results((m-1)*(n_t(1,1))+it_phase1).NL = Expert_IbI.NL;
        Bests_Results((m-1)*(n_t(1,1))+it_phase1).Cost = Expert_IbI.Cost;
        
    end
end
NUM = n_it_phase1;
for it_phase2 = 1:n_it_phase2
NUM = NUM+1;    
    % Calculate the ratios
    for i = 1:nNL
        C(i,1) = sqrt(sum((Experts(i).NL-Logic.NL).^2));
        D(i,1) = sqrt(sum((Experts(i).NL-Experts(i).NLprevious).^2));
        P(i,1) = sqrt(sum((Experts(i).NL-Expert_IbI.NL).^2));
    end
    min_D = min(D); max_D = max(D);
    min_P = min(P); max_P = max(P);
    min_C = min(C); max_C = max(C);
    
    Rc = (C-min_C)./(max_C-min_C);
    Rp = (P-min_P)./(max_P-min_P);
    RD = (D-min_D)./(max_D-min_D);
    Bc = Bmin + (Bmax-Bmin)*rand();
    Bp = Bmin + (Bmax-Bmin)*rand();
    BD = Bmin + (Bmax-Bmin)*rand();
    
    for i = 1:nNL
        B = Bmin + (Bmax-Bmin)*rand();
        if (Rc(i,1) <= Bc) && (Rp(i,1) <= Bp)
            random_member = randi (nNL);
            K0(i).NL = Rp(i,1).*(Experts(i).NL + Experts(random_member).NL)./2;
        elseif (Rc(i,1) <= Bc) && (Rp(i,1) > Bp)
            SUM = 0;
            for ii = 1:nNL
                SUM = Experts(ii).NL + SUM;
            end
            Average = SUM./nNL;
            K0(i).NL = Rp(i,1).*(Experts(i).NL + Average)./2;
        elseif (Rc(i,1) > Bc) && (Rp(i,1) <= Bp)
            random_member = randi (nNL);
            K0(i).NL = Rp(i,1).*(Expert_IbI.NL + Experts(random_member).NL)./2;
        elseif (Rc(i,1) > Bc) && (Rp(i,1) > Bp)
            SUM = 0;
            for ii = 1:nNL
                SUM = Experts(ii).NL + SUM;
            end
            Average = SUM./nNL;
            K0(i).NL = Rp(i,1).*(Expert_IbI.NL + Average)./2;
        end
        
        if RD(i,1)<= BD
            SUM = 0;
            for ii = 1:nNL
                SUM = Experts(ii).NL + SUM;
            end
            Average = SUM./nNL;
            K1(i).NL = (rand()).*(Average);
        else
            K1(i).NL = (rand()).*(unifrnd(Vmin,Vmax,1,nV));
        end
        
        % Update the NL
        Knowledge_Phase2(i).NL = abs(K0(i).NL + K1(i).NL)./2;
        alpha2 = -0.75+1.5.*rand(1,nV);
        Expert_new.NL = Experts(i).NL + alpha2.*(Knowledge_Phase2(i).NL);
        Expert_new.NL = max(Expert_new.NL, Vmin);
        Expert_new.NL = min(Expert_new.NL, Vmax);
        E1 = Experts(i).NL;
        Expert_new.Cost = CostFunction(Expert_new.NL);
        
        COEF = -0.75+1.5*rand();
        K = rand().*(Expert_IbI.NL);
        NEW.NL = COEF.*(Expert_new.NL) + K;
        NEW.NL = max(NEW.NL, Vmin);
        NEW.NL = min(NEW.NL, Vmax);
        NEW.Cost = CostFunction(NEW.NL);
        
        if NEW.Cost < Expert_new.Cost
            Expert_new = NEW;
        end
        
        if Expert_new.Cost < Experts(i).Cost
            Experts(i).NL = Expert_new.NL;
            Experts(i).Cost = Expert_new.Cost;
        end
        if Experts(i).NL ~= E1
            Experts(i).NLprevious = E1;
        end
        E1 = Expert_IbI.NL;
        if Experts(i).Cost < Expert_IbI.Cost
            Expert_IbI.Cost = Experts(i).Cost;
            Expert_IbI.NL = Experts(i).NL;
        end
        if Expert_IbI.NL ~= E1
            Logic.NL = E1;
        end
    end
    
    costs2(it_phase2,1) = Expert_IbI.Cost;
    Bests_Results(NUM).NL = Expert_IbI.NL;
    Bests_Results(NUM).Cost = Expert_IbI.Cost;
end

%% Phase 3: IbI Logic Search

for it_phase3 = 1:n_it_phase3
NUM = NUM+1;    
    for i = 1:nNL
        SUM = 0;
        for ii = 1:nNL
            SUM = SUM + Experts(ii).NL;
        end
        Average = SUM./nNL;
        
        factor = randi(2);
        if factor == 1
            Knowledge_Phase3(i).NL = abs(Average - Experts(randi(nNL)).NL);
        else
            Knowledge_Phase3(i).NL = abs(Average - Expert_IbI.NL);
        end
        alpha3 = -0.25+0.5.*rand(1,nV);
        Expert_new.NL = Experts(i).NL + alpha3.*(Knowledge_Phase3(i).NL);
        
        Expert_new.NL = max(Expert_new.NL, Vmin);
        Expert_new.NL = min(Expert_new.NL, Vmax);
        Expert_new.Cost = CostFunction(Expert_new.NL);
        
        COEF = -0.25+0.5*rand();
        K = rand().*(Expert_IbI.NL);
        NEW.NL = COEF.*(Expert_new.NL) + K;
        NEW.NL = max(NEW.NL, Vmin);
        NEW.NL = min(NEW.NL, Vmax);
        NEW.Cost = CostFunction(NEW.NL);
        if NEW.Cost < Expert_new.Cost
            Expert_new = NEW;
        end
        
        if Expert_new.Cost < Experts(i).Cost
            Experts(i).NL = Expert_new.NL;
            Experts(i).Cost = Expert_new.Cost;
        end
        if Experts(i).Cost < Expert_IbI.Cost
            Expert_IbI.Cost = Experts(i).Cost;
            Expert_IbI.NL = Experts(i).NL;
        end
    end
    costs3(it_phase3,1) = Expert_IbI.Cost;
    Bests_Results(NUM).NL = Expert_IbI.NL;
    Bests_Results(NUM).Cost = Expert_IbI.Cost;
end

%% Extract the results
Expert_IbI.Cost = CostFunction(Expert_IbI.NL);

end

 下方小卡片回复关键词:2023,免费获取2023年智能优化算法合集matlab代码。

后续会继续发布2023年其他最新优化算法,敬请关注。

你可能感兴趣的:(智能优化算法,matlab,2023年最新智能优化算法,优化算法,IBI逻辑优化算法,IBL)