PSOt, particle swarm optimization toolbox for matlab. / o3 i/ F9 [1 w# f& P$ }, n6 s& _) O* ?3 Z
May be distributed freely as long as none of the files are 2 o- z8 X" I& L& x% O2 P& emodified. 4 N* D; _$ N$ ^ f
1 s" r6 q! B. ~
Send suggestions to bkbirge@yahoo.com 5 Q4 _* D# I2 M8 @% a7 ~# x3 h T8 w3 a( t
Updates will be posted periodically at the Mathworks User + I$ T+ a A- S9 H" D+ ~4 jContributed Files website (www.mathworks.com) under the 4 k! p; _( k) @Optimization category.' _; x. f) H+ s% z7 f
' M! L/ N U4 L4 u( `# T G
To install:* n q) W: i2 S( {
Extract into any directory you want but make sure the matlab " P1 u# s3 h* `path points to that directory and the subdirectories 1 I8 z9 }/ N( i, \9 R
'hiddenutils' and 'testfunctions'. 1 _ Q: I8 s+ y, r0 M8 q: ?
9 j8 \% y$ H$ G# ^- o6 ?
Enjoy! - Brian Birge- y, K+ L( z6 i- _" L% c% Y
4 S2 B* S7 d$ n0 _
------------------------------------------------------------- : H% ^7 w Y: y( n-------------------------------------------------------------0 C( [5 O) Q8 P- w
' ^3 e+ w' h% W
INFO" k( G) k/ b0 A( h7 J6 t
Quick start: just type ... out = pso_Trelea_vectorized('f6',2) . W7 A! v' \1 @* Nand watch it work! 6 d2 s2 \& U" S ~( h' T4 ~' ~' D7 A _! ?3 _This is a PSO toolbox implementing Common, Clerc 1", and & Y! E3 M; c( d/ B
Trelea types along with an alpha version of tracking changing4 T2 N7 b- G% R' @9 W. `
environments. It can search for min, max, or 'distance' of + P, W" d1 V- N# i2 L0 K
user developed cost function. Very easy to use and hack with # Z. I8 n' Y" d+ @reasonably good documentation (type help for any function and 6 _* g: B8 `/ pit should tell you what you need) and will take advantage of 6 v# u! q4 a6 y% }
vectorized cost functions. It uses similar syntax to Matlab's 6 r4 }3 V2 Y5 B% Soptimization toolbox. Includes a suite of static and dynamic ; r: z! b+ A, H) i9 u1 |
test functions. It also includes a dedicated PSO based neural 1 v; v4 ~- p" t- X
network trainer for use with Mathwork's neural network toolbox.8 r V- y }1 H2 R7 e6 U
' x! T5 c- {' e1 dRun 'DemoPSOBehavior' to explore the various functions, options, / [' P& A7 s" j8 A, h& \$ [& ^! I
and visualizations. ; J7 j9 f- x) n $ o1 o: u1 T: l( W) }- k- IRun 'demoPSOnet' to see a neural net trained with PSO " N$ Y( U; U2 L, \8 `8 x8 B( E
(requires neural net toolbox).9 A( |2 a2 H3 ~6 \" A
) @+ c/ I X3 M% K1 } T7 W 3 f$ @) d- o4 i4 G" U1 m; V C% w8 V4 nThis toolbox is in constant development and I welcome 5 y: q4 h2 Y0 @* B. Y! L5 u
suggestions. The main program 'pso_Trelea_vectorized.m' lists 2 G8 \7 h( f- p) S# ?
various papers you can look at in the comments. 9 Q& O0 m5 j5 e9 S 5 j; E' f1 S2 r% U0 B1 R" q0 `Usage ideas: to find a global min/max, to optimize training of " c. J3 M# ^+ O/ E; c+ c2 t
neural nets, error topology change tracking, teaching PSO, / O7 F) P$ u* |1 y
investigate Emergence, tune control systems/filters, paradigm . g3 W2 \. P, }8 k: n" q! sfor multi-agent interaction, etc. * D8 x' r* F( v, ^- p0 v" ~( s, }4 H8 `0 G) |. m6 g+ }' l, T
-------------------------------------------------------------. ?! s) m( H& G' W
------------------------------------------------------------- \+ ?6 _8 g9 ]3 J I8 U u( B * V$ D. A; B2 f # N) o; [2 `. ^. ~+ M; W+ GFiles included: * I* O9 t5 Z& j) p# F9 ]* {& Z, B% w% F& l' z/ R( Y& P
) N) a9 H/ E. u6 M** in main directory:* A4 I H, a- b0 M) Z5 s
# G) g; R' G! Q$ V1 P3 q3 P2 L0) ReadMe.txt - this file, duh) x" x6 A3 P+ ~5 G& @$ O
1) A Particle Swarm Optimization (PSO) Primer.pdf - powerpoint converted to pdf presentation explaining the very basics of PSO# |+ g5 h5 ]' b& ]" L$ O6 y
2) DemoPSOBehavior.m - demo script, useful to see how the pso main function is called 3 U& D6 B1 u; r3) 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' [$ D! ]8 l! I: S4 k1 \
4) goplotpso.m - default plotting routine used by pso algorithm2 ^% J3 G5 m$ c$ U; _5 {+ [
5) pso_Trelea_vectorized.m - main PSO algorithm function, implements Common, Trelea 1&2, Clerc 1", and an alpha version of tracking environmental changes. % B1 c; V: A; S" A% l ! B, V" a p8 G 0 _8 G5 y# S; y! q% D' i; v, } y0 T* d- y- T" i** in 'hiddenutils' c; b2 y' ^- j) V2 } h" O" |
/ v8 L! @4 ?/ J! L, F/ w: G0 C0 S
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! ]2 ?8 Z( t: X2) normmat.m - takes a matrix and reformats the data to fit between a new range, very flexible $ [; z L/ ^8 `' p8 w$ s E* M# o3) linear_dyn, spiral_dyn.m - helpers for the dynamic test functions listed in the 'testfunctions' directory 3 S0 N/ c( @1 r1 N1 h% X7 F$ p7 T4 X/ e$ U0 @# R, U' ]0 d% u
2 X# Y# }* ?) Y# D: D* e) d: L6 I* r- T/ {
** in 'testfunctions') N1 \' Y! J$ }7 H$ A) l' q5 |; S
; ^7 [% a4 s& ~- Y1 r+ F
A bunch of useful functions (mostly 2D) for testing. See help for each one for specifics. Here's a list of the names: + m; \3 L% D4 n) c; j 6 V! p4 f* P, Y. ~' M/ m3 Y% eStatic test functions, minima don't change w.r.t. time/iteration:. Z6 {5 d0 w, X) {
1) Ackley $ k' I9 I9 K' a! a! Q 2) Alpine $ w& v; g6 @: M, h# F/ K8 K 3) DeJong_f2 % n4 s# j: R" `" v; R g. w6 V 4) DeJong_f3 # [! b) l. q1 {5 b" ]+ a 5) DeJong_f4 $ ~& A7 X. z) M+ c0 l. s# H% W ^ 6) Foxhole5 {0 @, d7 n. t
7) Griewank( K" m6 q; o0 R# Q
8) NDparabola, _; ]! g' y/ ~" T
9) Rastrigin! l- o1 Q; a( w- V& H1 t3 `0 _& w
10) Rosenbrock 5 @3 M4 _( i. D+ b0 h11) Schaffer f6 4 u7 Y S: D- P12) Schaffer f6 modified (5 f6 functions translated from each other)9 D- n, O, ~# M" {
13) Tripod- ^4 ~6 k) @7 Q, A
' r- {5 _$ L" q' eDynamic test functions, minima/environment evolves over time (NOT iteration, though easily modifed to do so): 0 A4 i6 [, {) Y, {14) f6_bubbles_dyn/ C$ l% `& t& A$ k% d
15) f6_linear_dyn $ }! J* F% \+ J! g5 [; m A16) f6_spiral_dyn 3 y+ |( ^/ u8 X3 y ) q- p$ q* [6 X r/ y/ f8 w) l 6 I- ]4 }# Z; _9 [4 I. I- K% e* V/ m. S) b* J& w
** in 'nnet' (all these require Matlab's Neural Net toolbox)# s# ?3 ^ T7 G( }4 d
c1 A9 S& T; P5 Z1 U 1) demoPSOnet - standalone demo to show neural net training; i: \8 T" O8 N% h
2) trainpso - the neural net toolbox plugin, set net.trainFcn to this S$ d7 n* D8 W, z; c1 {4 K0 |5 h
3) pso_neteval - wrapper used by trainpso to call the main PSO optimizer, this is the cost function that PSO will optimize 1 s0 n& w4 \. N/ b 4) goplotpso4net - default graphing plugin for trainpso, shows net architecture, relative weight indications, error, and PSO details on run0 n9 \5 N5 v4 T9 l
+ Q+ c4 k" v) r$ l( q" u - c0 [# ]) Q7 F6 P& [, C% D% m