PSOt, particle swarm optimization toolbox for matlab. + k$ k" u, o, I6 m& K( t2 I! w+ A5 ?' D: i6 O
May be distributed freely as long as none of the files are ' C* ^/ n/ }) K, l
modified. / g+ j# m7 d. ?6 L* ^/ ]
K5 J) {9 }8 q- R' [) s; Y
Send suggestions to bkbirge@yahoo.com 9 G u3 w" e* A2 N
# ]$ C* Q# A$ c0 B1 F( oUpdates will be posted periodically at the Mathworks User - w, h7 {6 A0 m3 c6 f% W/ FContributed Files website (www.mathworks.com) under the 1 `' S3 Y) P' T) m% h9 DOptimization category. ! ?" J7 _4 m8 B4 G+ F" s/ k: c3 D3 c; e- H4 w$ Y: e
To install:0 c7 a( w( v0 M& u, D3 F
Extract into any directory you want but make sure the matlab $ S. S) t! ~% Z! v8 J2 ^
path points to that directory and the subdirectories 9 l W3 M+ [7 {'hiddenutils' and 'testfunctions'. " n6 \7 U! U% H+ `/ ~5 Q. q1 m- C+ }- u4 v( U' u& r1 z
Enjoy! - Brian Birge- T# ^3 X4 H+ K6 Q* V% }+ }6 z
1 V- I5 d+ u; U8 J' b7 \: E
-------------------------------------------------------------* o8 Z6 w8 k3 Y( F# y; S
-------------------------------------------------------------; w- G. r+ }+ x
$ Y2 P k, X+ {
INFO : M. H( D+ U' F% E0 zQuick start: just type ... out = pso_Trelea_vectorized('f6',2) 7 `) c0 O0 }% @" T$ Z/ V
and watch it work!1 i) \2 c6 U" e4 I; `$ |' w6 s
4 T+ P) @6 v9 @, z8 e( @4 iThis is a PSO toolbox implementing Common, Clerc 1", and 4 X0 a: n" L8 T/ o6 ETrelea types along with an alpha version of tracking changing ( ^1 _9 ]1 S) T9 w5 I! henvironments. It can search for min, max, or 'distance' of ' C" C' R Y9 N6 N: x w; T6 }user developed cost function. Very easy to use and hack with & H1 L' N& \8 m% J6 l6 areasonably good documentation (type help for any function and1 O& V) j; z" H/ S4 ` I
it should tell you what you need) and will take advantage of % d) q+ J T4 S7 D% ~" c, s
vectorized cost functions. It uses similar syntax to Matlab's 6 T. o3 E8 e+ [( m. @optimization toolbox. Includes a suite of static and dynamic * m& ~( v" H9 j' j! ttest functions. It also includes a dedicated PSO based neural : L5 m, P" z+ l- f
network trainer for use with Mathwork's neural network toolbox. , Q# J" ]+ H6 f/ O/ e5 G1 v6 U' o0 k3 [8 L/ K, `1 K
Run 'DemoPSOBehavior' to explore the various functions, options, 8 T! G" U1 s3 u3 Y
and visualizations. 1 }" p6 s4 b6 E$ @
4 f3 |- S' g. gRun 'demoPSOnet' to see a neural net trained with PSO & H0 n6 q! v1 s: |
(requires neural net toolbox)., O6 x; ? {2 b1 W* c
" Z _! z4 }; O8 @% ~6 @
) x* y. L! F4 C# gThis toolbox is in constant development and I welcome 2 A. V' _1 |. E, K/ X1 x
suggestions. The main program 'pso_Trelea_vectorized.m' lists ( O2 M9 @, Q& N+ _# g. \* ?
various papers you can look at in the comments.3 G' k7 D0 ^$ i( q* n
( q. ~( T: H# `% k; p( O' @
Usage ideas: to find a global min/max, to optimize training of / x; d6 Q; w- e7 ?4 |- W5 K* Kneural nets, error topology change tracking, teaching PSO, $ U' v& L8 E/ f3 n2 H8 o& linvestigate Emergence, tune control systems/filters, paradigm # I. g4 |8 n. D8 Y0 C* q5 D' t
for multi-agent interaction, etc. ! {5 @+ C, f5 g3 V w6 R# B 9 l6 A# }1 f% b3 w------------------------------------------------------------- & w; p- ^4 d$ }' @5 S3 |------------------------------------------------------------- 9 n* ?- [ O, y2 i2 h$ A* [ 9 ~$ e- m7 ]+ N1 j2 ~7 q1 M. N2 r; E& t! q7 }
Files included: 1 i' v( v9 S" i6 n2 {( p$ p1 b/ P7 \
! e" j) g( g5 H0 V# E** in main directory: & x6 N& N5 m& G& D" v 1 K, u, u" c3 H, \6 Y0) ReadMe.txt - this file, duh + A/ H$ l: b7 X, G+ f9 z1) A Particle Swarm Optimization (PSO) Primer.pdf - powerpoint converted to pdf presentation explaining the very basics of PSO + w% H. B5 W$ b( r8 v4 ~8 r2) DemoPSOBehavior.m - demo script, useful to see how the pso main function is called @" b1 _9 D/ g4 @6 |& ^ A1 J3) 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 5 E) j& |8 [8 b4) goplotpso.m - default plotting routine used by pso algorithm- m/ Z0 q3 u2 |4 e1 Z- A* B
5) pso_Trelea_vectorized.m - main PSO algorithm function, implements Common, Trelea 1&2, Clerc 1", and an alpha version of tracking environmental changes. * V9 D, V8 i3 D- W- C- B ' {( \- i! f- C* y! ]4 a' U& J6 D, w. ?, l
+ `( }) J) T4 e$ E q- q5 k** in 'hiddenutils'" @: \% K9 ]) y0 P
% ~& N9 i( Q/ p, e0 E/ @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$ d; K& `- h4 p
2) normmat.m - takes a matrix and reformats the data to fit between a new range, very flexible \- C& j& H( r0 l9 p3) linear_dyn, spiral_dyn.m - helpers for the dynamic test functions listed in the 'testfunctions' directory0 e( u) i9 r( X0 O0 z
- H& }" b! @ |; l. u& R4 e
9 U1 ]( `. G& A* p
9 C& b8 E( `- W* V# s! {( |, x. o4 X
** in 'testfunctions' . @7 V5 Z! N+ N+ h2 E% Y " e& N8 e+ {) E* u7 aA bunch of useful functions (mostly 2D) for testing. See help for each one for specifics. Here's a list of the names:% I% T; q" j: z3 c' i, `+ X
1 I3 O- \! ? u$ R+ T
Static test functions, minima don't change w.r.t. time/iteration:1 a" P) _/ E ~- G/ n$ v3 a
1) Ackley & V+ ]. z* }% ^6 [0 k* M# h 2) Alpine ! c0 ?6 h. N& X2 B 3) DeJong_f2 / H) q. c7 ]- j5 v) o4 [; }6 i 4) DeJong_f3 " J+ [. l% N U% \. Q 5) DeJong_f4 3 v1 K1 H7 N' t+ x2 F! A" f) q 6) Foxhole! Q6 ~& K9 G; y6 z r
7) Griewank 7 |: L+ P& v' E, N9 { 8) NDparabola) Q1 v; z* o1 _
9) Rastrigin; z7 o5 r% |$ ~8 ?+ d4 I; E0 i# [
10) Rosenbrock ( M8 r+ }* _7 V0 x6 B11) Schaffer f6 + Y `: ?3 q; Q' t# Z! E. U12) Schaffer f6 modified (5 f6 functions translated from each other) 4 ~8 @4 q$ h8 B- E9 E13) Tripod ! F% k s5 p+ p2 O/ z# s `% I( T' p$ k' B8 S( L% S
Dynamic test functions, minima/environment evolves over time (NOT iteration, though easily modifed to do so):7 C# |' [! K8 W2 W: P
14) f6_bubbles_dyn3 Q: i K$ l& Q+ W2 G& Y9 r* p
15) f6_linear_dyn + G8 L( {, a6 K# L7 u16) f6_spiral_dyn ) i- y' Z: p% S G; A* L6 B' y+ ?, ~5 v; j- U; M3 x$ g
7 `0 m# P/ B J* p r+ O+ d [$ T
: g& U. P4 Z# K3 B9 k/ x9 k
** in 'nnet' (all these require Matlab's Neural Net toolbox)0 f3 V& x0 a1 k, H+ N) f
' f9 M) F9 w' \( N' o
1) demoPSOnet - standalone demo to show neural net training / y" ^5 Z& c( J+ c" T 2) trainpso - the neural net toolbox plugin, set net.trainFcn to this ; R1 G: v6 {0 u+ n 3) pso_neteval - wrapper used by trainpso to call the main PSO optimizer, this is the cost function that PSO will optimize7 Q5 f4 T3 `( A' b8 y
4) goplotpso4net - default graphing plugin for trainpso, shows net architecture, relative weight indications, error, and PSO details on run: g% g8 v: B7 D3 }5 d1 g: W8 @; v
. g, A: ^+ y$ A