Lably
Skip to content

Particle swarm optimization

Iterative simulation method

  • 14 min read
  • 5 chapters

Related on Lably

Through Mathematical optimization, Feasible region and Point particle

PSO is originally attributed to Kennedy and Eberhart and was first intended for simulating social behaviour, as a stylized representation of the movement of organisms in a bird flock or fish school, or the evolution of attitudes in a human population. Simulation of principles of social behavior was observed to be capable of solving hard mathematical problems. The book by Kennedy and Eberhart describes many philosophical aspects of PSO and swarm intelligence. An extensive survey of PSO applications is made by Poli. In 2017, a comprehensive review on theoretical and experimental works on PSO was published by Bonyadi and Michalewicz.

PSO is a metaheuristic as it makes few or no assumptions about the problem being optimized and can search very large spaces of candidate solutions. Also, PSO does not use the gradient of the problem being optimized, which means PSO does not require that the optimization problem be differentiable as is required by classic optimization methods such as gradient descent and quasi-newton methods. However, metaheuristics such as PSO do not guarantee an optimal solution is ever found.

Algorithm

A basic variant of the PSO algorithm is initialized with a connected population (called a swarm) of candidate solutions (called particles). A candidate solution is a vector of numeric values which can be considered as coordinates of a point in a search space; as an iteratively moving point it can be conceptualized as a particle. The particles move around in the search-space according to a few simple formulae. Each particle has some neighbors it is connected to, where the neighborhood may be a few or all other population members. The next position of a particle is stochastically determined by its own best-so-far position in the search space as well as the particle's best neighbor's best-so-far position. When an improved position is discovered - one that produces a better result in the objective function - the best-so-far position of the particle is updated. The process is repeated and by doing so it is expected, but not guaranteed, that a satisfactory solution will eventually be discovered.

Formally, let f: ℝn → ℝ be the cost function which must be minimized. The function takes a candidate solution as an argument in the form of a vector of real numbers and produces a real number as output which indicates the objective function value of the given candidate solution. The gradient of f is not known. The goal is to find a solution a for which f(a) ≤ f(b) for all b in the search-space, which would mean a is the global minimum.

Let S be the number of particles in the swarm, each having a position xi ∈ ℝn in the search-space and a velocity vi ∈ ℝn. Let pi be the best known position of particle i and let g be the best known position of the particle's neighborhood. A basic PSO algorithm to minimize the cost function is then:

