Python implementation of an Swarm based Optimization algorithm, named Cat Swarm Optimization. This meta heuristic optimization technique was developed by Chu and Tsai (2007).Although there are many modified versions of CSO proposed, the original vanilla version is implemented.
Inspired from the behavior of a population of cats, where they are likely to be in either of the two modes, Seeking or Tracing Mode. Cats rather spend being alert in Seeking mode to conserve their energy to locate the pray before they execute their hunt. This process of locating the solution in a search space elaborates an efficient and accurate hunting behavior of cats.
This algorithm of cats can be utilised by choosing a population of cats interacting with the environment in an M dimensional map with their position X(i,d) and velocity v(i,d). Where Xbest is the best position searched by a cat in that search space.
During this mode the cat is resting while keeping an eye on its environment. In case of sensing a prey or danger, the cat decides its next move. If the cat decides to move, it does that slowly and cautiously. Just like while resting, in the seeking mode the cat observes into the M-dimensional solution space in order to decide its next move. In this situation, the cat is aware of it own situation, its environment, and the choices it can make for its movement. These are represented in the CSO algorithm by using four parameters: seeking memory pool (SMP), seeking range of the selected dimension (SRD), counts of dimension to change (CDC), and self-position consideration (SPC). SMP is the number of the copies made of each cat in the seeking process. SRD is the maximum difference between the new and old values in the dimension selected for mutation.CDC tells how many dimensions will be mutated. All these parameters define the seeking process of the algorithm.SPC is the Boolean variable which indicates the current position of the cat as a candidate position for movement. SPC cannot affect the value of SMP.
Xcn = (1 ± SRD × R) × Xc
in which, Xc current position
Xcn new position
R a random number, which varies between 0 and 1
The probability parameter Pi in the orginal litrature has been modified into aggressive allocation of the best solution among the involved population of cats in the seeking mode.Since this method proved stable and faster convergence towards a solution.
The tracing mode simulates the cat chasing a prey. After finding a prey while resting (seeking mode), the cat decides its movement speed and direction based on the prey's position and speed. In CSO, the velocity of the cat k in demension d is given by
vk,d = vk,d + r1 × c1(Xbest,d - Xk,d)
in which, vk,d = velocity of cat k in dimension d; Xbest,d = position of the cat with the best solution; Xk,d = position of the catk; c1 = a constant; and r1 = a random value in the range [0,1]. Using this velocity, the cat moves in the M-dimensional decision space and reports every new position it takes.If the velocity of the cat is greater than the maximum velocity, its velocity is set to the maximum velocity. The new position of each cat is calculated by
Xk,d,new = Xk,d,old + vk,d
in which Xk,d,new new position of cat k in dimension d ; and
Xk,d,old current position of cat k in dimension d.
-- Refrenced from Advanced Optimization by Nature-Inspired Algorithms by Omid Bozorg-Haddad
One can customize their cost function, it is applicable to any type of Univariate equations.