# An algorithm for global optimization inspired by collective animal behavior

By Erik Cuevas, Mauricio González, Daniel Zaldivar and Marco Pérez-Cisneros

## Introduction

Global Optimization (GO) has yielded remarkable applications to many areas of science, engineering, economics and others through mathematical modelling$^1$. In general, the goal is to find a global optimum of an objective function which has been defined over a given search space. Global optimization algorithms are usually broadly divided into deterministic and metaheuristic$^2$. Since deterministic methods only provide a theoretical guarantee of locating a local minimum of the objective function, they often face great difficulties in solving global optimization problems$^3$. On the other hand, metaheuristic methods are usually faster in locating a global optimum$^4$. They virtuously adapt to black-box formulations and extremely ill-behaved functions, whereas deterministic methods usually require some theoretical assumptions about the problem formulation and its analytical properties (such as Lipschitz continuity)$^5$.
Several metaheuristic algorithms have been developed by a combination of rules and randomness mimicking several phenomena.
Many studies have been inspired by animal behavior phenomena for developing optimization techniques. For instance, the Particle swarm optimization (PSO) algorithm which models the social behavior of bird flocking or fish schooling$^6$. PSO consists of a swarm of particles which move towards best positions, seen so far, within a searchable space of possible solutions. Another behavior-inspired approach is the Ant Colony Optimization (ACO) algorithm proposed by Dorigo et al.$^7$, which simulates the behavior of real ant colonies. Main features of the ACO algorithm are the distributed computation, the positive feedback and the constructive greedy search. Recently, a new metaheuristic approach which is based on the animal behavior while hunting has been proposed in$^8$. Such algorithm considers hunters as search positions and preys as potential solutions.
Just recently, the concept of individual-organization$^9$,$^{10}$ has been widely referenced to understand collective behavior of animals. The central principle of individual-organization is that simple repeating interactions between individuals can produce complex behavioral patterns at group level$^9$,$^{11}$,$^{12}$. Such inspiration comes from behavioral patterns previously seen in several animal groups. Examples include ant pheromone trail networks, aggregation of cockroaches and the migration of fish schools, all of which can be accurately described in terms of individuals following simple sets of rules$^{13}$. Some examples of these rules$^{12}$,$^{14}$ are keeping the current position (or location) for best individuals, local attraction or repulsion, random movements and competition for the space within of a determined distance.
On the other hand, new studies$^{15}$-$^{17}$ have also shown the existence of collective memory in animal groups. The presence of such memory establishes that the previous history of the group structure influences the collective behavior exhibited in future stages. According to such principle, it is possible to model complex collective behaviors by using simple individual rules and configuring a general memory.
In this paper, a metaheuristic algorithm for global optimization called the Collective Animal Behavior (CAB) is introduced. In this algorithm, the searcher agents emulate a group of animals that interact to each other based on simple behavioral rules which are modeled as mathematical operators. Such operations are applied to each agent considering that the complete group has a memory storing their own best positions seen so far, by using a competition principle. The proposed approach has been compared to other well-known optimization methods. The results confirm a high performance of the proposed method for solving various benchmark functions.

## Biologic fundamentals