<b id="mwdg">for</b> each particle <i id="mwdw">i</i><span typeof="mw:Entity" id="mweA"> </span>=<span typeof="mw:Entity" id="mweQ"> </span>1,<span typeof="mw:Entity" id="mweg"> </span>...,<span typeof="mw:Entity" id="mwew"> </span><i id="mwfA">S</i> <b id="mwfQ">do</b> Initialize the particle's position with a <a rel="mw:WikiLink" href="./Uniform_distribution_(continuous)" title="Uniform distribution (continuous)" class="mw-redirect" id="mwfg">uniformly distributed</a> random vector: <b id="mwfw">x</b><sub id="mwgA">i</sub><span typeof="mw:Entity" id="mwgQ"> </span>~<span typeof="mw:Entity" id="mwgg"> </span><i id="mwgw">U</i>(<b id="mwhA">b<sub id="mwhQ">lo</sub></b>,<span typeof="mw:Entity" id="mwhg"> </span><b id="mwhw">b<sub id="mwiA">up</sub></b>) Initialize the particle's best known position to its initial position: <b id="mwiQ">p</b><sub id="mwig">i</sub><span typeof="mw:Entity" id="mwiw"> </span>←<span typeof="mw:Entity" id="mwjA"> </span><b id="mwjQ">x</b><sub id="mwjg">i</sub> <b id="mwjw">if</b> <i id="mwkA">f</i>(<b id="mwkQ">p</b><sub id="mwkg">i</sub>) < <i id="mwkw">f</i>(<b id="mwlA">g</b>) <b id="mwlQ">then</b> update the swarm's best known position: <b id="mwlg">g</b><span typeof="mw:Entity" id="mwlw"> </span>←<span typeof="mw:Entity" id="mwmA"> </span><b id="mwmQ">p</b><sub id="mwmg">i</sub> Initialize the particle's velocity: <b id="mwmw">v</b><sub id="mwnA">i</sub><span typeof="mw:Entity" id="mwnQ"> </span>~<span typeof="mw:Entity" id="mwng"> </span><i id="mwnw">U</i>(-|<b id="mwoA">b<sub id="mwoQ">up</sub></b>-<b id="mwog">b<sub id="mwow">lo</sub></b>|,<span typeof="mw:Entity" id="mwpA"> </span>|<b id="mwpQ">b<sub id="mwpg">up</sub></b>-<b id="mwpw">b<sub id="mwqA">lo</sub></b>|) <b id="mwqQ">while</b> a termination criterion is not met <b id="mwqg">do</b>: <b id="mwqw">for</b> each particle <i id="mwrA">i</i><span typeof="mw:Entity" id="mwrQ"> </span>=<span typeof="mw:Entity" id="mwrg"> </span>1,<span typeof="mw:Entity" id="mwrw"> </span>...,<span typeof="mw:Entity" id="mwsA"> </span><i id="mwsQ">S</i> <b id="mwsg">do</b> <b id="mwsw">for</b> each dimension <i id="mwtA">d</i><span typeof="mw:Entity" id="mwtQ"> </span>=<span typeof="mw:Entity" id="mwtg"> </span>1,<span typeof="mw:Entity" id="mwtw"> </span>...,<span typeof="mw:Entity" id="mwuA"> </span><i id="mwuQ">n</i> <b id="mwug">do</b> Pick random numbers: <i id="mwuw">r</i><sub id="mwvA">p</sub>, <i id="mwvQ">r</i><sub id="mwvg">g</sub> ~ <i id="mwvw">U</i>(0,1) Update the particle's velocity: <b id="mwwA">v</b><sub id="mwwQ">i,d</sub><span typeof="mw:Entity" id="mwwg"> </span>←<span typeof="mw:Entity" id="mwww"> </span>w <b id="mwxA">v</b><sub id="mwxQ">i,d</sub> + φ<sub id="mwxg">p</sub> <i id="mwxw">r</i><sub id="mwyA">p</sub> (<b id="mwyQ">p</b><sub id="mwyg">i,d</sub>-<b id="mwyw">x</b><sub id="mwzA">i,d</sub>) + φ<sub id="mwzQ">g</sub> <i id="mwzg">r</i><sub id="mwzw">g</sub> (<b id="mw0A">g</b><sub id="mw0Q">d</sub>-<b id="mw0g">x</b><sub id="mw0w">i,d</sub>) Update the particle's position: <b id="mw1A">x</b><sub id="mw1Q">i</sub><span typeof="mw:Entity" id="mw1g"> </span>←<span typeof="mw:Entity" id="mw1w"> </span><b id="mw2A">x</b><sub id="mw2Q">i</sub> + <b id="mw2g">v</b><sub id="mw2w">i</sub> <b id="mw3A">if</b> <i id="mw3Q">f</i>(<b id="mw3g">x</b><sub id="mw3w">i</sub>) < <i id="mw4A">f</i>(<b id="mw4Q">p</b><sub id="mw4g">i</sub>) <b id="mw4w">then</b> Update the particle's best known position: <b id="mw5A">p</b><sub id="mw5Q">i</sub><span typeof="mw:Entity" id="mw5g"> </span>←<span typeof="mw:Entity" id="mw5w"> </span><b id="mw6A">x</b><sub id="mw6Q">i</sub> <b id="mw6g">if</b> <i id="mw6w">f</i>(<b id="mw7A">p</b><sub id="mw7Q">i</sub>) < <i id="mw7g">f</i>(<b id="mw7w">g</b>) <b id="mw8A">then</b> Update the swarm's best known position: <b id="mw8Q">g</b><span typeof="mw:Entity" id="mw8g"> </span>←<span typeof="mw:Entity" id="mw8w"> </span><b id="mw9A">p</b><sub id="mw9Q">i</sub>

The values blo and bup represent the lower and upper boundaries of the search-space respectively. The w parameter is the inertia weight. The parameters φp and φg are often called cognitive coefficient and social coefficient.

The termination criterion can be the number of iterations performed, or a solution where the adequate objective function value is found. The parameters w, φp, and φg are selected by the practitioner and control the behaviour and efficacy of the PSO method (below).

Sign in to keep reading

4 more chapters are free with a Lably account.

More in Computing and communication