基于非线性权重因子和纵横交叉策略的麻雀搜索算法

 目录

1 主要内容

非惯性权重模型

纵横交叉策略模型

2 部分程序

3 程序结果

4 程序链接


主要内容

该程序参考文献《基于Sobol序列和纵横交叉策略的麻雀搜索算法》对麻雀搜索算法进行改进,实现了基于纵横交叉策略和非线性权重因子的麻雀搜索算法 改进SSA算法【matlab代码】,主要改进如下:

- 改进1:采用一种指数形式的非线性惯性权重提高算法的收敛效率。

- 改进2:应用纵横交叉策略对算法进行改进,利用横向交叉增强全局搜索能力,利用纵向交叉保持种群的多样性并防止算法陷入局部最优。

  • 非惯性权重模型

  • 纵横交叉策略模型

部分程序

  % 改进1:★★非线性惯性权重★★
    w = exp(1-(M+t)/(M-t));
    x( sortIndex( i ), : ) = pX( sortIndex( i ), : ) * w; 
    x( sortIndex( i ), : ) = Bounds( x( sortIndex( i ), : ), lb, ub );
    fit( sortIndex( i ) ) = fobj( x( sortIndex( i ), : ) );   
  end
else
  for i = 1 : pNum          
    x( sortIndex( i ), : ) = pX( sortIndex( i ), : )+randn(1)*ones(1,dim);
    x( sortIndex( i ), : ) = Bounds( x( sortIndex( i ), : ), lb, ub );
    fit( sortIndex( i ) ) = fobj( x( sortIndex( i ), : ) );      
  end  
end
 
[~, bestII] = min(fit);      
bestXX = x(bestII,:);            
​
%% 跟随者位置更新
for i = ( pNum + 1 ) : pop                     % Equation (4)
​
  A=floor(rand(1,dim)*2)*2-1;
  if( i>(pop/2))
    x( sortIndex(i ), : )=randn(1)*exp((worse-pX( sortIndex( i ), : ))/(i)^2);
  else
    x( sortIndex( i ), : )=bestXX+(abs(( pX( sortIndex( i ), : )-bestXX)))*(A'*(A*A')^(-1))*ones(1,dim);  
  end  
  
  x( sortIndex( i ), : ) = Bounds( x( sortIndex( i ), : ), lb, ub );
  fit( sortIndex( i ) ) = fobj( x( sortIndex( i ), : ) );
  
end
​
c=randperm(numel(sortIndex));
b=sortIndex(c(1:20)); 
%% 警戒者位置更新
​
for j =  1  : length(b)      % Equation (5)
  % 改进2.1:★★横向交叉策略★★
  if (mod(j,2) == 1)
      for i = 1 : dim
          r = rand();
          c = 2*rand()-1;
          x_criss( sortIndex( b(j) ), i ) = r * pX( sortIndex( b(j) ), i )+(1-r)*pX( sortIndex( b(j+1) ), i )+c*(pX( sortIndex( b(j) ), i )-pX( sortIndex( b(j+1) ), i ));
      end
  else
      for i = 1 : dim
          r = rand();
          c = 2*rand()-1;
          x_criss( sortIndex( b(j) ), i ) = r * pX( sortIndex( b(j-1) ), i )+(1-r)*pX( sortIndex( b(j) ), i )+c*(pX( sortIndex( b(j-1) ), i )-pX( sortIndex( b(j) ), i ));
      end
  end
  
  if fobj( x_criss( sortIndex( b(j) ), : ) ) < fobj( pX( sortIndex( b(j) ), : ) )
      x( sortIndex( b(j) ), : ) = x_criss( sortIndex( b(j) ), : );
  else
      x( sortIndex( b(j) ), : ) = pX( sortIndex( b(j) ), : );
  end
  
  x( sortIndex(b(j) ), : ) = Bounds( x( sortIndex(b(j) ), : ), lb, ub );
  fit( sortIndex( b(j) ) ) = fobj( x( sortIndex( b(j) ), : ) );
  
  % 改进2.2:★★纵向交叉策略★★
  for i = 1 : dim
      d1 = randperm(dim,1);
      d2 = randperm(dim,1);
      r1 = rand();
      x_cross(sortIndex( b(j) ), i) = r1*x( sortIndex(b(j) ), d1 ) + (1-r1)*x( sortIndex(b(j) ), d2 );
  end
  
  if fobj( x_cross( sortIndex( b(j) ), : ) ) < fobj( x( sortIndex( b(j) ), : ) )
      x( sortIndex( b(j) ), : ) = x_cross( sortIndex( b(j) ), : );
  else
      x( sortIndex( b(j) ), : ) = x( sortIndex( b(j) ), : );
  end
  
  x( sortIndex(b(j) ), : ) = Bounds( x( sortIndex(b(j) ), : ), lb, ub );
  fit( sortIndex( b(j) ) ) = fobj( x( sortIndex( b(j) ), : ) );
​
end
​

程序实现了23种测试函数,可以通过更改main函数中的“F+编号”进行多函数性能测试。

程序结果

测试函数1

测试函数10

结果表明:改进算法较原算法优势显著。
智能算法最重要的就是改进策略,这种策略形式也可以用到其他智能算法里面,通过其他方式的组合形成新的改进算法,也是智能算法创新的重要方向。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值