The distributed parallel genetic algorithm on the ad hoc network

Today, mobile computing is one of the important issues in computer and network sciences. Using the processing power of mobile devices purposefully for solving complex issues is one of the research fields for researchers. One of the important issues in the optimization which needs a high processing power for finding the best possible answer is travelling salesman problem. In this paper, by providing a method based on the distributed parallel genetic algorithm on a number of mobile nodes in the Ad Hoc network, it was attempted to increase the speed of finding the best answer for the travelling salesman algorithm.


Introduction
Today, mobile computation means using the processing power of mobile devices for doing computational affairs. Mobile computations have a limited power which mobile distributed computations can be used for their solution in which the multi-user computing power is used. The mobile distributed computations divide into two categories of "with center" and "without center". In mobile distributed computations with center, issues such as the possibility of error and distance are posed [1]. For mobile distributed computations without center, a strategy such as using Ad Hoc networks can be presented. Mobile computations make it possible to use a computing device, even when it is changing its location; therefore, the transportability is one of the aspects of mobile computations. This method also makes it possible to use the computation ability without center and or the predefined connection in a network for information dissemination and or sharing [3]. Today, with the increasing expansion of smartphones, tablets and powerful mobile computers, their potential computing power can be actualized using the mobile processing, and they can be used for wireless computations. With the combination of mobile computations and mobile Ad Hoc networks, a subject is formed called "mobile computations in Ad Hoc networks" which can use this computing power [2], [3]. In this paper, we provide a method for solving the travelling salesman problem using the genetic algorithm distributed on a set of mobile nodes in parallel and prove the reduction of total time for finding the best answer in case of increasing processing nodes. In our proposed method, the problem parameters are distributed on processing nodes based on the processing power of each node and each node accelerates the process of finding the problem's best answer by computing the part it is assigned to and returning the reply to the distributed node.

The travelling salesman problem
The travelling salesman problem is one of the very important and widely used problems in computer sciences and operations research. This problem is in a standard form in mathematics as finding a Hamiltonian Cycle with the minimum weight in an undirected weighted graph with n vertices in which vertices indicate cities. Edges show intercity paths and weight shows intercity distance [7], [12]. The number of vertices in a complete graph equals . The final method for solving the travelling salesman problem includes passing all possible paths, evaluating the relating travel distance and finding the travel with the minimum distance. The total number of passable paths for n city equals consequently, for large values, finding the cost of all travels is very time consuming or sometimes impossible [7]. The parallel process will be very useful in reducing the computing time of this problem [6].

The parallel genetic algorithm
The genetic algorithm is a powerful technique used for solving different problems. This algorithm was inspired by the theory of human evolution in which a society with constant individuals, individuals with high fitness, is selected and this process continues until creating a society with optimal answers for the problem corresponding to that society [4]. In the genetic algorithm, first, we produce several answers randomly or based on a special algorithm. This set of answers is called the initial population. Each answer is called a chromosome. Then, after selecting better chromosomes, using the genetic algorithm operators, chromosomes are combined and mutated. Finally, we combine the current population with the new one which is resulted from the combination and mutation in chromosomes [4]. [6]. In fig. 2, the standard genetic algorithm flowchart is shown. One of the problems of the genetic algorithm is the high volume of information and time for processing and reinforcing answers and accessing an almost optimal answer in algorithms [5]. The nature of the genetic algorithm is such that there is a kind of implicit parallelization in it. For example, the computation of individuals' fitness can be done independent from the society, and its implementation in parallel is simpler and more efficient [4], [6]. Parallel genetic algorithms are better than sequential genetic algorithms in terms of higher acceleration and greater scalability. The parallelization of genetic algorithms leads to the improvement of genetic algorithms' performance in terms of efficiency and speed [4]. The parallel genetic algorithm has different categories one of the best known of which is master-slave model used in the paper. From among other categories, the coarse-grained and fine-grained model can be mentioned [6]. In the masterslave model, the society is maintained in the master and slaves are used for the evaluation of fitness. This model does not have any default architecture and its implementation on different types of architectures is possible; therefore, it can be used in Ad Hoc networks [4], [6], [8], [9]. In this model, the number of individuals assigned to each processor for computing the fitness is fixed, but in some applications, there is a need for balancing the computational load between processors [6]. The relation for obtaining the acceleration is as follows: (1) In this relation, n is the number of individuals in the society, is the required time for computing the fitness of each individual and is the required time for sending information from the master to the slave. Fig.3 presents the overview of the master-slave model [6].

Ad Hoc networks
Wireless Ad Hoc networks include a set of distributed nodes which are wirelessly connected to each other [1]. Each node connects to other nodes directly and without any center. Nodes in this network continually change their position; so, the most important feature of these networks is the existence of a variable and dynamic topology resulted from nodes mobility [8], [9].  A mobile Ad Hoc network is a non-infrastructure network of mobile devices which are connected wirelessly. Nodes in this network are autonomous, i.e. any device can freely move in the network [8]. Mobile Ad Hoc networks are better than conventional wireless networks because of the simple development of these networks, their development speed and lack of dependency on a constant structure, and as mentioned before, they are a proper platform for implementing the master-slave model [6], [8]. Generally, when an infrastructure is not accessible and the creation of an infrastructure is not practical and affordable, the use of an Ad Hoc network is useful [1], [9].

