Code covered by the BSD License
-
...
This is like "soft" boundaries, except that some kind of penalty value
-
...
-
...
Particle swarm optimization for binary genomes.
-
...
-
...
Find the minimum of a function using Particle Swarm Optimization.
-
ackleysfcn(x)
Ackley's Function.
-
binarytestfcn(x)
-
dejongsfcn(x)
-
dropwavefcn(x)
-
evolutioncomplete(options,sta...
Plays a notification when genetic algorithm finishes. Requires a
-
griewangksfcn(x)
Template for writing custom test/demonstration functions for psodemo.
-
langermannsfcn(x)
-
nonlinearconstrdemo(x)
Nonlinear constraints demo with Rosenbrock's function.
-
psoboundsabsorb(state,Aineq,b...
-
psodemo(DemoMode)
Runs the PSO on a few demonstration functions, which should be located
-
psoiterate(options,state,flag...
Updates swarm positions and velocities. Called to iterate the swarm from
-
psooptimset(varargin)
Creates an options structure for pso.
-
psoplotbestf(options,state,fl...
Plots the best, mean, and worst scores of particle swarm.
-
psoplotscores(options,state,f...
Plots the best and mean scores of particle swarm.
-
psoplotswarm(options,state,fl...
Plots the positions of particle swarm.
-
psoplotswarmsurf(options,stat...
Shows the evolution of a 2-variable population over a known surface. This
-
rastriginsfcn(x)
Takes row inputs. If not row, will attempt to correct it.
-
rosenbrocksfcn(x)
Takes row inputs. If input is not row, will attempt to correct it.
-
schwefelsfcn(x)
Schwefel's function.
-
templatefcn(x)
Template for writing custom test/demonstration functions for psodemo.
-
testfcn1(x)
-
View all files
from
Another Particle Swarm Toolbox
by Sam
Implementation of a PSO algorithm with the same syntax as the Genetic Algorithm Toolbox.
|
| psodemo(DemoMode)
|
function psodemo(DemoMode)
% Runs the PSO on a few demonstration functions, which should be located
% in the <./testfcns> directory.
%
% For less intensive 3D graphics, run with input argument 'fast', viz.:
% >> psodemo('fast')
%
% Note that PSODEMO was included as a quick way to showcase the behaviour
% of the particle swarm on some commonly used optimizer test functions. To
% use the particle swarm algorithm your own problems, use PSO, not PSODEMO.
%
% S. Chen, Dec 2009.
% Available as part of "Another Particle Swarm Toolbox" at:
% http://www.mathworks.com/matlabcentral/fileexchange/25986
% Distributed under BSD license.
%
% See also: PSO
workingdir = pwd ;
testdir = ls('testf*') ;
if ~isempty(testdir), cd(testdir), end
[testfcn,testdir] = uigetfile('*.m','Load demo function for PSO') ;
if ~testfcn
cd(workingdir)
return
elseif isempty(regexp(testfcn,'\.m(?!.)','once'))
error('Test function must be m-file')
else
cd(testdir)
end
fitnessfcn = str2func(testfcn(1:regexp(testfcn,'\.m(?!.)')-1)) ;
cd(workingdir)
options = fitnessfcn('init') ;
if any(isfield(options,{'options','Aineq','Aeq','LB'}))
% Then the test function gave us a (partial) problem structure.
problem = options ;
else
% Aineq = [1 1] ; bineq = [1.2] ; % Test case for linear constraint
problem.options = options ;
problem.Aineq = [] ; problem.bineq = [] ;
problem.Aeq = [] ; problem.beq = [] ;
problem.LB = [] ; problem.UB = [] ;
problem.nonlcon = [] ;
end
problem.fitnessfcn = fitnessfcn ;
problem.nvars = 2 ;
if ~nargin
problem.options.DemoMode = 'pretty' ;
else
problem.options.DemoMode = DemoMode ;
end
problem.options.PlotFcns = {@psoplotbestf,@psoplotswarmsurf} ;
% problem.options.VelocityLimit = 0.2 ;
problem.options.HybridFcn = @fmincon ;
% problem.options.Display = 'off' ;
tic
pso(problem)
toc
|
|
Contact us at files@mathworks.com