PSOt, particle swarm optimization toolbox for matlab. 1 P; c" u6 m9 U5 Q* h: j. F# V: W, }9 V5 b2 D! n
May be distributed freely as long as none of the files are ) @2 n% ]% B8 c; ?+ k
modified. : P. w7 T* S: M$ l. f1 r6 m- N 8 y6 G |+ q$ p- ]) @Send suggestions to bkbirge@yahoo.com $ e3 Y, ~) r; v: i* i3 v " R3 r# @' [: G' v; R5 K4 [! ~Updates will be posted periodically at the Mathworks User ; h8 s+ Z0 L/ } E
Contributed Files website (www.mathworks.com) under the % {/ ^. L0 Q! V, O2 a
Optimization category.3 V5 C; s! ^5 d; y+ @5 a
9 ~* T* h& y, k7 wTo install:- {3 r8 }( L: i/ L
Extract into any directory you want but make sure the matlab - [7 H2 O% t4 K/ G& E( L( \& Qpath points to that directory and the subdirectories 3 O) x, z3 B" b, j
'hiddenutils' and 'testfunctions'. , M( o. H% q8 S , ^: t! R# Y+ y# ?) ~( [! OEnjoy! - Brian Birge2 o# X* l# R# t; I# g) k
, E9 i R! a+ t& ^/ O( n-------------------------------------------------------------' f6 s/ K4 E( {% r) e0 U
-------------------------------------------------------------6 J8 n; |9 g! N: J" A
# C- p, T% o F+ e1 O
INFO% K: k) t/ A* o% I7 `
Quick start: just type ... out = pso_Trelea_vectorized('f6',2) ! y5 u/ a" p6 K) @7 I$ a
and watch it work! & p2 ?2 o8 t7 M/ l% X4 R/ |: p. i" e
This is a PSO toolbox implementing Common, Clerc 1", and ' M: ~7 l* j% w1 V @
Trelea types along with an alpha version of tracking changing % `" ]) h5 c* Z/ T! x) e7 tenvironments. It can search for min, max, or 'distance' of ) |: h! B8 L+ Fuser developed cost function. Very easy to use and hack with , ~" g7 p3 U- v6 ^7 P9 Y+ K% Q* |8 @
reasonably good documentation (type help for any function and 3 a# T# z( ~2 `9 P bit should tell you what you need) and will take advantage of 6 D. o+ b; F1 k# @# yvectorized cost functions. It uses similar syntax to Matlab's : C- ~6 a& S! T; r/ P1 goptimization toolbox. Includes a suite of static and dynamic 0 j$ Q' k: T z& ~2 d: u) h1 V, |test functions. It also includes a dedicated PSO based neural , q& k! A2 t$ Y' C
network trainer for use with Mathwork's neural network toolbox. # Y; J0 H& f- g; R* K $ J! \: G: u! j3 a/ w9 b# }0 N4 RRun 'DemoPSOBehavior' to explore the various functions, options, 3 o8 m/ R* O; I, n/ L8 }
and visualizations. + y2 S; ?( _6 q8 M6 o: J
0 f. _, j7 V& e! z
Run 'demoPSOnet' to see a neural net trained with PSO 4 t. }1 ^% v$ P% ^9 g/ C4 y0 H(requires neural net toolbox). ; M+ ^. Y0 k8 V. O, N 2 l' C/ ^) Q6 X/ P P1 [- x4 F0 T% I
This toolbox is in constant development and I welcome # ~6 } s( U; w. Lsuggestions. The main program 'pso_Trelea_vectorized.m' lists 8 }: [' u- y2 w4 K. E( Avarious papers you can look at in the comments.$ v5 @4 R h) X1 t1 C! U: e
+ v' J! P2 h7 H0 q3 o t5 Q
Usage ideas: to find a global min/max, to optimize training of 2 O. ~! I& ^7 X3 d+ t
neural nets, error topology change tracking, teaching PSO, + N, k! d& i9 n9 ginvestigate Emergence, tune control systems/filters, paradigm 3 ~- B" d2 P& G, \" Y
for multi-agent interaction, etc.4 S$ `5 w/ h6 ^; [) \7 Q4 X# I7 K
& U! g2 Z" ?+ Z/ }& s1 b
------------------------------------------------------------- - _' z: w3 J2 f7 x-------------------------------------------------------------5 P/ }: Z) p1 r; ?
8 e9 F4 V) n6 Y$ A% R6 r3 o! ^ 0 C* |4 ~0 Z/ @9 K: O3 V4 y; ]Files included:& {" m; _7 o5 m
4 k$ r' p; J* M) `$ \7 J4 g- O
* C# @7 ]2 k3 [+ O
** in main directory:/ N. X) t# g2 e
- c$ F. V3 K& a' A# v3 B% y0) ReadMe.txt - this file, duh ' m O1 b$ O. U1) A Particle Swarm Optimization (PSO) Primer.pdf - powerpoint converted to pdf presentation explaining the very basics of PSO+ `0 m J; \- y3 ^: ?2 T
2) DemoPSOBehavior.m - demo script, useful to see how the pso main function is called - Y) {: P( S2 d; A5 y3) 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" F# t4 l2 W5 s
4) goplotpso.m - default plotting routine used by pso algorithm$ e9 D" w8 }! b6 K
5) pso_Trelea_vectorized.m - main PSO algorithm function, implements Common, Trelea 1&2, Clerc 1", and an alpha version of tracking environmental changes.8 A2 z# I4 }* P ]! f9 Z- z/ C
7 B* v/ C! [% }4 T$ l
) C! g* Y5 F/ D
$ c- A6 X8 P* x4 w
** in 'hiddenutils' , ~5 @7 t8 M6 {" Z) S% x8 M8 q6 H/ a1 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 4 f& }+ p- M% v9 K2) normmat.m - takes a matrix and reformats the data to fit between a new range, very flexible5 k- B/ E( }/ l9 K4 u! T
3) linear_dyn, spiral_dyn.m - helpers for the dynamic test functions listed in the 'testfunctions' directory W7 Q6 c! F; a: Q0 z
# J1 }& [3 _2 R1 f6 H / S/ V/ I$ y. P5 v( s) E 9 S8 Q; R* U& r6 Z+ V** in 'testfunctions'- j6 X: J+ f7 J6 f J, p
" g2 s5 ~; V+ M9 |! a
A bunch of useful functions (mostly 2D) for testing. See help for each one for specifics. Here's a list of the names: N2 {& J5 Z( N$ r. s3 x8 I% ~- r9 S; o5 B5 k
Static test functions, minima don't change w.r.t. time/iteration: + o7 N9 J; X8 d( }" o4 h! J 1) Ackley/ T# H% N& X! O( t% f1 D: B% c, q- v
2) Alpine % G7 s& J5 x3 {- T! Z 3) DeJong_f2 8 Y/ \! ?! e" p! O6 u" s 4) DeJong_f3' ~. Q" v: R3 ] M
5) DeJong_f4. ?* H5 ?* E6 T, t( y, k
6) Foxhole8 d& @* f4 f* v6 V* |4 \8 L: C
7) Griewank 0 I. P/ _# c2 A! O 8) NDparabola: `5 ]9 s/ K- i2 g+ [" x9 c& X
9) Rastrigin+ T: L6 j1 o4 q/ `
10) Rosenbrock! g9 t9 O% W$ a& L
11) Schaffer f6' _$ j' V/ r) v A0 K
12) Schaffer f6 modified (5 f6 functions translated from each other)4 N; f( d- Y3 q2 \
13) Tripod- O& _* ?, j! B8 b: u
1 D, G; O. |5 ]" A' Y) F" r
Dynamic test functions, minima/environment evolves over time (NOT iteration, though easily modifed to do so):( g0 g" m3 E; `5 ]8 k
14) f6_bubbles_dyn " z4 S) m( K0 c' h6 P15) f6_linear_dyn & K Y2 n }5 Y" {6 V3 W: K16) f6_spiral_dyn $ q+ w" s7 w# {- _+ ]9 L9 d2 h3 a4 q* G: V g! g7 A
1 l) h" p2 }4 ]
7 x5 u) q2 f$ H5 p9 d** in 'nnet' (all these require Matlab's Neural Net toolbox). ]( h9 N: Y8 \: B
3 m* n& ^+ I5 Z" a6 i; G7 S( D
1) demoPSOnet - standalone demo to show neural net training) `" [2 o9 i* \
2) trainpso - the neural net toolbox plugin, set net.trainFcn to this/ I# P) w( a* R+ c( n
3) pso_neteval - wrapper used by trainpso to call the main PSO optimizer, this is the cost function that PSO will optimize) I! u V, Y0 l' l
4) goplotpso4net - default graphing plugin for trainpso, shows net architecture, relative weight indications, error, and PSO details on run, `3 p, A2 ~& k3 E p l
9 k& ]) l8 B+ [