f6_dynamic.m

来自「C++实现的PSO算法,很有用写关于PSO算法的论文少不了他」· M 代码 · 共 27 行

M
27
字号
% f6_dynamic.m
% Schaffer's F6 function
% commonly used to test optimization/global minimization problems
%
% This version moves the minimum about a Fermat Spiral
% according to the equation: r = a*(theta^2)
%   theta is a function of time and is checked internally (not an input)
%   x_center = r*cos(theta)
%   y_center = r*sin(theta)
%
% z =  0.5 ...
%    +(sin^2(sqrt((x-x_center)^2+(y-y_center)^2))-0.5) ...
%    /((1+0.01*((x-x_center)^2+(y-y_center)^2))^2)

function [out]=f6_dynamic(in)
 % parse input
  x = in(:,1);
  y = in(:,2);
 
 % find current minimum based on clock
  [x_center,y_center]=spiral(1,.1);

 
  num = sin(sqrt((x-x_center).^2+(y-y_center).^2)).^2 - 0.5;
  den = (1.0+0.01*((x-x_center).^2+(y-y_center).^2)).^2;

  out = 0.5 + num./den;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?