PSOt, particle swarm optimization toolbox for matlab. / q6 P" X, j, R# l+ A8 }0 j7 w! \4 r& k( R/ p+ Z" ?: K) ?
May be distributed freely as long as none of the files are , l$ S8 e9 `2 W! Z+ d
modified. $ c% k* C9 W6 a# k9 y/ x+ K# E$ `' | _; u
Send suggestions to bkbirge@yahoo.com - b9 e4 [& y; R7 ]+ ]/ A8 U 5 w0 k C/ w% k+ t3 D! _Updates will be posted periodically at the Mathworks User 2 W" N" t" G: `3 M1 E8 I6 j' @
Contributed Files website (www.mathworks.com) under the 2 Z. B8 v0 i' K- w: z; g& A
Optimization category. $ C' N; j; o2 r {$ m4 M& U $ g) h$ a( {8 C- @: l! YTo install:+ O1 t+ D% o; T
Extract into any directory you want but make sure the matlab / Q0 {/ l: @9 ~4 r: w
path points to that directory and the subdirectories & I' H8 O( e# A- \* j' n'hiddenutils' and 'testfunctions'. * Y9 V7 n" U% c- K5 I8 k5 r, ^
9 n: @% Y4 _; p( kEnjoy! - Brian Birge$ b6 o+ v2 F! F
& F: J* p: u% R
------------------------------------------------------------- ' V" J; H3 A' P) G3 y: \# G2 o$ I------------------------------------------------------------- ; O1 j+ v* I6 K5 ?! `8 H: E6 N- v5 Y 7 h" u) p. ]- K! mINFO 8 ^; j- ^/ P$ f' fQuick start: just type ... out = pso_Trelea_vectorized('f6',2) & g' b. W9 I3 x' y3 C" d0 K, v
and watch it work! # o! g; z% d4 _. \ 3 h' k+ K8 h- O3 L, _( h5 ZThis is a PSO toolbox implementing Common, Clerc 1", and 4 m! p; L1 \) O: p. p/ r
Trelea types along with an alpha version of tracking changing 9 i% j/ \& } A. i8 h0 zenvironments. It can search for min, max, or 'distance' of " W/ m. q* z0 n2 n' Q, V
user developed cost function. Very easy to use and hack with ' G6 z* S1 q; ?reasonably good documentation (type help for any function and* G$ l% C! `7 J4 E% [
it should tell you what you need) and will take advantage of & K4 C: n( @2 T9 i. A0 M
vectorized cost functions. It uses similar syntax to Matlab's: s! e7 b9 i& W- ^) b
optimization toolbox. Includes a suite of static and dynamic : s# U8 X1 a' h! r1 M5 n5 o
test functions. It also includes a dedicated PSO based neural 1 b- O: M2 S4 C& p4 znetwork trainer for use with Mathwork's neural network toolbox.1 _0 S$ c5 a' v8 Y" W3 A1 O
$ f$ k+ V$ D8 d, K" Q! fRun 'DemoPSOBehavior' to explore the various functions, options, $ a4 ^( U$ R; r7 s# p6 o% gand visualizations. * S+ x* b: {2 T* C* o! b) ]( K, R6 z% [' d
Run 'demoPSOnet' to see a neural net trained with PSO 5 f q( g4 Q+ }(requires neural net toolbox).0 p3 B1 k4 t8 p# i. Y1 f
8 ]; U0 \2 L1 a7 z* }' h4 i' g. L1 T- c( c
This toolbox is in constant development and I welcome # ?7 g' L$ F) m8 R" Z5 e
suggestions. The main program 'pso_Trelea_vectorized.m' lists 4 j" P6 t: Z; t" Xvarious papers you can look at in the comments. 3 b6 X9 M$ R+ o; G: _1 }4 B9 t( K( T1 m# M3 ]" ]2 ?6 f
Usage ideas: to find a global min/max, to optimize training of 2 `6 `% l* x2 x5 f) Q+ tneural nets, error topology change tracking, teaching PSO, j1 G2 j% C0 I9 D! t5 I6 ~( Y0 u0 rinvestigate Emergence, tune control systems/filters, paradigm # ~& `' ^: T$ F0 s; K5 @. ffor multi-agent interaction, etc.) ~, o+ H& u% g& O: E
" t8 v; H% \9 }! c& u( z-------------------------------------------------------------7 E# x7 w$ x& g7 P- F
-------------------------------------------------------------" w5 o, X- o/ A# b/ o/ e
4 T. x- n/ o$ J% V& x
; \. D, O! t. U, r) C# I% U+ v
Files included:+ J1 b" _# t1 g L$ S3 a% E
& n- j( X7 C9 p1 ~' o1 R: m8 C% o8 q3 {( y6 f! {0 W; h1 ^7 K4 g, [
** in main directory:0 g! S; b, ?& B
5 ~! F2 @! L Q4 O0 R
0) ReadMe.txt - this file, duh % x' _6 s% h( J) M" i/ [, M" H( J1) A Particle Swarm Optimization (PSO) Primer.pdf - powerpoint converted to pdf presentation explaining the very basics of PSO9 ?# n8 }) H) i& L
2) DemoPSOBehavior.m - demo script, useful to see how the pso main function is called# Q# D7 S, ` _
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 2 `5 R* L- P; g/ z, H2 o4) goplotpso.m - default plotting routine used by pso algorithm : w' x6 w- T) }" h3 d" Y G" n5) pso_Trelea_vectorized.m - main PSO algorithm function, implements Common, Trelea 1&2, Clerc 1", and an alpha version of tracking environmental changes.' r; k& f( N, @: V9 K) `
% e* Q- F! Y6 h0 }# x( I/ P; ]2 \0 j& m$ m- I
5 |$ G) H3 l0 D7 x) y) n- ?* v** in 'hiddenutils' 3 x2 E* L* Q! k; P7 _6 \( Z3 D7 d2 @- N
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* s$ Q8 v0 C4 r, `
2) normmat.m - takes a matrix and reformats the data to fit between a new range, very flexible$ y, F: \0 b) b7 x0 Q
3) linear_dyn, spiral_dyn.m - helpers for the dynamic test functions listed in the 'testfunctions' directory4 M W- ]: _0 X4 r& `
) n/ v8 t% a0 R2 a1 q- _( m( n6 l( C6 P1 L1 ^) m
5 C( a* v( f X/ R** in 'testfunctions' ' `' @3 G! x' c/ i; g7 r+ ]6 C* ~7 r: j( `2 Y4 x4 M, C
A bunch of useful functions (mostly 2D) for testing. See help for each one for specifics. Here's a list of the names: 8 }. t1 K3 @+ A/ m7 ^% T) q$ A Y1 v- Y& g
Static test functions, minima don't change w.r.t. time/iteration:1 H6 _/ p0 R; u+ B
1) Ackley* h8 F, e" C3 N( }
2) Alpine 5 O' w4 ?- l7 m8 d9 h 3) DeJong_f2 . b1 V2 m% P+ b9 z3 A: z 4) DeJong_f3 E7 q/ q" Z& d; _+ ]2 | 5) DeJong_f4 " i' O2 y5 c& O7 d1 S 6) Foxhole ; }8 X3 Y' `' O/ Q; h% f& \ 7) Griewank # V8 ^- Q# ]4 @; q" E2 y4 u. u 8) NDparabola ; O* S0 M' l4 {% X; k/ U% ?7 R2 U" ` 9) Rastrigin ! ?5 g$ X2 j( Y( w+ R x; a10) Rosenbrock N% ^; ?! {5 F9 e7 r11) Schaffer f6 4 G2 v8 K% H# s! L) W12) Schaffer f6 modified (5 f6 functions translated from each other) 9 F3 R/ Z" `* s- t/ n; H- n& W/ `13) Tripod9 x& P6 k8 C6 I2 _
5 |0 h& u" G- X! y7 j$ s/ e5 F
Dynamic test functions, minima/environment evolves over time (NOT iteration, though easily modifed to do so): + ? U7 w1 ~5 a8 p1 p% Q3 y14) f6_bubbles_dyn4 z) C, u$ s# W3 X4 V9 {
15) f6_linear_dyn: K- G. }* q+ G
16) f6_spiral_dyn % ?+ y7 {1 j! y4 O4 s" U8 l+ X! K- G9 L K! R- V
' P8 t& e3 s& j
( s* I# ` k; Y1 G& D. h' J
** in 'nnet' (all these require Matlab's Neural Net toolbox)6 n* l" T: c! Z
; ?* K* V6 s; `4 p5 M
1) demoPSOnet - standalone demo to show neural net training 8 n+ _' j- ?) [& z3 ^5 J t4 z 2) trainpso - the neural net toolbox plugin, set net.trainFcn to this 4 A* N6 `% N# @# t 3) pso_neteval - wrapper used by trainpso to call the main PSO optimizer, this is the cost function that PSO will optimize: w7 b9 V- Q* i- i1 E) N! G
4) goplotpso4net - default graphing plugin for trainpso, shows net architecture, relative weight indications, error, and PSO details on run: C7 ]2 W- X% W; t! I$ S( y+ X0 o
! M4 s! G2 w" c+ Z" A
' Z. i! P& x9 v1 I4 y/ X- |0 t) y