PSOt, particle swarm optimization toolbox for matlab. & T5 g/ w8 `- b8 r# l 2 y+ R" D# N8 Z c' Z4 F! y! _May be distributed freely as long as none of the files are / d4 h# _' f- n9 d
modified. 3 A+ Q* W. v9 `4 J6 f7 [) p; l8 E9 B
Send suggestions to bkbirge@yahoo.com $ j; O9 t2 W4 ~/ M2 h- U1 g0 ?( h% \4 o* i
Updates will be posted periodically at the Mathworks User w; \, O" K$ h% d& pContributed Files website (www.mathworks.com) under the , Z- U" i& R2 ~% r3 ZOptimization category.2 ^2 a8 ~3 {4 ]
: H2 ~& H7 B3 a4 e: X2 nTo install:2 D8 R7 }/ h. ~9 Y
Extract into any directory you want but make sure the matlab " S# {, a) F5 E6 _8 p) Upath points to that directory and the subdirectories 3 k; v' F2 u% r& u) o+ Q# n
'hiddenutils' and 'testfunctions'. ; f$ v4 e* a! U' f5 ^: E; y
9 H7 O* z0 G" bEnjoy! - Brian Birge : K( A$ J3 f- ]; |8 s6 E8 P 3 o+ C& w! l5 z' ^! a( m7 g-------------------------------------------------------------" B, y% f n% y; r
-------------------------------------------------------------, P6 y! e( |8 O# i
0 G& [8 d U1 S$ \
INFO: ~0 c: `% c+ o Q6 O: i
Quick start: just type ... out = pso_Trelea_vectorized('f6',2) " m& g) ]& Z% C. |! v3 wand watch it work!! N O) K% C7 q$ a* ]2 E! G
. D/ [- Y* [" E5 L) r' TThis is a PSO toolbox implementing Common, Clerc 1", and ' q6 F: W7 u u# m) v* [5 TTrelea types along with an alpha version of tracking changing - X6 c J4 p# a; h) Wenvironments. It can search for min, max, or 'distance' of ; C" f0 ]" f3 W- D0 V8 u/ huser developed cost function. Very easy to use and hack with 1 K3 f, ^9 J, X, ]reasonably good documentation (type help for any function and P6 ]! b, T( O" {9 g- W1 D- c) rit should tell you what you need) and will take advantage of - s3 T2 |( G3 Lvectorized cost functions. It uses similar syntax to Matlab's + g- D- x* \6 `optimization toolbox. Includes a suite of static and dynamic * h1 N$ z J0 _
test functions. It also includes a dedicated PSO based neural ) q! R2 c8 w8 R# N2 N- inetwork trainer for use with Mathwork's neural network toolbox.2 |: J1 F/ R9 f; l) F
! o4 c0 \) V2 K0 c
Run 'DemoPSOBehavior' to explore the various functions, options, 4 r6 x# M' b+ b- N* n" E( G3 Q+ `" Band visualizations. ' d5 Z C" `6 _' r- g
. I( S4 c) d/ G3 [5 _ {. ^
Run 'demoPSOnet' to see a neural net trained with PSO 0 r: R5 v7 Q# z9 y$ ?
(requires neural net toolbox). O: M' z7 c. s8 m0 K; ]/ k# E+ c; O : o8 V1 Y3 g. |; w& b+ N9 H/ Q4 p% ]" f! [! B: u* V, @7 w
This toolbox is in constant development and I welcome * ]; g- X- j0 Y2 x( H& usuggestions. The main program 'pso_Trelea_vectorized.m' lists 4 _0 {9 v- I/ |% J
various papers you can look at in the comments. + E* g" R. h8 @5 g: z; a# z' e/ l$ A! d/ d! A
Usage ideas: to find a global min/max, to optimize training of , N7 e* [% a5 f# d: Y& a( ?
neural nets, error topology change tracking, teaching PSO, H- i0 j2 h4 f
investigate Emergence, tune control systems/filters, paradigm 3 Z$ @& k$ H1 @) G& D: E; @* q6 U0 ^
for multi-agent interaction, etc. ( Q$ X/ v& b7 i+ l $ v, i" W/ G2 h1 I1 Z------------------------------------------------------------- 2 a0 H7 e4 Y+ }+ O-------------------------------------------------------------6 R6 R: |$ [# T: f7 k3 s& H
8 r( ?4 F' k$ G; c# _# {" q
/ |% I" L% Y4 K, i
Files included: 6 M8 Q* K* W$ j. x8 Y5 q/ d8 ^& c1 W! H
: V2 T) D0 T* n5 D! @
** in main directory:+ ?# y" c) C& n z0 q+ h
9 j. \5 W9 M, [. D. f0) ReadMe.txt - this file, duh 7 R; w) c& u [* H* o7 i1) A Particle Swarm Optimization (PSO) Primer.pdf - powerpoint converted to pdf presentation explaining the very basics of PSO3 J/ U' u3 q: e- S' H. @4 Q
2) DemoPSOBehavior.m - demo script, useful to see how the pso main function is called0 }, F! p, |. D! V4 z% g
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 ! a) T8 \- e$ X' [% \4) goplotpso.m - default plotting routine used by pso algorithm 6 b: X7 N2 S* n4 z) N5) pso_Trelea_vectorized.m - main PSO algorithm function, implements Common, Trelea 1&2, Clerc 1", and an alpha version of tracking environmental changes. / N7 h2 z/ Z P! h# {# c " U$ B9 w8 j1 d: p0 m% } " }* W) _8 K1 l4 _; A, H9 E2 x( E0 x9 y% A- G2 }
** in 'hiddenutils'' E2 U$ G3 N6 g5 ]
9 Y8 A% c0 h _% c0 f7 [7 Y
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 R" ?5 S' v( C' W+ ~5 c2) normmat.m - takes a matrix and reformats the data to fit between a new range, very flexible , X# D+ g# E5 {# D3) linear_dyn, spiral_dyn.m - helpers for the dynamic test functions listed in the 'testfunctions' directory$ F) E, O; Z/ A% S1 q2 ~+ ~
$ O$ f0 S( R( K, F) s T2 [ + l2 L3 H6 K, l% w- q* P# T- u( d* C+ \+ \3 q4 w
** in 'testfunctions' ' w& h+ d7 _' N8 t$ C& k ) l1 V5 l0 Q6 ?+ _4 ^/ Z0 C4 Z) a1 XA bunch of useful functions (mostly 2D) for testing. See help for each one for specifics. Here's a list of the names:( h. z' s2 C0 M0 B, u8 [
* O% z c4 s# [1 R+ D }Static test functions, minima don't change w.r.t. time/iteration: 3 l0 d0 |. x T: \3 {, ?% k 1) Ackley8 A" r+ Z: f. |) q, O) K
2) Alpine 5 {3 w. m' H0 J3 u* R* h 3) DeJong_f2 + P- P+ b- M- |+ G 4) DeJong_f36 }. a5 U' N. i" k+ l, {2 U7 K7 C% |
5) DeJong_f4 + g9 y3 s; w" e4 ~3 Z# ~ 6) Foxhole : [. f: o2 Z+ r6 s0 w 7) Griewank3 _4 F5 |5 Y0 v0 f, b" j
8) NDparabola " T( {, J2 h) t8 \ 9) Rastrigin & Q) P* G4 W$ D. _/ H10) Rosenbrock: Y# q z) w% Q& p2 c d9 o7 E/ S
11) Schaffer f6: F: @* q, L( O0 o) i! k$ z
12) Schaffer f6 modified (5 f6 functions translated from each other)3 |) x5 k, L$ h) g0 v8 A2 G
13) Tripod + T( _; _3 w+ j0 m1 h0 Z( g- x9 t" `2 @9 M
Dynamic test functions, minima/environment evolves over time (NOT iteration, though easily modifed to do so): 1 F2 w4 d. Z! Z) P14) f6_bubbles_dyn4 I1 Y: a$ }; f1 i* Z0 U
15) f6_linear_dyn$ x b( y& B( J1 A. n0 [1 ?
16) f6_spiral_dyn `3 Q& H# x, E' Y9 o
8 `% H1 D- k, y; y# ~6 ?2 H+ h7 c' @, G6 a8 a) X; |1 N
- ?/ ^" A# e8 s( l! \** in 'nnet' (all these require Matlab's Neural Net toolbox). V3 i7 s2 Z6 W! M! U
* Q6 y9 o3 F, `# j0 O
1) demoPSOnet - standalone demo to show neural net training ! z7 ~# \7 N, ^5 A 2) trainpso - the neural net toolbox plugin, set net.trainFcn to this9 n: j8 d% y, t* E+ ?, _. V
3) pso_neteval - wrapper used by trainpso to call the main PSO optimizer, this is the cost function that PSO will optimize # W6 Y7 N$ d- T& X2 Z6 f: w, ` 4) goplotpso4net - default graphing plugin for trainpso, shows net architecture, relative weight indications, error, and PSO details on run 3 i j6 }4 c1 L$ C# z3 `* d6 U* Z ; [+ Q" U* T0 s % h5 Z6 p7 G- ?, h7 z4 i