# Optimization Algorithms for Detection of Social Interactions
## 3 Immunological Algorithms
### Hybrid-IA  
A fundamental difference between Opt-IA and Hybrid-IA is that the former, as described above, is a stochastic IA that finds solutions by random methods. The latter, instead, uses a deterministic local search, based on rational choices that refine and improve the solutions found so far. The pseudocode of Hybrid-IA is described in Algorithm 2. ```
1:procedureHybrid-IA(\(d\), \(dup\), \(\rho\), \(\tau_{B}\))
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)},\rho)\)
8: ComputeFitness(\(P^{(hyp)}\))
9:\((P^{(t)}_{a},P^{(hyp)}_{a})\leftarrow\text{Aging}(P^{(t)},P^{(hyp)},\tau_{B})\)
10:\(P^{(select)}\leftarrow(\mu+\lambda)-\text{Selection}(P^{(t)}_{a},P^{(hyp)}_{a})\)
11:\(P^{(t+1)}\leftarrow\text{LocalSearch}(P^{(select)})\)
12: ComputeFitness(\(P^{(t+1)}\))
13:\(t\gets t+1\);
14:endwhile
15:endprocedure
```  
**Algorithm 2** Pseudo-code of Hybrid-IA. The hypermutation operator developed in Hybrid-IA has the main goal of exploring the neighborhoods of solutions by evaluating how good each clone is. Unlike Opt-IA, the mutation rate is determined through an _inversely proportional_ law to the fitness function value of the B cell considered, that is, the better the fitness value of the element is, the smaller the mutation rate will be. In particular, let \(\vec{x}\) be a cloned B cell, the _mutation rate_\(\alpha=e^{-\rho\hat{f}(\vec{x})}\) is defined as the probability to move a node from one community to another one, where \(\rho\), a user-defined parameter that determines the shape of the mutation rate, and \(\hat{f}(\vec{x})\) is the fitness function normalized in the range \([0,1]\). Formally, the designed hypermutation works as follows: for each B cell, two communities \(c_{i}\) and \(c_{j}\) are randomly chosen (\(c_{i}\
eq c_{j}\)): the first is chosen among all existing ones, and the second in the range \([1,N]\). Then, all vertices in \(c_{i}\) are moved to \(c_{j}\) with probability given by \(\alpha\). If a value that does not correspond to any currently existing community is assigned to \(c_{j}\), a new community \(c_{j}\) is created and added to the existing ones. The idea behind this approach is to better explore the search space and create and discover new communities by moving a variable percentage of nodes from existing communities. This search method balances the effects of local search (as described below), by allowing the algorithm to avoid premature convergences towards local optima. The static aging operator in Hybrid-IA acts on each mutated B cells by removing older ones from the two populations \(P^{(t)}\) and \(P^{(hyp)}\). Basically, let \(\tau_{B}\) be the maximum number of generations allowed for every B cell to stay in its population; then, once the age of a B cell exceeds \(\tau_{B}\) (i.e., age=\(\tau_{B}\)+1), it will be removed independently from its fitness value. However, an exception may be done for the best current solution, which is kept into the population even if its age is older than \(\tau_{B}\). Such a variant of the aging operator is called _elitist aging operator_. In the overall, the main goal of this operator is to allow the algorithm to escape and jump out from local optima, assuring a proper turnover between the B cells in the population, and producing, consequently, high diversity among them. After the aging operator, the best \(d\) survivors from both populations \(P^{(t)}_{a}\) and \(P^{(hyp)}_{a}\) are selected, in order to generate the temporary population \(P^{(select)}\), on the local search will be performed. Such a selection is performed by the \((\mu+\lambda)\)_-Selection operator_, where \(\mu=d\) and \(\lambda=(d\times dup)\). The operator identifies the \(d\) best elements among the set of offsprings and the old parent B cells, ensuring consequently monotonicity in the evolution dynamics.