Code Monkey home page Code Monkey logo

particle-swarm-optimization's Introduction

Particle Swarm Optimization

This is a python implementation of the Particle Swarm Optimization algorithm (PSO). In computation intelligence, PSO is a computational method to optimize an objective function. It is a stochastic searching method, which in contrast to many other optimization algorithms, it does not compute the gradient. It is also usually used in problems where the variables take uniform values.

linear-regression-gradient-descent

Variables

There are a couple of variables that needs to be initialized at the beginning of the algorithm:

  • n_pop: Population count
  • max_iter: Maximum amount of iterrations
  • v_max: Maximum velocity value
  • x(i): The particle's position
  • v(i): The particle's velocity
  • p(i): The particle's best position yet
  • f(i): The particle's best function value yet
  • s_best: The swarm's best particle's position
  • s_fbest: The swarm's best particle's best function value yet
  • f_best: The best objective value of the function

The best objective value of the function is not always present and is not used in all variations of the algorithm.

How it works

The way it works is by iteratively improving a candidate solution from a population of particles (swarm), by moving these particles around. Each of these particles are aware of their best yet position in the search space, as well as the swarm's best position yet is also known. Based on these assumptions, the swarm is expected to move towards the best solutions (positions). In order to update the position of each particle the following formulae is followed:

$$x[i] = x[i] + c1*r1*(p(i)-x(i))+c2*r2*(s_best-x(i))$$

The term c1*r1*(p(i)-x(i)) is known as personal coefficient while the term c2*r2*(s_best-x(i)) is known as social coefficient

  • c1 is the personal coefficient factor
  • c2 is the social coefficient factor
  • r1,r2 are random numbers from the uniform space [0,1]

particle-swarm-optimization's People

Contributors

sotostzam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.