• 大小: 5KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-06-03
  • 语言: Matlab
  • 标签: 差分进化  

资源简介

实现了自适应差分进化(SaDE)算法,其中的参数(CR,F)由种群自适应生成,提供了灵活的适宜度函数接口,可供实现复杂的优化问题求解。

资源截图

代码片段和文件信息

function [ besttrmeanttroptindbestvalPopCRtp] = SADE( vminvmaxitermaxNpfitarguin)
%DE Summary of this function goes here
%   Detailed explanation goes here
%% initialization

[ab] = size(vmin);
    if(a>b)
       vmin = vmin‘;
    end
    vmin = repmat(vminNp1);
    vmax = repmat(vmaxNp1);
    besttr = zeros(itermax1);
   meanttr = besttr;
   Pop = vmin +(vmax-vmin).*rand(size(vmin));
   V  = Pop;
    popfit = double (fit(Poparguin));
    [~minInd]  = min(popfit);
    F = zeros(size(Pop1)1);
    M = F;
    p  =0.5;
   CRm  =0.5;
    CR  = 0.5  + 0.1 *randn(size(F)) ;
    ns1 =0;
    ns2=0;
    nf1 = 0;
    nf2 =0;
    CRs =[];
    CRt=[];
    weight = [];
% ssss
 %% iteration
    for t =1:itermax
            %% mutate
                for i  = 1:Np
                    F = 0.5 + 0.3 .*randn(size(F));
                    F(F > 1) =1;
                    F(F<0.1) = 0.1;
                    if(rand < p)
                             % best/2/bin
                              ind = randsample(Np4);
                              V(i:) = Pop(minInd:) + F(i).*(Pop(ind(1):) - Pop(ind(2):)) + F(i).*(Pop(ind(3):) - Pop(ind(4):)) ;
                              M(i)  =1;
                    else
                            %rand/1/bin
                                    ind = randsample(Np3);
                                    V(i:) = Pop(ind(1):) + F(i).*(Pop(ind(2):) - Pop(ind(3):));
                            M(i) =2;
                    end
                   
                end
               %% crossover
             
  
              
                %% copy
                R = rand(size(Pop));
                T = Pop;
                
  
               
            
              
                 
                %% crossover
                R= rand(size(T));
                CRcurr = repmat(CR(:)1size(Pop2));
                T(R        
                T(:end) = V(:end);
                    %% check boundary
                R= rand(size(T));
                if(sum(sum(T0)
                T(T < vmin)   = vmin(T <  vmin) + R(T < vmin) .* (vmax(T < vmin) - vmin(T < vmin) );
                end
                if (sum(sum(T>vmax)) >0)
                T(T > vmax)  =  vmin(T > vmax) + R(T > vma

评论

共有 条评论