PSOt, particle swarm optimization toolbox for matlab.# ]' {# z5 r1 I! i8 i1 T
9 L9 j; `+ v. v
May be distributed freely as long as none of the files are $ Z- U g4 L S; y" J
modified. j, O4 P% [6 j* Z' I8 G; y9 g9 M7 H" r0 ], R4 q% m0 }: O
Send suggestions to bkbirge@yahoo.com {0 {& q1 F, I4 ~2 Z
7 T8 w0 f7 e' ^* IUpdates will be posted periodically at the Mathworks User + A4 U) @9 R( Z1 K$ b/ p, G3 a
Contributed Files website (www.mathworks.com) under the . V/ B4 p7 K3 a( _5 |6 D; |) C
Optimization category.& N* Y$ e3 K! {6 Z: ?+ @
: j6 v# r5 U3 z0 c7 M: h3 X" S+ \
To install:$ e8 z' t! Y& O& ^( g
Extract into any directory you want but make sure the matlab 6 S, Z1 t/ _7 w+ E& v) Wpath points to that directory and the subdirectories ) {- O' f6 j' a) a r2 @
'hiddenutils' and 'testfunctions'. 1 o! y3 u, d9 z3 ?; T6 V, L8 j
+ x& O8 s& y3 J5 b& a7 f8 n3 t
Enjoy! - Brian Birge4 a. o8 g8 l1 ?0 Q; g7 [, a+ J
' K h l2 W% D& }6 V------------------------------------------------------------- 9 F h* u2 A y( B2 X `& A+ o-------------------------------------------------------------4 @! }7 w! R7 V: G4 G4 y4 D+ |
' Q6 Y8 p' R( v3 X
INFO 6 A+ g U2 X7 q* [7 xQuick start: just type ... out = pso_Trelea_vectorized('f6',2) " _* o* _4 j9 d; N; L
and watch it work!! O# f( n) p: S! R
j, m' L! |. ~' D2 x: uThis is a PSO toolbox implementing Common, Clerc 1", and # K. c. s, W- K; E/ ZTrelea types along with an alpha version of tracking changing0 p' t$ S7 Q2 d" a L% m! d) N0 w
environments. It can search for min, max, or 'distance' of Q1 t! }" J5 ]1 p7 nuser developed cost function. Very easy to use and hack with , D* E7 a, U& x2 s$ _: Sreasonably good documentation (type help for any function and1 n; K. v* k2 p7 x
it should tell you what you need) and will take advantage of . `8 \3 j: @, [5 v) W. v2 ]
vectorized cost functions. It uses similar syntax to Matlab's . V0 ?4 ]# h; y# a# x4 t" |optimization toolbox. Includes a suite of static and dynamic * Q: [. v1 @; C( n; r6 d' y
test functions. It also includes a dedicated PSO based neural $ z7 D7 l- X( T/ C( hnetwork trainer for use with Mathwork's neural network toolbox.7 H9 J& F" T7 Q: Q& M0 X* x: U
6 a' H* `9 ?) g( q }
Run 'DemoPSOBehavior' to explore the various functions, options, 2 W8 ~$ [. F( C
and visualizations. H( f( v6 c' h& V! g8 R. o' N- T4 k/ L' F2 M
Run 'demoPSOnet' to see a neural net trained with PSO # }9 B) k- v# S6 Y! ], {
(requires neural net toolbox). 1 F( W- T. r; G" \, Y. [ 5 J" p0 a0 t$ S( D; u8 f9 x; i3 N% ], i9 T/ ^" @
This toolbox is in constant development and I welcome # V3 `2 k0 t9 C3 y" Z
suggestions. The main program 'pso_Trelea_vectorized.m' lists ; Y/ ?/ i6 M8 z# V
various papers you can look at in the comments. , ~, U! l9 f4 n5 B# X# n( Y1 j* M4 f5 _! y
Usage ideas: to find a global min/max, to optimize training of - P+ \* e4 N0 S6 D5 ^
neural nets, error topology change tracking, teaching PSO, . h7 u% D t% k* T
investigate Emergence, tune control systems/filters, paradigm 0 x" M* U; s- Bfor multi-agent interaction, etc. " ^) A8 W( C3 A( N* |* O4 T* D- b, K3 q
-------------------------------------------------------------4 _+ _4 u* O, a% R g2 T
-------------------------------------------------------------$ G! Z8 a$ E4 X
0 {! |5 p) L1 n8 M. Y% K4 {7 i5 x( c& } \2 M7 [4 v* q: @; q
Files included: 0 `) V# N$ _9 \ i( c # {# w" h- r; g, X3 G; P7 [, _5 a$ J* z+ C& K1 R% h- ?5 }
** in main directory: ) g$ j/ B9 S- b9 h. \ 8 H) R, \' R2 ~/ O% a- s. z2 |0) ReadMe.txt - this file, duh) K/ o1 k# V: y( o! ]& o, f" k: f7 a
1) A Particle Swarm Optimization (PSO) Primer.pdf - powerpoint converted to pdf presentation explaining the very basics of PSO( t( g* W: x! z8 u0 f! f* \
2) DemoPSOBehavior.m - demo script, useful to see how the pso main function is called : {3 ~9 C: ^+ S! C3) 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 & q2 B; J E0 W+ |9 P4) goplotpso.m - default plotting routine used by pso algorithm : y; ~$ w3 w- l' X! D4 h8 h9 \5) pso_Trelea_vectorized.m - main PSO algorithm function, implements Common, Trelea 1&2, Clerc 1", and an alpha version of tracking environmental changes. ( J5 o. r( y* K* g7 |. I1 }( t6 B. _% }. E( u1 [
, R6 X8 A! Z' P+ N( i0 D3 J9 g& h: q, @- D1 ]
** in 'hiddenutils'' V0 H$ l4 M; S; p0 ~. i8 u
8 {! j9 ~* [9 c7 Q& m1) 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 3 r* U K+ A6 C: r( K2) normmat.m - takes a matrix and reformats the data to fit between a new range, very flexible7 x/ l$ v9 G# [; C, }6 h, }
3) linear_dyn, spiral_dyn.m - helpers for the dynamic test functions listed in the 'testfunctions' directory& ~7 P, s$ A: W$ s, `# e. s/ z
& ]! f/ ?* O9 n1 F4 p" q6 e2 | l/ G; y. M( M8 v
9 l" n) o! l5 r# V# F8 i
** in 'testfunctions' 6 z$ ?* R" E/ C) j% V- j* J" u6 n" ^9 f7 S2 S$ S" m5 J5 _
A bunch of useful functions (mostly 2D) for testing. See help for each one for specifics. Here's a list of the names: + g( U6 N9 R' Q9 I A2 {" e# o" [- s7 ~
Static test functions, minima don't change w.r.t. time/iteration: : U8 F0 U2 x D6 q: Q4 ?9 Q- B 1) Ackley 4 i2 ~- R5 f7 E0 j3 T 2) Alpine2 }) y- ?9 u, B9 t
3) DeJong_f2 ) Q5 p2 W9 @ ~. w 4) DeJong_f3; B/ @* S/ ^) B0 W
5) DeJong_f4 & C6 _* C. [' _5 d3 p: d 6) Foxhole! S0 g& {' Z$ w* ^0 }
7) Griewank1 Y% C2 `/ G) j7 e. g
8) NDparabola1 ^" }# z: r6 _0 j5 a B1 K
9) Rastrigin9 K" U/ O }; B' w( C: ~4 P1 k
10) Rosenbrock ; y T1 S+ j4 J9 L$ Q5 R, b+ t2 B11) Schaffer f6, k/ ^5 v- |5 v/ [' ]( i' r
12) Schaffer f6 modified (5 f6 functions translated from each other)% J* a- W7 i0 k4 o- [8 {
13) Tripod ; }8 n9 W7 q% s$ C, V# } ! c- n+ Z# }' ]1 D Z5 b4 P" z2 A9 yDynamic test functions, minima/environment evolves over time (NOT iteration, though easily modifed to do so): 7 ?* O5 K4 `8 @+ _5 g/ D14) f6_bubbles_dyn 3 P8 P0 |- e8 K6 P: _# R15) f6_linear_dyn! G7 D" [/ a3 B# \( D: z( K4 L4 Y' z
16) f6_spiral_dyn+ m# k6 q, b& d+ H5 ?
8 B* e$ ^9 \2 s! k 4 Q) d" m7 l) x9 S/ g ; E) |9 }5 x4 h, S, ?% b3 g3 H** in 'nnet' (all these require Matlab's Neural Net toolbox)" C1 e$ ]: b# u! P# @! G
% D' ?- O: O3 O2 {- V; }
1) demoPSOnet - standalone demo to show neural net training9 [) T4 H6 g& ^6 `4 |; X( v' w1 {. l
2) trainpso - the neural net toolbox plugin, set net.trainFcn to this ( E+ I- ~' M9 h 3) pso_neteval - wrapper used by trainpso to call the main PSO optimizer, this is the cost function that PSO will optimize( h8 W4 j- E7 k1 E: J
4) goplotpso4net - default graphing plugin for trainpso, shows net architecture, relative weight indications, error, and PSO details on run 7 q' }8 G5 a3 U- g" R5 h- E X4 D4 N