### Traditional Ant Colony Algorithm

Here we briefly introduce AC and its applications using TSP as an example. In the TSP, a given set of n cities has to be visited exactly once and the tour ends in the initial city. We denote the edge between city i and j as (i, j) and its distance as d_{ij} (i, j ∈ [1, n]). Let *τ*
_{ij}(t) be the intensity of pheromone on (i, j) at time t, and use *τ*
_{ij}(t) to simulate the pheromone of real ants. Suppose m is the total number of ants, at time t the kth ant selects from its current city i to city j according to the following probability distribution:

Where allowed_{k} is a set of the cities can be chosen by the kth ant at city i for the next step, *η*
_{ij} is a heuristic function which is defined as the visibility of the link between cities i and j, for instance it can defined as 1/d_{ij}.

The relative influence of the trail information *τ*
_{ij}(t) and the visibility *η*
_{ij} are determined by the parameters *α*, *β*. When *α* = 1 and *β* = 0, the algorithm becomes a complete heuristic algorithm with positive feedback and when *α* = 0 and *β* = 1, it is just a traditional greedy algorithm. For every ant, its path traversing all the cities forms a solution. The intensity of pheromone is updated by Eq. (2):

*τ*
_{ij}(t + 1) = *ρ*
*τ*
_{ij}(t) + Δ*τ*
_{ij} (2)

Where 0 <*ρ* < 1 represents the evaporation of *τ*
_{ij}(t) between time t and t + 1, Δ*τ*
_{ij} is the increment of the pheromone on (i, j) in step t, and Δ*τ*
_{ij}k is the pheromone laid by the kth ant on it, it takes different formula depending on the model used.

For example, in the most popularly used model called "ant circle system", it is given as Eq. (4).

Where Q is a constant, L_{k} is the total length of current tour travelled by the kth ant.

### Diversity Guaranteed Ant Colony Algorithm with Immune Strategy

**Begin**

1. Initialize

The ants search the solution space at random and generate Np initial solutions, compute their fitness, set t = 1(Np is the population size of the colony, t is the iteration number), suppose there are s initial solutions which pass the edge (i, j) and the total length of the paths they have toured are L1, L2,...,Ls, then let the initial trail information on edge (i, j) be

Using niche technique [13], isolate the ant colony to m sub-colonies;

2. While (t <= Nc)

/* Nc is the maximal iteration number depend on the requirement*/

2.1 each sub-colony executes its evolutionary iteration independently

2.1.1 find the ant i which has the most high fitness value f_{i} in current sub-colony, decompose its solution it searched, and abstract immune vaccination H = {h_{s}|s = 1,2,⋯n, h_{s} represents the index number in the solution sequence}

2.1.2 For k = 1 to N do//for n cities

For i = 1 to m do //for m ants

2.1.2.1 The ant i select the next city j with the probability given by (1);

2.1.2.2 have local updating operation to update the trail information on edge (i, j) according to (6);

End for i

The ant would stop its search in current iteration if the length of the path it has passed overpasses that of the optimal solution f_{opt} obtained in the former iteration, and then let f_{opt} be the solution of this ant;

End for k

2.1.3 Select some solutions searched by the ants in current sub-colony to have mutation operation,

2.1.4 Inoculate the vaccination; have immune memory and immune metabolism operations on the sub-colony;

2.1.5 Calculate the quality factor of each ant, we let *δ* be the density of the ant i, (it was defined in the next section), have global pheromone updating operation to update the trail information on the edges between each city according to (8);

2.2 Adjust the population size of the sub-colony, by eliminating the individuals with lower fitness;

2.3 Have immune memory and immune metabolism operations on the whole colony

End while

3 Return the number of iteration t and the best solution

**End**

In the line (2.1.2.1) of the algorithm, the next city j will be selected by the following formula:

Here, q is generated stochastically between (0, 1). q_{0} is a probability of pitching on the optimal individual, for example, if q_{0} = 0.7, the city who has the highest trail information will be chosen with a probability over 0.7, meanwhile, the other cities only can be selected with a little chance less than 0.3. In the formula, arg max *τ*
_{
ij
}(*t*)(*j* ∈ *allowed*
_{
k
}) is the available adjacent city of city i who has the highest trail information. In (5), j_{0} ∈ [1, ki] is generated with the probability of *p*
_{
ij0}
^{
k
}(*t*).

