PSOt, particle swarm optimization toolbox for matlab.9 r! ~# E$ U4 ]2 z
3 g K9 O/ R2 y7 R
May be distributed freely as long as none of the files are $ m7 [4 l0 e+ W) {& h8 {modified. 0 j2 d, b3 v5 X9 g s 0 r! t/ t# z1 m3 nSend suggestions to bkbirge@yahoo.com 1 C j% v1 m, u6 U8 i J5 i# t. ~1 w( n3 X3 Q7 K- Z
Updates will be posted periodically at the Mathworks User 1 [/ t( ~+ k8 t7 h( ^
Contributed Files website (www.mathworks.com) under the ! Z4 j- i& w+ _. Y7 @! f3 o
Optimization category.( x+ m4 T3 {# m8 f, T z
" ?3 I, i6 X& i& } U$ ~0 y; S t* V
To install: - @+ R: \$ r7 Z) m- @Extract into any directory you want but make sure the matlab 3 P: e6 l( K/ A! g& s kpath points to that directory and the subdirectories O, }6 \& b$ |7 t+ r, m: v
'hiddenutils' and 'testfunctions'. ; ^ O/ S, z. t0 D: h
5 a5 D) t; t: k8 Q' r9 f/ b1 b
Enjoy! - Brian Birge 1 m: T" { V: ^4 l; w% u . j' P0 _! \) z3 y------------------------------------------------------------- ; B8 W; \; k* E2 b$ ]------------------------------------------------------------- $ o( n$ }, T8 a; s" d1 H. O9 R n! k! d& B2 U3 X7 jINFO 4 }* K/ P! h( r- O2 X! nQuick start: just type ... out = pso_Trelea_vectorized('f6',2) ( o! C! p+ V+ H3 }/ Y7 J; Eand watch it work! % J# A/ P: I3 o4 F& n2 `8 f p7 O ]! y7 ]( y1 E5 b
This is a PSO toolbox implementing Common, Clerc 1", and 0 h" E$ _# X# K8 A7 D5 D5 n, uTrelea types along with an alpha version of tracking changing & V3 J/ T- G. {1 @5 i2 q denvironments. It can search for min, max, or 'distance' of + s: }% y- _$ k# G1 i. o2 q
user developed cost function. Very easy to use and hack with , b; W2 U* Y# v, e8 vreasonably good documentation (type help for any function and & _! p4 f/ {) V* i( J+ R. [it should tell you what you need) and will take advantage of ) t* q8 B1 p1 C1 z+ Evectorized cost functions. It uses similar syntax to Matlab's, j( }! }, k7 ~ s$ E
optimization toolbox. Includes a suite of static and dynamic 0 {1 x# Y! D& N3 I
test functions. It also includes a dedicated PSO based neural ! ]4 Y5 _6 b1 o" ]3 N' W4 anetwork trainer for use with Mathwork's neural network toolbox.; ^; ]1 B {( c" D2 U- \' \
- U, ~8 r4 ^3 {0 t8 tRun 'DemoPSOBehavior' to explore the various functions, options, , `, g" Q- x: a5 I( j+ Q
and visualizations. ; X B/ P1 w/ Y7 q& b1 ?- C
* ]% T0 @/ v* x E! Q2 s' u& iRun 'demoPSOnet' to see a neural net trained with PSO - N9 K+ y1 T! }0 `- G& e7 r& G) q7 Y(requires neural net toolbox)., m" P! O6 ]. B" Q% s9 ?
" H5 L- U7 |9 N- m% n+ O
7 z" A1 T t1 B3 n2 C) w: J
This toolbox is in constant development and I welcome 7 D* |# ^/ O* Z) v) K" ?& z5 Isuggestions. The main program 'pso_Trelea_vectorized.m' lists 7 o" X9 w0 u7 ]$ \9 f
various papers you can look at in the comments.+ a' |1 x2 s/ [1 S: V
' g7 r; {4 ~5 b& W
Usage ideas: to find a global min/max, to optimize training of $ H1 y4 s. ?. e0 }! }
neural nets, error topology change tracking, teaching PSO, . _2 U5 }" f' g8 h
investigate Emergence, tune control systems/filters, paradigm $ e: R/ y' ]* \& y# S2 G; u( pfor multi-agent interaction, etc. 0 c1 E( {, O# j, x# ~+ p7 o4 i m2 ]
------------------------------------------------------------- D3 F. w7 b) z$ v* o5 W-------------------------------------------------------------: P' t- A" _% U6 Z& @9 \/ H
7 R. f' W5 C. t j
( P. ^9 f& v" F# {) _6 yFiles included: 0 A4 R) Y' Q) b / p8 M2 [- x# u* Q2 W$ { 1 R$ p' o' h6 ?** in main directory: 6 ]; v6 O: I( `; J1 O 9 `$ Z! K; H) G0) ReadMe.txt - this file, duh ' v5 z7 C! L0 J! |5 `; i3 P1) A Particle Swarm Optimization (PSO) Primer.pdf - powerpoint converted to pdf presentation explaining the very basics of PSO9 B, ?6 l0 E; S' h) i7 A* ^+ ?
2) DemoPSOBehavior.m - demo script, useful to see how the pso main function is called & |# L' f/ n$ F( P. n! s; ]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 lot7 q; v* X8 c% I, }# D5 E
4) goplotpso.m - default plotting routine used by pso algorithm & c' C( e* }! a) j- q- s" z( n5) pso_Trelea_vectorized.m - main PSO algorithm function, implements Common, Trelea 1&2, Clerc 1", and an alpha version of tracking environmental changes.2 S4 P' B6 g j
5 [1 g$ w# s1 P; S
' p& F, G4 b- q- f: F8 i6 X( B
0 H; u. l* O% c$ n# N8 {$ }
** in 'hiddenutils'# d4 k2 x5 ~4 h' z3 u' M" b
* O' i; f3 B! @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 / M6 _5 l" J' O+ V {2) normmat.m - takes a matrix and reformats the data to fit between a new range, very flexible9 b) x+ x# }- s! x9 G
3) linear_dyn, spiral_dyn.m - helpers for the dynamic test functions listed in the 'testfunctions' directory# _% `8 f6 q& i5 i& j
4 p& r+ }, A3 X V g. U
: t% O' w$ ]. G" A3 s) `! l% u1 Q6 D d; g7 Y
** in 'testfunctions' : @: ~1 x. A. U. W$ U' B$ K! ?$ [0 Y& x1 W4 ^; f( v0 C6 t+ Y
A bunch of useful functions (mostly 2D) for testing. See help for each one for specifics. Here's a list of the names: ' L; ~0 l! w- c8 I2 D 1 s: O2 l/ j) tStatic test functions, minima don't change w.r.t. time/iteration: _9 d, J/ O7 A6 @1 v% S9 N: B; T1 a
1) Ackley / \' D' C' q) g- S 2) Alpine * y: M/ v. O, L8 m 3) DeJong_f2; ~% F: E$ N' x& n" Y
4) DeJong_f3 ; |; ^0 k0 e3 ` 5) DeJong_f4 2 p9 x% \' A' r# [% W& K 6) Foxhole9 v+ W5 Y0 G' t A2 B
7) Griewank. n% {4 \0 [* @$ i% [$ B/ d
8) NDparabola / \/ U+ n5 i$ n4 z+ @ 9) Rastrigin# }7 h* _9 a" H6 J1 P9 f" y
10) Rosenbrock. u9 A6 ?8 j, p7 Q+ r: a
11) Schaffer f62 S1 {# P- S3 g$ T4 q
12) Schaffer f6 modified (5 f6 functions translated from each other) ) ?0 d$ V3 }1 U1 h1 Z7 ^13) Tripod r" W& W. N4 t
: O5 P* _4 k8 ~- PDynamic test functions, minima/environment evolves over time (NOT iteration, though easily modifed to do so): + j i& b2 s5 R2 T& Y" ]3 r14) f6_bubbles_dyn 6 k5 h& u( O9 B0 {. l2 q C! }& S15) f6_linear_dyn ) [$ n' w# n' H- e! L16) f6_spiral_dyn ! x2 ^' _9 _) b! ~# T2 O% X( h 0 U1 Q& R( m. d+ x9 p- ]* j: ~2 v! B) Q, |/ U9 b! F' c. A
; n$ v0 V2 | X# G. _1 \( z+ x9 G! V6 {
** in 'nnet' (all these require Matlab's Neural Net toolbox)& Y3 k. X, O8 V# m9 Q
6 k9 A7 Q7 @3 I% P0 t 1) demoPSOnet - standalone demo to show neural net training5 U- P/ ?' i' W/ X7 I4 U t
2) trainpso - the neural net toolbox plugin, set net.trainFcn to this2 `9 `. ^/ K- v# P3 C4 C6 _6 `8 W
3) pso_neteval - wrapper used by trainpso to call the main PSO optimizer, this is the cost function that PSO will optimize + D0 o+ n |- V! I( S/ }2 w 4) goplotpso4net - default graphing plugin for trainpso, shows net architecture, relative weight indications, error, and PSO details on run! x+ ~; @$ y1 n
. N" V5 G3 g, b4 g0 q. ]
6 \$ r7 E B: E7 n; N