PSOt, particle swarm optimization toolbox for matlab. / H' u3 J9 `* z* U1 F* ^) u+ l( L4 U) j+ Z6 h( O% n. K
May be distributed freely as long as none of the files are , p5 Y7 L1 Q4 n: q) }9 C
modified. * m6 S% o2 `) O% h# X. c1 J
! v x8 G9 t- \
Send suggestions to bkbirge@yahoo.com # w4 n! j: P' E( R" |
% {/ V, y! Y3 \$ W G- \Updates will be posted periodically at the Mathworks User 7 r! t' Y5 l X8 g, {Contributed Files website (www.mathworks.com) under the / P4 i/ }& ?) }4 Y m+ u
Optimization category. 1 w" i) I' {5 V/ D , Z* d% `+ G5 tTo install: 1 _1 I. N9 b+ F. Q i- u4 {Extract into any directory you want but make sure the matlab # ^( J' s, F' U0 E
path points to that directory and the subdirectories : E* F3 Y8 o2 c+ R% C'hiddenutils' and 'testfunctions'. # y; C) A" ?$ a, S! I& f2 V- `! O' Q0 N& w- l" O3 e
Enjoy! - Brian Birge. S7 s' I7 e ~9 Q; v* _
- ~4 X5 Q7 `9 p0 @0 ?" J. t/ U b# J# K7 p-------------------------------------------------------------& g* e. j7 s9 ~3 h5 B
-------------------------------------------------------------$ r5 r; g+ K+ q3 \" W/ w! Z/ r; [
- `! _! F- ?/ g# Z [
INFO3 A _" H Q, R' l5 ?% m
Quick start: just type ... out = pso_Trelea_vectorized('f6',2) ( R" K( r6 Q6 s' Vand watch it work! 0 L0 l0 E5 v; e7 \, v % ?# O# P3 a8 t. c$ ]This is a PSO toolbox implementing Common, Clerc 1", and 2 ~8 v; f4 W0 C! h$ m
Trelea types along with an alpha version of tracking changing 6 U5 }4 ^% N" x) Tenvironments. It can search for min, max, or 'distance' of 1 }( N2 [! ^: m5 }8 v; Auser developed cost function. Very easy to use and hack with 3 Z4 }' _1 X8 |; }reasonably good documentation (type help for any function and " f2 C p [4 X; Ait should tell you what you need) and will take advantage of * U$ u5 X: A3 r7 k" Tvectorized cost functions. It uses similar syntax to Matlab's 7 ~2 z' w" _1 l, B6 q5 xoptimization toolbox. Includes a suite of static and dynamic ( ^& |: J2 c0 L. C% Vtest functions. It also includes a dedicated PSO based neural 8 ]# K- Z0 ~0 A7 o( _network trainer for use with Mathwork's neural network toolbox. . {" \! V* S# a. v' F( S" L ) w: W( n* Y' M& wRun 'DemoPSOBehavior' to explore the various functions, options, " N. @9 A% m! n9 {1 T/ k+ p0 }and visualizations. . r( x7 g! U! u' S. A5 R 5 A0 ?/ D& c# D) I# @: w URun 'demoPSOnet' to see a neural net trained with PSO ) A* F2 b/ Z/ r9 w/ D, [) Y; R6 x(requires neural net toolbox).7 e6 i" R% G' ^( F9 z
! l5 i Z- b4 N, J7 i3 t' j1 ]& m0 _/ {, o0 S6 s3 D5 I
This toolbox is in constant development and I welcome , o% C0 p6 ~0 c7 l/ T' Wsuggestions. The main program 'pso_Trelea_vectorized.m' lists % l4 V. c3 b, P6 I- evarious papers you can look at in the comments. 2 S" u) L z x4 s 2 _; W; S+ @+ A9 eUsage ideas: to find a global min/max, to optimize training of " E T; J/ J- T* Ineural nets, error topology change tracking, teaching PSO, 9 w. ?9 j% s6 g. E
investigate Emergence, tune control systems/filters, paradigm ; ^5 j3 T/ I' ^: A; X, ffor multi-agent interaction, etc. ) E6 p1 r7 V' F8 H( ^' h* J1 Y/ v% `4 M: s4 M
-------------------------------------------------------------" r+ n9 r. t( R
------------------------------------------------------------- [' u2 S- D- Q& Y) q Y H6 G5 s0 i- D/ w) ^1 ^0 Z+ J/ t. Y! G8 T5 ?
4 g% O% Q- l, c1 j. F
Files included: M6 o/ g2 k3 J0 D+ W& V9 P3 C$ s * @$ E% `2 q4 T+ G. y7 V4 {2 j) p s/ T4 ^, b/ W
** in main directory: 3 a! n; X! ^7 w. o- T$ L! s) l* A: t) s4 J: D5 w4 d1 l, f+ V
0) ReadMe.txt - this file, duh $ E% J! @5 p2 ?% M! Z$ i: [1) A Particle Swarm Optimization (PSO) Primer.pdf - powerpoint converted to pdf presentation explaining the very basics of PSO1 s( W; Z( l' c9 g/ ?6 {
2) DemoPSOBehavior.m - demo script, useful to see how the pso main function is called6 Z- `! @% d. ~+ |% b' E# T7 I$ {
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 3 c. R# i/ M, R7 [4) goplotpso.m - default plotting routine used by pso algorithm0 {; `' H) m2 g0 N. |- B+ L
5) pso_Trelea_vectorized.m - main PSO algorithm function, implements Common, Trelea 1&2, Clerc 1", and an alpha version of tracking environmental changes.% p D! N: r, ?9 P0 W+ s$ ?0 E
, X6 L( W. U7 ?3 V& ?3 k- Z2 A) f ; D/ J* d9 R9 S9 A; K- @& W- W$ D* R. T1 M
** in 'hiddenutils'" Z6 ]* b9 w5 R$ Z& u5 _
$ h8 E2 h; E) P0 L5 z! B0 r% z
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 ; {$ ?3 M) r5 I# [4 Y' Z9 y2) normmat.m - takes a matrix and reformats the data to fit between a new range, very flexible! }0 Q3 K: C2 R" T* o- P
3) linear_dyn, spiral_dyn.m - helpers for the dynamic test functions listed in the 'testfunctions' directory ! H g- C, w% d' a0 B8 Y E ' q' o, V& \9 P% f) u" A1 _3 ^: M5 \/ m5 m
. C" ^/ R9 q8 _0 \/ u* _. }** in 'testfunctions') u+ N/ y- F$ J& O
7 ?( L0 J: g3 P _A bunch of useful functions (mostly 2D) for testing. See help for each one for specifics. Here's a list of the names: . p; R9 W8 K$ e # y5 o: f% v$ ]' `# YStatic test functions, minima don't change w.r.t. time/iteration: 2 B6 N9 b1 r- `- G8 L 1) Ackley/ Q" h5 w& J3 y- j6 |9 i
2) Alpine& f: Y/ |! }" L' t* G$ A
3) DeJong_f2 ) F# f \8 W2 f7 U) D; \ 4) DeJong_f3: V1 a# g4 N {5 s2 x- T5 q0 k/ p+ D
5) DeJong_f49 ^2 W6 V9 j6 k; k% o i$ e3 Y
6) Foxhole ' [ d, m1 ]5 n" V 7) Griewank 6 ]$ L# w2 n* u! d P- F 8) NDparabola 5 F+ F) o- l! d& Z' l 9) Rastrigin o* e, [3 l& S" O" {- n* K10) Rosenbrock 1 h# b( H, g, v# i11) Schaffer f60 q, k1 k9 z! ]" l' U
12) Schaffer f6 modified (5 f6 functions translated from each other) + q& H6 N; C0 |13) Tripod0 z! ~9 n% a- F9 r1 n+ a
! Q) k; _. n' r; z# p; hDynamic test functions, minima/environment evolves over time (NOT iteration, though easily modifed to do so): $ b4 t4 d! e- M6 X. K& J14) f6_bubbles_dyn ' M! l* G. G4 N15) f6_linear_dyn 6 j. @# P2 r4 W16) f6_spiral_dyn0 V; V8 K! |# P$ ]
& F( b; U. M8 m5 g1 ]; j. g. x6 P0 I) @7 M
0 r3 K6 s* `# [/ p* e** in 'nnet' (all these require Matlab's Neural Net toolbox) 4 E$ r, r2 f7 ~. D/ v4 j( k1 Y( M' U( p/ |" x% v
1) demoPSOnet - standalone demo to show neural net training9 \+ N/ z9 a; Q* Q% r* M: m
2) trainpso - the neural net toolbox plugin, set net.trainFcn to this/ b- g3 Q* `$ b8 }
3) pso_neteval - wrapper used by trainpso to call the main PSO optimizer, this is the cost function that PSO will optimize5 r! N# [$ A9 \5 b0 t; b
4) goplotpso4net - default graphing plugin for trainpso, shows net architecture, relative weight indications, error, and PSO details on run 0 r% K6 n; M3 E, ]1 @ r7 E* z 7 s+ O0 k$ e; W B# ^7 @$ |5 O6 o2 ]