Computation in Ad Hoc networks
One of the challenges of Ad Hoc networks is the way of problem distribution among network's nodes because network nodes do not have the previous knowledge about the network's topology where there are located; so, they have to discover the destination in the network for communicating with other nodes [9]. But, here it is assumed that the master is communicating with some nodes which are used as slaves and ready to receive the problem from the master for processing and returning the answer to the master. Accordingly, it is better to distribute the genetic algorithm in parallel on the network nodes.

The proposed method
In this method, the main objective is to solve the travelling salesman problem which is a problem for finding a Hamilton Cycle with the minimum length using the genetic algorithm. When the travelling salesman problem is modeled mathematically, it turns into the Hamilton Cycle in mathematics and graphs theory and then will be ready for being solved [7]. Fig. 5 shows the cities' distribution in the travelling salesman problem under the process, including 150 cities and cities are related and randomly presented for simulating the efficiency of the proposed method in this article. In our proposed method, the problem parameters are distributed based on the processing power of each node among the existing processing nodes and the standard genetic algorithm is performed on each node. After receiving the problem parameters from the master, each node is numbered by a label granted from the master. This number is notified to other existing processing nodes. Therefore, each node not only knows its number, but also other nodes' numbers. It leads to the simplicity of immigration among subpopulations of each node. Nodes can exchange some individuals for preventing from being trapped in the local optimum. This exchange called immigration leads to the sharing of genetic parameters by processing nodes. In our proposed method, the immigration relationship among nodes is as follows: Assume that each slave node is . Each selects the best individual in its population in terms of fitness and sends it to the substitute . So, the last node will send its best individual to . As a result, each receives individuals from and substitutes its worst individual in terms of fitness with the individual it received. After several immigrations, each slave has the best individuals found by other processing nodes. For distributing the problem parameters, each node notifies its processing power to the master node with (processing power) parameter. (2) For dividing the problem parameters on slave nodes, the master node works as follows which each slave is computed through the relation and problem parameters are assigned to each slave based on the weight obtained. So: (3) The general puzzle of distributing problem parameters and returning of the answer to the master for studying the desirability of the answer is shown in fig. 6. In a graph of n vertices, a Hamiltonian Cycle indicates a sequence of n vertices creating the cycle without repeating any vertex. In general, any Hamiltonian Cycle indicates one of possible permutations of graph vertices. We assume that graph shows the problem and . Any individual in population is a Hamiltonian Cycle which is shown as follows: (4) Therefore, as all possible permutations of elements, equals . Now, the fitness function is defined as follows: Is the distance between cities and ; so, can be the distance from the Hamiltonian Cycle . Any slave receives problem parameters from the master, produces a random subpopulation and begins to perform the standard genetic algorithm among subpopulations. Individuals in the society of Hamiltonian Cycle are in the form of a sequence of vertices which make the mutation and crossover simpler and more efficient. In any generation and after the mutation and crossover operations were done by the slave, each slave sends the minimum cost of the Hamiltonian Cycle in its generation to the master. Based on the received results, the master decides whether the desired result is obtained or another generation must be computed. In our proposed method known as the steady state distributed parallel genetic algorithm, children are not substituted with their parents, but substitutes are members of population with the minimum fitness [10]. The crossover operation is done for each generation. In this article, OX crossover operator is used for the crossover operation. This crossover method is one of the crossover operators which maintain the relative order for which: 1) We select two parents randomly.

2)
For producing the first child, we copy a random subsequence from one of the parents and insert it in the first child.

3)
For filling other cities in the first child, we copy the second child.

4)
For producing the next child, we change the role of parents.
In our proposed method, the highest time acceleration happens which the crossover rate is adjusted on 50%. Otherwise, the time of finding the best answer for the travelling salesman problem is significantly increased. In fig. 7, we observe the comparison among 4 acceleration rates of 50%, 70%, 80% and 90%. As it is obvious in fig. 7, when the crossover rate is more than 50%, the time of finding the best answer is significantly increased.
For the design proposed in the article, the following flowchart can be presented: As it is observed in fig. 9, the simulation results show that with the increase in number of clusters from 1 to 4, the answer of the distributed genetic algorithm is accompanied with a uniform and significant reduction. This special feature of the master-slave distribution granted a unique and desired ability to the distributed genetic algorithm in order to have the effective implementation ability on structures without centers such as Ad Hoc networks. For a better understanding of the improvement through the proposed method, the speed of finding the best answer for the problem is separately shown for slave nodes in fig. 10. Note that there is a great difference in the speed of finding an optimal answer by the proposed algorithm so that it leads to very high amount of savings in time; cost and energy, especially as processing nodes in Ad Hoc networks face the limitation of power.

Conclusion
In this article, after studying important issues such as the genetic algorithm and travelling salesman, it was attempted to solve the travelling salesman problem using the property of the master-slave distributed genetic algorithm in Ad Hoc networks. Results show the efficiency of the aforementioned method and its ability in Ad Hoc networks which significantly improves the speed of finding the best answer for the travelling salesman problem. The distribution of problem parameters by our proposed method which is proportional to the processing power of each slave node underlies the acceleration in solving problems and finding the optimal answer for the problem. The acceleration of the process of finding answer leads to the savings in energy and overcoming one of today's challenges in Ad Hoc networks, i.e. the limitation of nodes' power.