PSOt, particle swarm optimization toolbox for matlab. / w2 J) B: Q( c" n e7 o - s3 ?, N, _3 m( g# Z5 |& y+ XMay be distributed freely as long as none of the files are % A% O* W1 d% A, A" kmodified. 7 {# e) @1 E* U7 g3 j! ?1 \ 4 f' i, v: f" y0 D3 ?% D' x* FSend suggestions to bkbirge@yahoo.com $ {; Z4 O/ r! K5 M , w6 N, [0 c: s1 Y4 K4 ^* @0 }+ q' c2 IUpdates will be posted periodically at the Mathworks User 2 d% Y) n" r9 _4 h& r0 N# nContributed Files website (www.mathworks.com) under the 1 U' X/ `& b4 B! w8 ^, a0 R) g# XOptimization category. ) x# x$ R2 S8 T( ~+ c- J8 E4 N/ _ * j1 i2 S4 t' E- hTo install: 3 x& r5 F7 `- z3 r2 eExtract into any directory you want but make sure the matlab / |3 j! S4 F5 S% I; v. f; P5 L/ x0 gpath points to that directory and the subdirectories 0 H8 J/ M6 j- s& H# K& L, ]'hiddenutils' and 'testfunctions'. ) U4 J6 U, Q" i2 v# X4 t9 O# n& r7 H) T1 a2 t: Z
Enjoy! - Brian Birge ( g! W$ e( c3 D' r* g9 M" f8 j# f$ S5 h u; e" I: i2 k2 V* b
------------------------------------------------------------- # A" C/ [2 [ R4 d) T-------------------------------------------------------------2 ^- R ~) n) n& M+ Q7 B! e
* v' A3 W, m- N, g! h
INFO ) |% i6 Z) C8 R# D# E. ]* @Quick start: just type ... out = pso_Trelea_vectorized('f6',2) 1 [, k2 X$ L' nand watch it work! 2 f$ m$ D4 W( m$ {: s5 Q4 B. l+ U, J0 P' k) y: \
This is a PSO toolbox implementing Common, Clerc 1", and 4 P9 R" S6 {% [. B9 kTrelea types along with an alpha version of tracking changing" p4 ^3 q) b& \( L+ x
environments. It can search for min, max, or 'distance' of : a: c5 _/ _4 v- ~3 s0 U: h9 x, ?
user developed cost function. Very easy to use and hack with & N+ M2 B9 u* D- s7 Ureasonably good documentation (type help for any function and1 i( E9 R" V% w9 v3 |- G
it should tell you what you need) and will take advantage of . J- P |4 j8 g9 L7 E: t( u0 Fvectorized cost functions. It uses similar syntax to Matlab's % y* q* S9 G0 I, w& @0 Soptimization toolbox. Includes a suite of static and dynamic 1 ]5 l$ n+ c. s9 Z! Q& ^. S2 z
test functions. It also includes a dedicated PSO based neural 1 I }7 F& S1 Q+ }network trainer for use with Mathwork's neural network toolbox. 0 t! _/ M8 _' j3 t/ ~ 2 {8 U4 k* z% y2 C: O% W: X7 d0 gRun 'DemoPSOBehavior' to explore the various functions, options, + b! `2 E; C" L5 ~" Q7 S" _
and visualizations. D0 j; o% |; ?) x
. F5 ~. ^' |- \0 k, U$ _1 E" ?Run 'demoPSOnet' to see a neural net trained with PSO 8 W& I) k7 b% ~; d. W- C% ~
(requires neural net toolbox).* k* S, y' o; g
3 L1 [- S! h8 c- p
) e0 p$ E* n% q" w/ A* dThis toolbox is in constant development and I welcome 1 g) P' |2 Y+ ?; z, jsuggestions. The main program 'pso_Trelea_vectorized.m' lists 9 {1 ` l' {9 r. n% F
various papers you can look at in the comments.$ b# v- n3 |- p$ r6 b |+ c9 W
; h1 Z/ `, o% Q2 l% G3 U" B
Usage ideas: to find a global min/max, to optimize training of 0 k8 o* ]# j+ j# {3 t' ]
neural nets, error topology change tracking, teaching PSO, , J) o# v: u. x4 o; l+ m$ e
investigate Emergence, tune control systems/filters, paradigm 2 v4 l+ N- K& [+ J+ w" m
for multi-agent interaction, etc. : k3 E+ m. C. Z0 i5 [1 A" e- ~4 O
------------------------------------------------------------- ; T( x _/ K) n. B-------------------------------------------------------------( G" f% C% r4 U; \2 C7 e% M0 U$ C
" p# w# l# [( }7 m0 n" D9 K
- o" o) K% {) w: Q1 M
Files included: / j- H+ t$ ^( ~& h; \# _ . }9 ?; N' _, G% P, ~/ `: U5 [ 9 ~- z5 C- d* G+ i) [# ~** in main directory: % p( u1 K( \) K# V3 P 1 U$ S `7 b' R/ z( m, d0) ReadMe.txt - this file, duh6 T) ~1 g4 l1 t9 P0 I; v
1) A Particle Swarm Optimization (PSO) Primer.pdf - powerpoint converted to pdf presentation explaining the very basics of PSO- B& ^( G2 I& P _# i& ]
2) DemoPSOBehavior.m - demo script, useful to see how the pso main function is called) R# k3 x* H0 T0 x0 U& M. @; f
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 lot2 Y& E9 C/ C' O6 x
4) goplotpso.m - default plotting routine used by pso algorithm) |9 A* K4 ~, H0 e
5) pso_Trelea_vectorized.m - main PSO algorithm function, implements Common, Trelea 1&2, Clerc 1", and an alpha version of tracking environmental changes.5 L1 }- M/ i5 ~1 H
6 k6 S' x4 U* s, f) E6 ?' I
8 S7 ^4 j) K6 j0 d0 ? 9 M" `2 T: P* K! i+ z" B3 j** in 'hiddenutils'/ M- E3 J. d5 \* |- ]% ?
, L: U; H( v" g" z- c; q
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 & q6 A3 e& p4 d# f2) normmat.m - takes a matrix and reformats the data to fit between a new range, very flexible* [9 I. d3 [, i" z) `6 F
3) linear_dyn, spiral_dyn.m - helpers for the dynamic test functions listed in the 'testfunctions' directory z: m) ~. T' h( u, y0 l# [- W
* ]! |, {2 h- b; z: v/ ~6 M" T3 m
[8 h' ~( ?* e5 E4 q, y; ?: j
D6 J q# {$ h% s6 s** in 'testfunctions' & {8 f1 @$ j2 ` 6 g4 K( o W9 b; m. T9 {9 \' xA bunch of useful functions (mostly 2D) for testing. See help for each one for specifics. Here's a list of the names: 5 }/ u c7 D& u) O7 x0 \% F7 Z. |5 l, J6 U$ S4 w
Static test functions, minima don't change w.r.t. time/iteration:; @0 {7 G7 T) v, ]
1) Ackley6 ?. @: W2 v4 G3 i9 l
2) Alpine " A {! s, \# h/ \ 3) DeJong_f2) ?. |$ `& X2 d: n0 Q
4) DeJong_f36 Y$ o' b. s) D- P* T
5) DeJong_f4 : m2 Q3 q' E2 B: J/ M 6) Foxhole" U3 g9 X. a7 W
7) Griewank- g# L$ E$ ~; }8 m% A/ j& \2 C0 @
8) NDparabola" p# J( ^' Q0 V
9) Rastrigin. l1 y9 T! I8 x- A$ z4 d
10) Rosenbrock# S v( H% ^: b/ w- _9 M
11) Schaffer f6 U+ s# u6 \9 I; n12) Schaffer f6 modified (5 f6 functions translated from each other) ' z- W, A, P6 L# {# j% c/ w6 ~13) Tripod % b( p/ s* @+ w( L % A5 Q: @+ V2 \% Y% l1 U1 W( Q9 oDynamic test functions, minima/environment evolves over time (NOT iteration, though easily modifed to do so):4 Y: Z0 w! S( V5 f( \0 G1 B/ r
14) f6_bubbles_dyn 2 U5 W) d2 n, f+ b- _, E! L15) f6_linear_dyn+ P# `! X$ v% T) G) d" _* S
16) f6_spiral_dyn# d4 y' p, y- r1 j
. ?5 q5 M$ N' U" w F1 H
5 H4 V1 o9 u5 Y5 B- `* ?% K/ P \1 w/ T0 E, w, v
** in 'nnet' (all these require Matlab's Neural Net toolbox)( R, d ] I9 z! M3 Y
: R/ u/ `/ J% f* F0 w+ W2 e- x" } 1) demoPSOnet - standalone demo to show neural net training 1 V/ l9 X/ {% ?8 Q& I 2) trainpso - the neural net toolbox plugin, set net.trainFcn to this 2 O( v+ d- o9 E& I3 y/ h4 P 3) pso_neteval - wrapper used by trainpso to call the main PSO optimizer, this is the cost function that PSO will optimize: ?* x! ]4 \1 J5 M+ U+ M
4) goplotpso4net - default graphing plugin for trainpso, shows net architecture, relative weight indications, error, and PSO details on run # G4 h0 B6 _/ z# E5 r3 _/ s, W : L! W! x3 [$ y$ W g5 ]! T | o" J# [( E