# Optimization Algorithms for Detection of Social Interactions
## 3 Immunological Algorithms  
Immunological Algorithms (IA) are among the most used population-based metaheuristics, successfully applied in search and optimization tasks. They take inspiration from the dynamics of the immune system in performing its job of protecting living organisms. One of the features of the immune system that makes it a very good source of inspiration is its ability to detect, distinguish, learn, and remember all foreign entities discovered ([PERSON] et al., 2015). Both proposed algorithms, Opt-IA and Hybrid-IA, belong to the special class _Clonal Selection Algorithms_ (CSA) ([PERSON] et al., 2016; [PERSON] et al., 2016), whose efficiency is due to the three main immune operators: (i) cloning, (ii) hypermutation, and (iii) aging. Furthermore, both are based on two main concepts: antigen (\(Ag\)), which represents the problem to tackle, and B cell, or antibody (\(Ab\)) that represents a candidate solution, i.e., a point in the solution space. At each time step \(t\), both algorithms maintain a population of \(d\) candidate solutions: each solution is a subdivision of the vertices of the graph \(G=(V,E)\) in communities. Let \(N=\mid V\mid\), then a B cell \(\vec{x}\) is a sequence of \(N\) integers belonging to the range \([1,N]\), where \(x_{i}=j\) indicates that the vertex \(i\) has been added to the cluster \(j\). The population, for both algorithms, is initialized at the time step \(t=0\) randomly assigning each vertex \(i\) to a group \(j\), with \(j\in[1,N]\). Then, just after the initialization step, the fitness function (Equation (1)) is evaluated for each randomly generated element (\(\vec{x}\in P^{(t)}\)) by using the function \(\text{ComputeFitness}(P^{(t)})\). The two algorithms end their evolutionary cycle when the halting criterion is reached. For this work, it was fixed to a maximum number of generations (\(MaxGen\)).  
Among all immunological operators, _cloning_ is the only one that is roughly the same between Opt-IA and Hybrid-IA (6 th line in Algorithms 1 and 2). This operator simply copies \(dup\) times each B cell producing an intermediate population \(P^{(clo)}\) of size \(d\timesdup\). We used a static cloning for both algorithms in order to avoid premature convergences. Indeed, if a number of clones proportional to to the fitness value is produced instead, we could have a population of B cells very similar to each other, and we would, consequently, be unable to perform a proper exploration of the search space getting easily trapped in local optima. Hybrid-IA, more in detail, assigns an age to each cloned B cell, which determines how long it can live in the population, from the assigned age until it reaches the maximum age allowed \(\tau_{B}\), a user-defined parameter). Specifically, a random age chosen in the range \([0:\frac{2}{3}\tau_{B}]isassignedtoeachclone\). In this way, each clone is guaranteed to stay in the population for at least a fixed number of generations (\(\frac{1}{3}\tau_{B}\) in the worst case). The age assignment and the aging operator (see Section 3.2) play a crucial role on Hybrid-IA performances, and any evolutionary algorithm in general because they are able to keep a right amount of diversity among the solutions, thus avoiding premature convergences ([PERSON] et al., 2016).