# Optimization Algorithms for Detection of Social Interactions
## 3 Immunological Algorithms
### Opt-Ia  
Opt-IA[14] is a totally blind stochastic algorithm, a particular type of optimization method that generates a set of random solutions for the community detection problem. It is based on  
1. the _hypermutation operator_, which acts on each clone in order to explore its neighborhood;
2. the _precompetition operator_, which makes it possible to maintain a more heterogeneous population during the evolutionary cycle;
3. the _stochastic aging operator_ whose aim is keep high diversity into the population and consequently help the algorithm in escaping from local optima; and, finally,
4. the _selection operator_ which identifies the best \(d\) elements without repetition of fitness, ensuring heterogeneity into the population. In Algorithm 1, the pseudocode of Opt-IA, and its key parameters, are described:  
```
1:procedureOpt-IA(\(d\), \(dup\), \(m\), \(P_{die}\))
2:\(t\gets 0\)
3:\(P^{(t)}\leftarrow\text{InitializePopulation}(d)\);
4: ComputeFitness(\(P^{(t)}\))
5:while\(-\)StopCriterion do
6:\(P^{(clo)}\leftarrow\text{Cloning}(P^{(t)},dup)\)
7:\(P^{(hyp)}\leftarrow\text{Hypermutation}(P^{(clo)},m)\)
8: ComputeFitness(\(P^{(hyp)}\))
9:\(P^{(pre)}\leftarrow\text{Precompetition}(P^{(t)})\)
10:\(P^{(pre)}_{a}\leftarrow\text{StochasticAging}(P^{(pre)},P_{die})\)
11:\(P^{(t+1)}\leftarrow\text{Selection}(P^{(pre)}_{a},P^{(hyp)})\)
12:\(t\gets t+1\);
13:endwhile
14:endprocedure
```  
**Algorithm 1** Pseudo-code of Opt-IA  
The purpose of the hypermutation operator is to carefully explore the neighborhood of each solution in order to generate better solutions from iteration to iteration. It basically performs at most \(m\) mutations on each B cell, where \(m\) is a user-defined constant parameter. Unlike the other clonal selection algorithms, including Hybrid-IA, the \(m\) mutation rate of each element is not determined by a law inversely proportional to the fitness function, but it will be the same for anyone. In this way, possible premature convergences are avoided. In this algorithm, three different types of mutation have been designed, which can act on a single node (local operators) or a set of nodes (global operators):  
1. _equiproability_: randomly select a vertex from the solution and reassign it to a cluster among those existing at that time. Each cluster has the same probability of being selected;
2. _destroy_: randomly select a cluster \(c_{i}\) from the solution \(\vec{x}\), a percentage \(P\) in the range \([1\%,50\%]\), and a cluster \(c_{j}\) in the range \([1,N]\). All vertices in \(c_{i}\) are then moved to the cluster \(c_{j}\) with \(P\) probability. Note that, if the cluster \(c_{j}\) does not exist, then a new community is created;
3. _fuse_: randomly select a cluster and assign all its nodes to a randomly selected cluster among those existing. After the hypermutation operator, the fitness values for all mutated B cell are computed. Three operators act on the population at this point. _Precompetition operator_: the primary aim of this operator is to obtain a more heterogeneous population by trying to maintain solutions which have different community numbers in order tobetter explore the search space. Basically, this operator randomly selects two different B cells from \(P^{(t)}\), and, if they have same community number, the one with a lower fitness value will be deleted with a 50% probability. _StochasticAging operator_: this operator helps the algorithm to escape from local optima by introducing diversity in the population. At each iteration, each B cell in \(P^{(pre)}\) will be removed with probability \(P_{die}\) (a user-defined parameter). Using this type of aging operator, Opt-IA is able to, on one hand, to introduce diversity in the population, which is crucial for jumping out from local optima, and, on the other hand, to have an accurate exploration and exploitation of the neighborhoods. _Selection operator:_ finally, the selection operator has the task to generate the new population for the next generation made up of the best B cells discovered so far.