rastrigin.m

来自「本文是关于粒子群算法(pso)的介绍和相关MATLAB源程序,是智能天线权值优化」· M 代码 · 共 22 行

M
22
字号
% Rastrigin.m
% Rastrigin function
%
% used to test optimization/global minimization problems 
%
% f(x) = sum([x.^2-10*cos(2*pi*x) + 10], 2);
% 
% 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 = Rastrigin([1,2;5,6;0,-50])
% note: known minimum =0 @ all x = 0

% Brian Birge
% Rev 1.0
% 9/12/04

function [out]=Rastrigin(in)

 cos_in = cos(2*pi*in);
 out    = sum((in.^2-10*cos_in + 10), 2);

⌨️ 快捷键说明

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