The remarkable collective behavior of organisms such as swarming ants, schooling fish and flocking birds has long captivated the attention of naturalists and scientists. Despite a long history of scientific research, the relationship between individuals and group-level properties has just recently begun to be deciphered$^{18}$.
Grouping individuals often have to make rapid decisions about where to move or what behavior to perform in uncertain and dangerous environments. However, each individual typically has only a relatively local sensing ability$^{19}$. Groups are, therefore, often composed of individuals that differ with respect to their informational status and individuals are usually not aware of the informational state of others$^{20}$, such as whether they are knowledgeable about a pertinent resource or about a threat.
Animal groups are based on a hierarchic structure$^{21}$ which considers different individuals according to a fitness principle called Dominance$^{22}$ which is the domain of some individuals within a group that occurs when competition for resources leads to confrontation. Several studies$^{23}$,$^{24}$ have found that such animal behavior lead to more stable groups with better cohesion properties among individuals.
Recent studies have begun to elucidate how repeated interactions among grouping animals scale to collective behavior. They have remarkably revealed that collective decision-making mechanisms across a wide range of animal group types, from insects to birds (and even among humans in certain circumstances) seem to share similar functional characteristics$^9$,$^{13}$,$^{25}$. Furthermore, at a certain level of description, collective decision-making by organisms shares essential common features such as a general memory. Although some differences may arise, there are good reasons to increase communication between researchers working in collective animal behavior and those involved in cognitive science$^{12}$.
Despite the variety of behaviors and motions of animal groups, it is possible that many of the different collective behavioral patterns are generated by simple rules followed by individual group members. Some authors have developed different models, one of them, known as the self-propelled particle (SPP) model, attempts to capture the collective behavior of animal groups in terms of interactions between group members which follow a diffusion process$^{26}$-$^{29}$.
The dynamical spatial structure of an animal group can be explained in terms of its history$^{24}$. Despite such a fact, the majority of studies have failed in considering the existence of memory in behavioral models. However, recent research$^{15}$,$^{30}$ have also shown the existence of collective memory in animal groups. The presence of such memory establishes that the previous history of the group structure influences the collective behavior which is exhibited in future stages. Such memory can contain the location of special group members (the dominant individuals) or the averaged movements produced by the group.
According to these new developments, it is possible to model complex collective behaviors by using simple individual rules and setting a general memory. In this work, the behavioral model of animal groups inspires the definition of novel evolutionary operators which outline the CAB algorithm. A memory is incorporated to store best animal positions (best solutions) considering a competition-dominance mechanism.

## Collective Animal Behavior Algorithm (CAB)

The CAB algorithm assumes the existence of a set of operations that resembles the interaction rules that model the collective animal behavior. In the approach, each solution within the search space represents an animal position. The “fitness value” refers to the animal dominance with respect to the group. The complete process mimics the collective animal behavior.
The approach in this paper implements a memory for storing best solutions (animal positions) mimicking the aforementioned biologic process. Such memory is divided into two different elements, one for maintaining the best locations at each generation (M$_h$) and the other for storing the best historical positions during the complete evolutionary process (M$_g$).

### Description of the CAB algorithm

Following other metaheuristic approaches, the CAB algorithm is an iterative process that starts by initializing the population randomly (generated random solutions or animal positions). Then, the following four operations are applied until a termination criterion is met (i.e. the iteration number NI):
* Keep the position of the best individuals.
* Move from or to nearby neighbors (local attraction and repulsion).
* Move randomly.
* Compete for the space within a determined distance (update the memory).

#### Initializing the population

The algorithm begins by initializing a set A of N$_p$ animal positions (A={a$^1$,a$^2$,...a$_{Np}$}). Each animal position a$_i$ is a D-dimensional vector containing parameter values to be optimized. Such values are randomly and uniformly distributed between the pre-specified lower initial parameter bound a$_j$$^{low}$ and the upper initial parameter bound a$_j$$^{high}$.
j=1,2,...,D; i=1,2,...,N$_p$.
with j and i being the parameter and individual indexes respectively. Hence,a$_{j,i}$ is the jth parameter of the ith individual.
All the initial positions A are sorted according to the fitness function (dominance) to form a new individual set X={x$_1$,x$_2$,...,x$_{Npp}$}, so that we can choose the best B positions and store them in the memory M$_g$ and M$_h$. The fact that both memories share the same information is only allowed at this initial stage.

#### Keep the position of the best individuals

