Skip to content
/ pso Public

This repository contains the standard Particle Swarm Optimization code (Matlab M-file) for optimizing the benchmark function.

License

Notifications You must be signed in to change notification settings

ElkmanY/pso

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Particle Swarm Optimization (PSO)

View pso - Particle Swarm Optimization on File Exchange

DOI: 10.13140/RG.2.2.16986.88000

This repository contains the standard Particle Swarm Optimization code (matlab M-file) for optimizing the benchmark function:

.
├── img
|   ├── benchmark.gif
|   ├── convergence-2d.png
|   ├── convergence-30d.png
|   ├── logo.jpg
|   └── trajectory.png
├── _config.yml
├── LICENSE
├── pso.m —— [function of particle swarm optimization]
├── README.md
└── test.m —— [a test for 'pso.m']

Usage

[f_best, x_best] = pso ( J, d, xlmt, n, T )

where

  • J is the function handle of the objective function
  • d is the dimension of the design variable
  • xlmt is the limit of the design variable; is a matrix with d rows and 2 column, and the first column contains lower limits of all dimension while the second upper ones.
  • n is the population size of the particle swarm
  • T is the maximum iteration times.
  • f_best is the fitness of the optimal solution
  • g_best is the optimal solution

Test

For instance, a benchmark Rastrigin is chosen for a test:

benchmark

Here, this benchmark is coded as a function handle

J = @(X) sum( X.^2 - 10*cos(2*pi*X) + 10 );

where X is a d-by-n matrix.

To run the test by executing

test.m

The test including two runs:

  • 30-d benchmark

    The results includes an optimal solution, its fitness and an execution time. Also, a plot of the convergence curve of fitness is shown.

    benchmark

  • 2-d benchmark

    The results includes an optimal solution, its fitness and an execution time. Also, a plot of the convergence curve of fitness, a plot of the trajectory of global optimal are shown.

    benchmark

    benchmark

Reference:

[1] Article: Particle swarm optimization (PSO). A tutorial

[2] Author's post (Chinese simplified): 粒子群优化及其Matlab实现

[3] Repo: BenchmarkFcns

About

This repository contains the standard Particle Swarm Optimization code (Matlab M-file) for optimizing the benchmark function.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages