⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dejong_f4_noise.m

📁 C++实现的PSO算法,很有用写关于PSO算法的论文少不了他
💻 M
字号:
% DeJong_f4_noise.m
% De Jong's f4 function, ND, includes a normally distributed noise term
%
% f(x) = sum( [1:N].*(in.^4), 2) + randn(tlen,1)
%
% x = N element row vector containing [ x0, x1,..., xN ]
%   each row is processed independently,
%   you can feed in matrices of timeXN no prob
%
% example: cost = DeJong_f4([1,2;3,4;5,6])
% note minimum @ x= all zeros

% Brian Birge
% Rev 1.0
% 9/12/04
function [out]=DeJong_f4_noise(in)
 persistent D tlen d randterm

% this speeds routine up a lot, if called from PSO these won't change from
% call to call (repmat is a cpu hog)
 Dx=length(in(1,:));
 tlenx=length(in(:,1));
 if isempty(D) | D~=Dx | tlen~=tlenx
   D=Dx; % dimension of prob
   tlen=tlenx; % how many separate states
   d=repmat([1:D],tlen,1); % needed to vectorize this
  % makes sure the function stays the same for the whole PSO run
   randterm=randn(tlen,1); 
 end
 out = sum( d.*(in.^4), 2) + randterm;

⌨️ 快捷键说明

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