frallebini / particle-swarm-optimization

An implementation of particle swarm optimization and its application to the computer vision task of object detection via template matching

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Particle Swarm Optimization

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

Executable files

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.

    rastrigin rosenbrock

  • PSO applied to Object Detection by Template Matching.

    quarto_stato arduino

Reproducibility

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()

About

An implementation of particle swarm optimization and its application to the computer vision task of object detection via template matching


Languages

Language:Python 100.0%