### Immune Pheromone Updating Strategy

Suppose the number of total iterations is NC, the fitness of the ith ant at the tth iteration (i.e. at time t) is fit(t, i), which is in inverse proportion to the length of its solution. We denote the worst and best fitness of solutions of the tth iteration as fit_{min}(t) and fit_{max}(t) respectively, namely f_{min}(t) = min{fit(t, i), i ≤ m}, fitmax(t) = max{fit(t, i), i ≤ m}. We define the global worst and best fitness as the worst and best fitness of solutions of all the iterations so far, and denote them as GF_{min} and GF_{max}, i.e. GF_{min} = min{fit_{min}(t), t ≤ NC}, GF_{max} = max{fit_{max}(t), t ≤ NC}. Then the quality factor of ith ant's solution is defined as:

Here, fit(t, i)-GF_{min} is the difference between the ith ant's fitness on the current iteration and the global worst fitness. For fixed values of GF_{min} and GF_{max}, the lager fit(t, i) is, the larger the quality factor the ith ant has.

In our algorithm, we present an adaptive pheromone updating strategy based on quality factor. In line 2.1.2.2, the local updating method is based on (8)

Here length is the length of the solution of the ith ant in the current iteration. By the quality factor, the tour of the ant with the high fitness will be greatly increased to strengthen the pheromone on the tour of the best solution.

### Isolation Niche Technique

In biology, niche means a special role or function in certain circumstances, and organizations that have common organizational functions in given environment are called species. The niche in nature makes the form of new species come true, and this is one of the foundational reasons of the infinity and diversity of the species. Researches have reported that, the creature can come into being daedal species in their evolutionary process mainly due to their capability of separating the whole colony into smaller sub-colonies. In the course of separation, geological isolation plays an important role, it gradually generate biological and behavioural isolation.

There is no communication between separated isolation sub-colonies, and the individuals belonging to different sub-colonies may have distinctly different evolutionary directions and arise different mutation, which may bring bigger and bigger differences.

To multi-peak object function optimization problems, the most important thing is not only getting diversified solutions but also to avoid local optimal solution in the evolutionary process to exploit new search space. Therefore, we can do nothing but construct a new algorithm with potential evolutionary capability to find the optimal solution of the object function. And this new algorithm will apply isolation niche technique into the ant colony algorithm to improve its optimization ability.

In line 1.2 the algorithm implements initial isolation operation. Np initial individuals are assigned to m sub-colonies (i.e. m species), and the number of individuals in each sub-colony is Np/m.

In line 2.2, the population size of the sub-colony is defined according to its average fitness value. The higher average fitness value the sub-colony has, the more chance of propagation this species has, and the larger number of ants the sub-colony will have. But in the ant colony algorithm the population size of the whole ant colony M is fixed (it is often close to the scale of the problem n). In order to avoid unbounded increase of the sub-colony size, we set the maximum size of the sub-colony be s_{max}. Contrarily, the number of species may be decreased even be extinct due to the low fitness of some individuals.

In the isolation niche mechanism of this paper, for the sake of protecting some low fitness valued sub-colonies especially to make it survival from the competition and maintaining the evolutionary capability, i.e. maintain the population size of the whole colony, we also define a minimal size s_{min} for each sub-colony.

In line 2.3, immune memory operation was carried out on the sub-colonies. Usually, the best individual in current iteration may necessarily have a high probability of coming into being the optimal solution of the object problem. So, we use the immune memory function of the immune system, and copy the sub-colony where the best individual included to the next iteration directly.

In addition, if the sub-colony has low fitness values continually in consecutive iterations, we will perform the immune metabolism operation and generate a new sub-colony in the search space to replace this sub-colony artificially. In the algorithm, some new generated sub-colonies are in the initial stages of its evolutionary process, they are relatively weak compared with other developed sub-colonies although they have potential of evolutionary capability. Therefore, our algorithm will protect the new sub-colonies from elimination in the iterations of its initial stages.

