Another Particle Swarm Toolbox
01 Dec 2009
01 Apr 2014)
Implementation of a PSO algorithm with the same syntax as the Genetic Algorithm Toolbox.
function f = templatefcn(x)
% Template for writing custom test/demonstration functions for psodemo.
% Change the function name and save as a different file to preserve this
% template for future use.
% NOTE: defining KnownMin is only for the purposes of demonstration
% plotting. It does not help the particle swarm algorithm in any way.
% Opportunity to set custom options before psodemo actually calls pso.
% Some examples:
% f.PopInitRange = [-2; 2] ;
% f.KnownMin = [0,0] ; % For plotting purposes only
% f.PopulationSize = 100 ;
% Set f.Vectorized = 'on' if the test function is able to take a matrix
% input, with swarm individuals on each row. That is, x is size n x nvars,
% where n is the number of individuals in the swarm, and the test function
% returns f as an nx1 vector representing the fitness scores for all
% Write the actual function here.
f = x.^2 ;