Analogous to the biological metaphor, this behavioral rule, typical from animal groups, is implemented as an evolutionary operation in our approach. In this operation, the first B elements ({a$_1$,a$_2$,...,a$_B$}), of the new animal position set A, are generated. Such positions are computed by the values contained inside the historical memory M$_h$, considering a slight random perturbation around them. This operation can be modeled as follows:
where lε{1,2,...,B} while m$_h$$^l$ represents the l-element of the historical memory M$_h$. v is a random vector with a small enough length.

#### Move from or to nearby neighbors

From the biological inspiration, animals experiment a random local attraction or repulsion according to an internal motivation. Therefore, we have implemented new evolutionary operators that mimic such biological pattern. For this operation, a uniform random number r$_m$ is generated within the range [0,1]. If r$_m$ is less than a threshold H, a determined individual position is moved (attracted or repelled) considering the nearest best historical position within the group (i.e. the nearest position in M$_h$); otherwise, it goes to the nearest best location within the group for the current generation (i.e. the nearest position in M$_g$). Therefore such operation can be modeled as follows:
where iε{B+1,B+2,...,N$_p$}, m$_h$$^{nearest}$ and m$_g$$^{nearest}$ represent the nearest elements of M$_h$ and M$_g$ to x$_i$, while r is a random number.

#### Move randomly

Following the biological model, under some probability P, one animal randomly changes its position. Such behavioral rule is implemented considering the next expression:
being iε{B+1,B+2,...,N$_p$} and r a random vector defined in the search space. This operator is similar to re-initialize the particle in a random position, as it is done by Eq. (1).

#### Compete for the space within of a determined distance (update the memory)

Once the operations to keep the position of the best individuals, such as moving from or to nearby neighbors and moving randomly, have all been applied to the all N$_p$ animal positions, generating N$_p$ new positions, it is necessary to update the memory M$_h$.
In order to update de memory M$_h$, the concept of dominance is used. Animals that interact within a group maintain a minimum distance among them. Such distance ρ depends on how aggressive the animal behaves $^{22}$,$^{30}$. Hence, when two animals confront each other inside such distance, the most dominant individual prevails meanwhile other withdraw.
In the proposed algorithm, the historical memory M$_h$ is updated considering the following procedure:
* The elements of M$_h$ and M$_g$ are merged into M$_U$(M$_U$=M$_h$υM$_h$).
* Each element m$_U$$^i$ of the memory M$_U$ is compared pair-wise to remaining memory elements ({m$_U$$^1$,m$_U$$^2$,...,m$_U$$^{2B-1}$}). If the distance between both elements is less than ρ, the element getting a better performance in the fitness function prevails meanwhile the other is removed.
* From the resulting elements of M$_U$ (from step 2), it is selected the B best value to build the new M$_h$.
Unsuitable values of ρ yield a lower convergence rate, a longer computational time, a larger function evaluation number, the convergence to a local maximum or to an unreliable solution. The ρ value is computed considering the following equation:
where a$_j$$^{high}$ and a$_j$$^{low}$ represent the pre-specified lower and upper bound of the j-parameter respectively, in an D-dimensional space.

#### Computational procedure

The computational procedure for the proposed algorithm can be summarized as follows:
Step 1: Set the parameters N$_p$, B, H,P and NI.
Step 2: Generate randomly the position set A={a$_1$,a$_2$,...,a$_{Np}$} using Eq.1
Step 3: Sort A according to the objective function (dominance) to build X={x$_1$,x$_2$,...,x$_{Np}$}.
Step 4: Choose the first B positions of X and store them into the memory M$_g$.
Step 5: Update M$_h$ according to Section 3.1.5. (during the first iteration:M$_h$=M$_g$).
Step 6: Generate the first B positions of the new solution set A({a$_1$,a$_2$,...,a$_B$}. Such positions correspond to the elements of M$_h$ making a slight random perturbation around them.
Step 7: Generate the rest of the A elements using the attraction, repulsion and random movements.
Step 8: If NI is completed, the process is finished; otherwise go back to step 3. The best value in M$_h$ represents the global solution for the optimization problem.