### Vaccination Inoculation

Line 2.1.4 of the algorithm inoculates the vaccination to some selected individuals. It picks out a certain number of ants from current ant colony to inoculate vaccination with a probability of p_{v}, then crossover the solution with the vaccination. In the operation of vaccination inoculation, we adopt the order crossover method (OX) proposed by Davis in 1985 [21].

Suppose the paternal individuals to be:

p1 = (2 5 8 3 7 4 6 1)

p2 = (5 1 2 8 3 6 7 4)

One of the paternal individuals is the selected ant to be inoculated, and the other is the vaccine. These two parent individuals means:

p1:set out from city 2, and passes the cities of 5, 8, 3, 7, 4, 6 and 1 successfully.

p2:set out from city 5, and passes the cities of 1, 2, 8, 3, 6, 7 and 4 successfully.

The crossover process is described as follows:

Select two crossover points stochastically (the part which is partitioned by the vertical lines between the two crossover points is called crossover section), then exchange the crossover sections of the parent individuals, that is to say, copy the crossover section of parent individual 1 (p1) to offspring 2 named o2, at the same interval, similarly, the initial part of crossover section of parent 2 (p2) will be copy to the same position of offspring 1 named o1.

Delete the contents (city number) of p1, which is in the crossover section of p2, and similarly, delete the contents of p2, which belongs to the crossover section of p1.

Fill the rest part of p2 to o1 behind its second crossover point, if it's over the end of o1 then turn to its head and continue its fill operation until all the rest of p2 were filled to o1, and have the same operation to p1 and o2 to accomplish an order crossover.

For instance, for the parents given above, suppose crossover points showed as follows ("|" denotes crossover points):

p1 = (2 5 | 8 3 7 | 4 6 1)

p2 = (5 1 | 2 8 3 | 6 7 4)

The offspring generated by crossover operation were denoted by o1 and o2, here "#" denotes undetermined cities, and the results of crossover copy operation are:

o1 = (# # | 8 3 7 | # # #)

o2 = (# # | 2 8 3 | # # #)

Fill the rest of the parents to the offspring:

o1 = (6 4 | 8 3 7 | 5 1 2)

o2 = (6 1 | 2 8 3 | 5 7 4)

Select the high fitness valued one from offspring o1 and o2 and replaces the original individual to accomplish the vaccination inoculation.

### Adaptive Mutation Operation

In line 2.1.3, the algorithm selects some solutions obtained by a sub-colony to have mutation operation with the mutation probability of

, which is adaptively defined according to the densities of the solutions. This means the sub-colony with higher diversity is more likely to be selected to have mutation. In this formula, m denotes the population size of the sub-colony. The probability for the ant i in the sub-colony to be selected to have mutation is exp(-

*δ*). It can be seen that the higher fitness the solution has, the higher probability this solution will be chosen. In mutation operation, if the fitness value between different solutions in the colony is large enough, this indicates a high diversity of the solution, the algorithm would have mutation operation with a low probability, otherwise it will mutate with a high probability to get rid of local convergence and to improve the solution diversity.

### Immune Memory and Immune Metabolism

In the immune system of the organism, in the long period of time after the antigen vanished from the immune system, the cells formed by antibody still memorizes the information of antigen. Consequently, when the antigen invades again, the organism will generate antibodies responsively to counteract the antigen according to its immune network.

In line 2.1.4 of our algorithm, we adopt this mechanism to have immune memory operation so as to increase the quality of the solutions. First, the algorithm calculates the fitness value of each ant in the colony, if the highest one is higher than the current optimal solution, it is added to the memory list, otherwise some better solutions obtained in previous iterations would be selected from the memory list and have crossover and mutation to get another higher fitness valued solution as an antibody.

In the organism, there are about 5% low inspirited cells died every day for its metabolism, and there are also neonatal cells generated by the marrow. Among these neonatal cells only those who have strong adaptability can be integrated into the immune system. By simulating this metabolism behaviour, in the end of each iteration, our algorithm picks out 5% low fitness valued ants and replaces them by the new stochastically generated solutions.