A Python implementation of Particle Swarm Optimization (PSO) — as suggested in [BrattonKennedy2007] — and its application to the Computer Vision task of Object Detection based on Template Matching.
Tested with:
matplotlib 3.3.2
numpy 1.19.2
python 3.8.5
Run the files listed below to get the shown results. You will be asked whether to plot the animations or output textual information only.
-
PSO applied to non-convex artificial landscapes.
-
PSO applied to Object Detection by Template Matching.
PSO is a nondeterministic algorithm; however, for the sake of reproducibility of the results, the random seed
in
swarm.py
is set to a fixed value — 42
, for
obvious reasons.
Conversely, if you want to get a different outcome at each run, replace
self.rng = np.random.default_rng(seed=42)
with
self.rng = np.random.default_rng()