PSOt, particle swarm optimization toolbox for matlab. 4 L; {2 y% V4 D6 A1 f4 P+ H" O- ?0 Y( @' g
May be distributed freely as long as none of the files are ; g( p' E5 f3 Y
modified. , O2 m+ {! }5 f0 }4 z- p; m7 [$ X( f+ w; B2 Q" X/ `
Send suggestions to bkbirge@yahoo.com 0 L# }; p$ Y! [# {9 a
7 b) m9 W- S4 H% B& H; F
Updates will be posted periodically at the Mathworks User + p; z' r# Q# D' H( w) y2 u
Contributed Files website (www.mathworks.com) under the ) u4 k" q! f/ ^* a! WOptimization category.) U$ q) i- y, O
# R1 I/ u }6 X3 _- Z- GTo install:) F; D$ s- w; X1 V4 B3 i
Extract into any directory you want but make sure the matlab 2 F G: |1 x0 ~+ Z$ _ h# _path points to that directory and the subdirectories + y$ a4 w* ^. w) I0 m- `( f
'hiddenutils' and 'testfunctions'. " M9 V) c1 o" F o1 S5 G8 j% ^9 B
Enjoy! - Brian Birge : I% u) P l9 x" W2 A" M9 A" b u5 h6 t; ]* y
-------------------------------------------------------------$ Z! w& ^$ Y; A3 d- _% d d5 N
-------------------------------------------------------------% A8 T- t7 M) }( Z/ D$ p$ Y
4 Y' C4 }1 I3 M! H/ I# [% DINFO& P9 e7 ]# i5 A8 Q' f
Quick start: just type ... out = pso_Trelea_vectorized('f6',2) 3 H+ R4 C: A) i2 X" |) U+ x
and watch it work! - ]" Q5 G" h. t5 Z" e4 ^; l1 x! b% r( N& q/ t0 Z3 }( ^2 n5 w( @' R2 o' ]
This is a PSO toolbox implementing Common, Clerc 1", and 8 u7 w* B# ]* t! |0 Y* J+ [! G& _Trelea types along with an alpha version of tracking changing , `( D+ Z' z) o a1 L aenvironments. It can search for min, max, or 'distance' of 3 w, N$ F" I6 ^6 M) }$ \
user developed cost function. Very easy to use and hack with ( F' h$ z: p( b8 J7 v" R+ b, xreasonably good documentation (type help for any function and 2 x9 {7 k+ b5 j4 K u% M0 e: yit should tell you what you need) and will take advantage of 7 Q2 V! y3 N8 e8 j0 L; H
vectorized cost functions. It uses similar syntax to Matlab's9 I9 J+ K$ Y& S9 C' `
optimization toolbox. Includes a suite of static and dynamic $ [5 c V! c- W1 ~8 j
test functions. It also includes a dedicated PSO based neural & m6 d1 p1 O2 l; S5 J9 enetwork trainer for use with Mathwork's neural network toolbox./ t0 }! O, N& M, J1 A {6 O. U
3 B4 Y5 V6 v7 W2 e9 N4 u
Run 'DemoPSOBehavior' to explore the various functions, options, 2 @3 I5 U5 `; p* |and visualizations. / a7 Y/ h3 H' {* `8 I
) ^$ J0 I3 s% d C0 E3 g# TRun 'demoPSOnet' to see a neural net trained with PSO - g K- ~8 j* Y. ~' @* r
(requires neural net toolbox).% \% T* y$ l) v, e# W# [; X
4 i% D2 w# Y% G) s2 M( H# ~: E7 C0 w
This toolbox is in constant development and I welcome / s( e, t# i- w" r; ^; R, Hsuggestions. The main program 'pso_Trelea_vectorized.m' lists & `/ A" I+ C2 @2 k! F
various papers you can look at in the comments. / D6 ?: \5 M# t- y1 E/ B. K ?5 b+ |: r& ^- x
Usage ideas: to find a global min/max, to optimize training of % W& Y6 o$ x9 i! M2 d' Y
neural nets, error topology change tracking, teaching PSO, ( ^2 f! ^2 l6 o
investigate Emergence, tune control systems/filters, paradigm 1 `' @0 W0 `, h' s0 b3 c0 Ifor multi-agent interaction, etc. 1 s( ~0 D; j8 \; s0 i( S6 R ( }0 a3 @6 b) m T7 e------------------------------------------------------------- + J n6 [$ R- s1 \- C-------------------------------------------------------------' M7 m5 O! c, a! `- A' d
& A+ J' L$ d# r' C& k6 ^. u c+ t$ X9 T6 H5 d) {' B& W
Files included:6 J; ]( S" ~1 C& v. u1 g9 {# W
4 {& T( ]5 _0 D6 A6 I
" H ^7 y1 N8 G# U** in main directory: 1 l. {! i* z; v+ q1 O# N! z, \/ Q) V
0) ReadMe.txt - this file, duh . e; L/ g! M% E1 U1) A Particle Swarm Optimization (PSO) Primer.pdf - powerpoint converted to pdf presentation explaining the very basics of PSO , P) x5 }, y" o7 d. R; @/ p$ X! p2) DemoPSOBehavior.m - demo script, useful to see how the pso main function is called / ]' d+ o7 R! Z+ P. m3) 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+ X. j* \2 u2 f, [1 i
4) goplotpso.m - default plotting routine used by pso algorithm" B4 `3 c; u6 A5 o
5) pso_Trelea_vectorized.m - main PSO algorithm function, implements Common, Trelea 1&2, Clerc 1", and an alpha version of tracking environmental changes.6 c# k1 ]/ a) _+ E- Z- E$ }
& ]* Y! E& r, c
, G/ K$ r. u7 ]$ n2 L4 S% V; K/ q: X2 V# R. g8 G
** in 'hiddenutils'( g: |- g9 W9 }6 M: x$ a' O6 u( {
5 |2 K! L: |0 B6 P$ f3 ^
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 F6 c8 y6 W; b3 `! [
2) normmat.m - takes a matrix and reformats the data to fit between a new range, very flexible : r- W. ]7 M5 X- F2 o3) linear_dyn, spiral_dyn.m - helpers for the dynamic test functions listed in the 'testfunctions' directory& E9 Y% N/ ~. m9 J9 _
; P# ?% Z1 h5 Z: v# q5 G+ x/ r. v7 j$ `- k/ v+ F7 S
3 U. v0 ~( p4 U) M2 Q
** in 'testfunctions'. N5 ]4 U, C4 d4 y- m
* \% }# G+ p% j7 [" j1 f, [
A bunch of useful functions (mostly 2D) for testing. See help for each one for specifics. Here's a list of the names:0 n, r {$ W% K, @
0 \2 |' b/ B* g8 r# A! G
Static test functions, minima don't change w.r.t. time/iteration: 8 n, |/ v0 Y, s' b/ q" R 1) Ackley / U; W! D% A) S8 Q- u 2) Alpine7 B0 a8 o/ x- m% i+ M
3) DeJong_f2 8 e+ g( S7 \2 }, L, ]( z 4) DeJong_f3 ( R$ H5 J6 u- n( U/ c. ^! t: y8 ] 5) DeJong_f4& o5 }. _8 I3 H7 U! n* { X% _7 ~
6) Foxhole 9 o7 R& k# F9 C! I7 n 7) Griewank : E. g8 _' \: m; e2 y 8) NDparabola0 r A, ?6 u1 |2 x- c! X4 e( W
9) Rastrigin$ ?- d$ w' @- G5 o. _0 M' d# P
10) Rosenbrock / Z. X7 ], N6 \2 W& J g11) Schaffer f6( _1 b9 I, D5 ~6 m
12) Schaffer f6 modified (5 f6 functions translated from each other)- u7 f) J- D K$ I' Y% B3 i
13) Tripod( T% F E" R5 h7 T; h& u+ R1 l. `( Y
$ }2 }6 ^$ v3 h. C2 b0 rDynamic test functions, minima/environment evolves over time (NOT iteration, though easily modifed to do so): 8 Z* @. Q, S5 ^! P14) f6_bubbles_dyn * q3 P1 ]) D' A& ]1 H- J15) f6_linear_dyn8 E$ k- b6 @& _& I; O7 O1 \
16) f6_spiral_dyn$ ~ y" g. S8 _9 H0 a: ?' t0 ^
1 c* i. z: ?4 [1 ^
! B( L$ l2 o5 ~
7 J7 z8 X# s; n** in 'nnet' (all these require Matlab's Neural Net toolbox)4 \/ E3 `9 B# {3 y9 T C2 e
) u, s) a% K/ m- N( {) l; r 1) demoPSOnet - standalone demo to show neural net training& U. o$ F0 e. T3 C7 D# H
2) trainpso - the neural net toolbox plugin, set net.trainFcn to this2 W N! M( v& q7 g# c/ @/ E* G0 u! H
3) pso_neteval - wrapper used by trainpso to call the main PSO optimizer, this is the cost function that PSO will optimize' o C" j8 y, y+ C
4) goplotpso4net - default graphing plugin for trainpso, shows net architecture, relative weight indications, error, and PSO details on run " } o" ^. J3 k& T/ W 6 y- ~; q; B3 p! W x9 \9 |: u: ~$ X0 t% @