PSOt, particle swarm optimization toolbox for matlab. % q" ]( t- N b. B$ e2 x3 q9 x7 T( ]! d& |4 f7 F: W
May be distributed freely as long as none of the files are 3 i' l: }6 N6 `4 h
modified. - S3 N) X& V8 ]8 s$ `, F) G
* J4 ]+ O2 U5 y( S6 BSend suggestions to bkbirge@yahoo.com , G( X: I, d) K8 v m# G8 `0 z% w6 Q. m& {! u0 z* I, i' Q' s
Updates will be posted periodically at the Mathworks User ' D, N4 L6 ?5 Z6 ]+ F# r( ]Contributed Files website (www.mathworks.com) under the 1 I- a+ m7 a3 _/ n i! J/ ^. F3 s
Optimization category. ( q, C+ z+ Q, V* X0 Y7 Y8 x; i1 p/ J# n
To install: , z7 l, M: R4 w6 t+ VExtract into any directory you want but make sure the matlab & I1 Z& y) r% S0 `0 A4 U7 j+ i0 `path points to that directory and the subdirectories - C: P7 X& }) h" J'hiddenutils' and 'testfunctions'. . N+ I9 H7 O# D2 A( `5 _
: l3 h! G2 D4 Q: T& E6 XEnjoy! - Brian Birge }& a2 G; ^ H" r
! }) `5 z5 z# q% i4 u-------------------------------------------------------------3 G/ I1 |. }* c) H3 U$ m
------------------------------------------------------------- , `) m+ E9 o. e M5 b 2 i l4 b! y3 i- V, Y2 I7 k0 lINFO ; I" K5 h9 g" W' l8 nQuick start: just type ... out = pso_Trelea_vectorized('f6',2) + E* R( H( G4 t; J3 b9 }- \8 Q& Fand watch it work! & L5 I g1 T J" |- Y ~# } 5 @5 M$ ~5 P' R! L" Z$ U7 }This is a PSO toolbox implementing Common, Clerc 1", and " W7 B0 K* `6 `" N$ H! aTrelea types along with an alpha version of tracking changing1 q! i: V) G' C! l
environments. It can search for min, max, or 'distance' of # @* H+ z4 Q. M8 |% {
user developed cost function. Very easy to use and hack with ; C1 `9 `" W* i5 {. \: E1 Z5 `7 D8 e4 O' n
reasonably good documentation (type help for any function and 6 x3 g# K7 t- j; ?& Bit should tell you what you need) and will take advantage of - X" T3 K, T. r& qvectorized cost functions. It uses similar syntax to Matlab's2 q/ U/ o6 D3 k) O, s3 \( h
optimization toolbox. Includes a suite of static and dynamic 6 [5 n0 x. w$ u+ Z4 _/ W0 ~! ^2 Z
test functions. It also includes a dedicated PSO based neural ! r& W! R; Y' _5 I8 ?+ ~) ]4 T( N. L
network trainer for use with Mathwork's neural network toolbox.. {8 m" |8 l2 r% k; E4 b& i
7 K8 _6 R5 m0 y9 r* B. IRun 'DemoPSOBehavior' to explore the various functions, options, 1 ^( h0 u4 i8 n2 K' A, fand visualizations. " ]7 W# @9 N; g1 {: I& Z & _. U! L4 a, }2 LRun 'demoPSOnet' to see a neural net trained with PSO 7 s& A7 H: B. l3 x' n6 {' C# Y6 W% G
(requires neural net toolbox). 7 K5 }, T7 M2 r: D& k0 g3 W% R2 C( f& Y3 _$ _+ D& t
% I. ~! d) z N% D1 J8 E8 DThis toolbox is in constant development and I welcome 8 P$ {3 A2 P/ Z
suggestions. The main program 'pso_Trelea_vectorized.m' lists ' }3 o5 }# e' ~( F
various papers you can look at in the comments.' V) M( O! E# o5 t7 ^
- J# i3 l9 ~( s7 b' @, |Usage ideas: to find a global min/max, to optimize training of ( h1 |" [3 X) Tneural nets, error topology change tracking, teaching PSO, % {& r4 f+ t7 b* P+ |+ G; u( Kinvestigate Emergence, tune control systems/filters, paradigm + \' d( N1 p! X/ o) l
for multi-agent interaction, etc. $ Z. ^. G# \" e9 D% X & p% C- Q) a. ]2 a-------------------------------------------------------------* n# f' i: `, p4 C
------------------------------------------------------------- 8 c* ~2 g& e3 \+ x 5 N- }( T. r0 S: p3 i% y3 S2 u+ S I# [
Files included:, {9 Q2 X6 b. }7 y! ?7 ^- D
9 A; i( _4 d: B% ]0 S. S1 b+ P/ x h5 q
** in main directory:! ?* d% L; D7 U7 i% q+ }
& P2 q( ^. I6 |0 ~. W
0) ReadMe.txt - this file, duh5 m: d. r2 G' q- i: Y ~/ l
1) A Particle Swarm Optimization (PSO) Primer.pdf - powerpoint converted to pdf presentation explaining the very basics of PSO+ n" ?1 `0 a* Z5 a1 W) ]
2) DemoPSOBehavior.m - demo script, useful to see how the pso main function is called- M. ~) V8 k9 j1 I- v8 Y7 c" ^
3) goplotpso4demo.m - plotting routine called by the demo script, useful to see how custom plotting can be developed though this routine slows down the PSO a lot Y% U" z2 X+ P4 T) u# S; C
4) goplotpso.m - default plotting routine used by pso algorithm " ]& i; S) F+ W8 F. {5) pso_Trelea_vectorized.m - main PSO algorithm function, implements Common, Trelea 1&2, Clerc 1", and an alpha version of tracking environmental changes. + D; Z. T0 z3 _9 m, H2 y/ ^1 [0 r7 g4 ^& q: \! e
* W/ V- a2 k2 P8 u+ C: P
' {. K, y( ? a
** in 'hiddenutils'2 t. y% v! c4 I% S A
+ l _1 `% a% {( v/ A9 H; r
1) forcerow, forcecol.m - utils to force a vector to be a row or column, superseded by Matlab 7 functions I believe but I think they are still called in the main algo, `" x" N' ~: _1 j. v/ w& f& Y
2) normmat.m - takes a matrix and reformats the data to fit between a new range, very flexible ; x" `$ k; H; _3) linear_dyn, spiral_dyn.m - helpers for the dynamic test functions listed in the 'testfunctions' directory ) Y( t! @+ h8 r" e3 D2 g8 Y% b$ a2 |2 w. `* {. ~' T) ]( v, M! g
' |+ p* h# t5 Y8 b
( z/ g8 a+ |4 f! }# \8 J** in 'testfunctions'7 X V3 L/ p2 ~# g5 x
! x* K, [: F9 I
A bunch of useful functions (mostly 2D) for testing. See help for each one for specifics. Here's a list of the names:2 b% R- [* c* X/ ^: w
1 h; h" B& E2 K; f" E$ R$ ^
Static test functions, minima don't change w.r.t. time/iteration: % s' s- I, k) R7 W 1) Ackley+ q+ @3 j) F x4 C, s# Z
2) Alpine 9 P. k$ }$ D, {7 A# G6 L 3) DeJong_f2 . i5 i0 j. l: l" r; Y c 4) DeJong_f3 " b+ a W+ F1 X" o* t: H 5) DeJong_f4 : y: ?8 a' S* ~+ T1 ^9 a/ ^: P 6) Foxhole / |5 @" l/ ^* X" `7 q7 n2 P 7) Griewank + ^, ] m" p; d4 w% R 8) NDparabola 8 W7 A, V2 f$ Y7 M! F( e$ z 9) Rastrigin + S. S* Y; H" @10) Rosenbrock( B7 h4 x ~6 }. _
11) Schaffer f6( I+ P* x0 B3 G1 v7 i
12) Schaffer f6 modified (5 f6 functions translated from each other) " h4 d0 l0 g V# e3 m+ n13) Tripod' `& I) R. z9 g m" k: n% i
8 ^6 ~5 D9 U! ?( Y" _1 A4 `Dynamic test functions, minima/environment evolves over time (NOT iteration, though easily modifed to do so):9 Y- n" L1 J! s. ^1 e
14) f6_bubbles_dyn5 n+ h% {9 _( d% `
15) f6_linear_dyn/ o! f* h8 x: N6 f* a; L- U$ s
16) f6_spiral_dyn$ e8 {8 o4 x3 c/ I
4 p: Q( x0 m) i$ o+ u3 T
5 b g; g% H1 t7 i3 f/ I# j/ Z$ N' r% u9 |& m
** in 'nnet' (all these require Matlab's Neural Net toolbox)* I" j, X5 Q, J3 P0 @! f' a: c
' c5 [9 @- F0 d7 H5 ^" c6 i 1) demoPSOnet - standalone demo to show neural net training ( G( L* n' `) h4 E% \ 2) trainpso - the neural net toolbox plugin, set net.trainFcn to this; v; K/ F$ {9 c
3) pso_neteval - wrapper used by trainpso to call the main PSO optimizer, this is the cost function that PSO will optimize & r6 [* E( @7 f* C 4) goplotpso4net - default graphing plugin for trainpso, shows net architecture, relative weight indications, error, and PSO details on run . b, V5 w2 s8 D- A% u; r : b6 a. W9 u, J% t$ |; q 4 Z7 v B/ g7 B( W* O9 F$ E