Using 2-Opt based evolution strategy for travelling salesman problem

Harmony search algorithm that matches the (μ+1) evolution strategy, is a heuristic method simulated by the process of music improvisation. In this paper, a harmony search algorithm is directly used for the travelling salesman problem. Instead of conventional selection operators such as roulette wheel, the transformation of real number values of harmony search algorithm to order index of vertex representation and improvement of solutions are obtained by using the 2-Opt local search algorithm. Then, the obtained algorithm is tested on two different parameter groups of TSPLIB. The proposed method is compared with classical 2-Opt which randomly started at each step and best known solutions of test instances from TSPLIB. It is seen that the proposed algorithm offers valuable solutions.


Introduction
The travelling salesman problem (TSP) is one of the most popular combinatorial optimization problems in complexity theory [1].TSP for minimizing the tour length is quite difficult to solve and classified as NP-Hard, it will be time consuming to solve larger instances.However, TSP is used in many theoretical and practical applications such as manufacturing planning, logistics, and electronics manufacturing.Due to the nature of TSP, obtaining the optimal solution is not possible in polynomial time if solved via integer programming.Also, it is known that the solution time extends exponentially as the problem size grows.Therefore, as an alternative solution approach, the meta-heuristics are commonly used to determine near optimal solutions in acceptable solution times [2][3][4][5][6][7][8].
In the related literature, many known metaheuristics were used to solve TSPs for minimizing the tour lengths.For instance, Freisleben and Merz [9] presented an algorithm by using genetic algorithm (GA) to find near-optimal solution for a set of symmetric and asymmetric TSP instances and obtained high quality solutions in a reasonable time.Chowdhury et al. [10] also used GA for solving a flow-shop scheduling problem to minimize makespan via finding optimal order of cities.The simulated annealing (SA) algorithm is also used for TSP by Wang and Tian [11] in which an improved SA is employed.Meta-heuristics approach is generally used to solve the problem in reasonable time if the problem size increases.For large TSPs, Fiechter [12] used a parallel tabu search algorithm.Similarly, different types of ant colony algorithm are used for the TSP [13][14][15].Also, Wang et al. [16] developed swap operator and swap sequence in order to use particle swarm optimization (PSO) for TSP.
In our study, the harmony search algorithm was used as the core algorithm to solve TSPs.HS is first proposed by Geem et al. [5].Weyland [29] proved that HS is theoretically a special case of an evolution strategy known as (µ +1) evolution strategy [30].In Geem et al [5], the 20-cities TSP, constraint optimization problem, and water network pipeline design are solved.For 20-cities TSP, neighbouring city-going and city-inverting operators were designed.Their operators were used to find the closest city that will be visited next and to produce a new path on feasible nodes, respectively.Geem et al [5] did not give the details of the discrete structure.However, later Geem [31] detailed the HS for TSP that uses stochastic derivative for discrete variables  In addition, we directly use the index values of the normally distributed harmony numbers in our method.In this process, besides the use of metaheuristics algorithms, the hybrid approaches involving the hybridization of two or more heuristics were applied in order to eliminate the weakness of single meta-heuristics for solving the large scale TSP optimization problems [32-39].
On the other hand, HS is directly adapted for TSP.
In TSP, the main goal is to find the shortest closed tour that visits each city once and exactly once in a given list with the best route.There are tour construction methods such as the nearest neighbor, greedy, insertion heuristics, Christofides method.After the tour has been generated by any tour construction heuristics, it is improved with tour improvement heuristics such as 2-Opt, 3-Opt, k-Opt, Lin-Kernighan, Tabu-Search, Simulated Annealing, Genetic Algorithms etc.The 2-Opt approach is a well-known method used for this purpose.The 2-Opt is a simple local search algorithm and it was first proposed by Croes [2] for TSP.It swaps edges in a tour for shortening the total tour length.
The HS algorithm, a special case of evolution strategy which is called (µ+1) evolution strategy, is a meta-heuristic optimization method that inspired by the mimics of the improvisation ability of musicians.Using HS algorithm, the musical instruments are played with discrete notes under the musicians' experience and their improvisation ability randomly.The musical harmony, aesthetic standard, pitches of instruments and the improvisation process are design parameters of HS algorithm.HS works with the harmony size (HMS), the harmony considering rate and the pitch adjusting rate as optimization operators [5,31].
A brief overview of TSP from the literature especially on meta-heuristics is surveyed in this section.The rest of the paper is organized as follows: the proposed method in which the HS algorithm with its continuous structure is directly used for the TSP is presented in Section 2. With the proposed algorithm, the transformation mechanism for HS to solve the TSP is obtained by using 2-Opt local search algorithm.Then, in Section 3, the obtained algorithm is tested on two different parameter groups of TSPLIB.

Proposed algorithm: 2-Opt based harmony search algorithm
The proposed algorithm that is called 2-Opt Based Harmony Search Algorithm (2-Opt_cHS) combines the algorithms of 2-Opt and the HS.The first advantage of the proposed algorithm is to convert the real numbers into index values for solving combinatorial optimization problem such as TSP.Thus, the modified algorithm provides to solve discrete optimization problems.
In general, for TSP problems, roulette wheel selection is used in evolution strategies for the transformation between randomly generated real numbers of heuristic solutions and ordered numbers of combinatorial problem solutions.In this paper, HS algorithm with its continuous structure is directly used for the travelling salesman problem.The transformation of real numbers of continuous HS algorithm to integer numbers of discrete form is obtained by using 2-Opt local search algorithm which is used to define a function from continuous to discrete functions and vice versa.The pseudo code of the HS algorithm is given as Algorithm 1 in Table 2 [29] and the proposed algorithm is given as Algorithm 2 in Table 3.

Table 2. The pseudo code of the harmony search algorithm [29]
Algorithm 1: The Harmony Search Algorithm 1: Initialize the harmony memory with HMS randomly generated solutions 2: repeat 3: create a new solution in the following way 4: for all decision variables do 5: with probability HMCR use a value of one of the solutions in the harmony memory (selected uniform random numbers) and additionally change this value slightly with probability PAR 6: otherwise (with probability 1-HMCR) use a random value for this decision variable 7: end for 8: if the new solution is better than the worst solution in the harmony memory then 9: replace the worst solution by the new one 10: end if 11: until the maximum number of iterations has been reached 12: return the best solution in the harmony memory According to Algorithm 2, firstly, the objective function is generated with real number arrays for initial harmonics.And then, its limits and bandwidths, and the values are defined as parameters.The 2-Opt algorithm is used for designing discrete variables and is defined with the step size (v) and application parameter (opt).By using v, the 2-Opt application is used once in each v steps.
The use of v parameter is the design idea of this study as using 2-Opt at each step increases the simulation time and decreases the effect of using HS algorithm.When a solution is obtained after HS with 2-Opt procedure, it will be evaluated using the fitness function.Respecting to HMS and fitness of new solution, the new solution may be inserted in harmony memory or not.Eventually, the termination criteria can be defined as a problem dependent number of iterations or as reaching to a specific quality of solution.In this study, the algorithm will stop when maximum number of iterations is met, and otherwise the while loop case will be repeated for each iteration.
A sample TSP solution taken from TSPLIB, known as Burma14, is demonstrated in Table 2.As can be seen in Table 2, IH and NH are real Harmony numbers.By using their index values in HOI, the route information is obtained and then improved by using 2-Opt.
The proposed algorithm with respect to the pseudo-code in Algorithm 2 by taking maximum number of iteration as 5 is given.The 2-Opt is used instead of the initial solution and the 3rd iteration.At iteration 4, the optimal solution for Burma14 is obtained as 3323.In Figure 1, the route improvement at some steps are visualized for Burma14.

Computational results
In this section, some benchmark problem sets from TSPLIB95 [40] such as eil51, berlin52, st70, pr76, eil76, kroA100, kroB100, eil101, bier127, chr130, ch150, kroA150, kroB200 and lin318 are considered.As the simulation platform, i7 CPU and 4 GB RAM hardware and MATLAB® 8.2 software package are used.Also, some functions of the Matlog: Logistics Engineering Matlab Toolbox [41] are used.For the simulations, two different parameter sets are chosen that are given as two cases in Table 5.For Case 1, the parameter values are taken as the most frequently used ones in the literature.For Case 2, on the other hand, the parameters are obtained by trial and error and especially, in order to shorten the simulation time, and as a result HMS is chosen as 1.By trial and error, the acceptable value of v is taken as 3.For Case 1, the iteration is limited as 3600s or best known solution (BKS) whereas for Case 2, 500s or BKS is used.For both cases, each test instance is executed 100 times and the simulation results are analysed in Table 6 and Table 7 for both cases of Table 5 using the mentioned problem sets of TSPLIB.
In Table 6 and Table 7, #Opt/Run is the number of BKS values obtained in total of 100 runs, BKS is the best known solution, BSolj and WSolj are the obtained best and worst solutions of 100 runs of the jth instance, respectively.ASolj is the average of Soli (i=1…100) for jth instance and can be given as (1) where Soli (i=1…100) is each solution of 100 runs.ADevj and BDevj are the percentage deviations of the ASolj and BSolj from BKSj, respectively, and can be given as (2) (3)  In addition, the solution times of each case are given in Table 8.Instead of berlin52 (i=2) Case 2 has better simulation times in average.This is an expected situation as HMS value is 1 for Case 2. Fig. 2 is given in order to show the results ADevj and BDevj respectively.When the deviations for both cases are investigated from Fig. 2, it can be seen that ADevj has more deviation than BDevj.9 where it is seen that an improvement is obtained in simulation performances by using the proposed method.The classical 2-Opt is simulated by randomly generating a new route information and then applying only the 2-Opt algorithm at each step.
The performances in Table 9 are also evaluated in Table 10 as an indicator of the solution quality using the ADevj, BDevj and Opt/Run parameters between 2opt_cHS and classical 2opt algorithms.According to Table 10, it can be seen from the BKS results of the proposed 2-Opt-cHS algorithm, ADevj and BDevj average deviations are -1.10 and -0.44, respectively.On the other hand, for the classical 2-Opt algorithm, ADevj and BDevj average deviations are -6.38 and -1.72, respectively.Therefore, it is seen that by using 2-Opt together with HS, the performance is improved with respect to classical 2-Opt algorithm.Also, the proposed 2-Opt_cHS algorithm can reach BKS values of seven test instances.However, for the classical 2-Opt algorithm, BKS value of one test instance (berlin52) is obtained.Thus, less deviation values and higher #Opt/Run values of 2-Opt_CHS show the advantage obtained using the proposed method.Thus, it is seen that using only classical 2-Opt at each step, optimal solutions cannot be obtained in general.This is an indicator that the proposed method has an improvement by applying the faster HS at each step and slower 2-Opt at some steps.Table 11 is designed to compare our solutions with the results obtained from literature.It can be observed that all the average solution performances of meta-heuristics including the basic Discrete Cuckoo Search (DCS) have worse results than proposed 2-Opt_cHS.On the other hand, improved DCS of their study and proposed 2-Opt_cHS in our study, have similar performances and both are better than the other meta-heuristics mentioned in their study.

Conclusions and further research
The travelling salesman problems are mostly studied in the class of NP-Hard problems.In order to solve these problems many techniques and solution approaches are designed in the literature.In this paper, a harmony search algorithm is directly used as a solution method.The transformation of real numbers of continuous harmony search algorithm to integer numbers of discrete form is obtained by using index values and the 2-Opt local search algorithm.As computational test instances the problem sets of eil51, berlin52, st70, pr76, eil76, kroA100, kroB100, eil101, bier127, ch130, ch150, kroA150, kroB200 and lin318 from TSPLIB are selected and two different cases are designed for experimental study.The results have shown that acceptable solutions can be obtained with the given algorithm.
The results of the proposed method are compared with conventional 2-Opt algorithm and also with other meta-heuristics.Consequently, it is shown that by using the proposed 2-Opt_cHS algorithm useful results could be obtained.The proposed method can be used for all TSP variants such as production planning, electronic manufacturing, and logistics.

Figure 2 .
Figure 2. The results of ADevj and BDevj for Case 1 and Case

Table 3 .
The pseudo code of the proposed algorithm: 2-Opt based harmony search Figure 1.Burma14 solution graphs in the proposed algorithm iterations 7: end for 8: if the new solution is better than the worst solution in the harmony memory then 9: replace the worst solution by the new one 10: end if 11: until the maximum number of iterations has been reached 12: return the best solution in the harmony memory

Table 5 .
The parameter settings

Table 6 .
It can be seen from Table6and Table7that the ADevj solutions of Case 2 are all better than Case 1 whereas BDevj (j=14) of Lin318 is only slightly worse for Case 2. When #Opt/Run values are taken into consideration, one can see that the parameter set of Case 2 is better in finding the BKS values in total simulations.Summary of computational results for the proposed method for Case 1

Table 7 .
Summary of computational results for the proposed method for Case 2

Table 8 .
Simulation times for test instances of Case 1 and Case 2

Table 9 .
Solutions for test instances of 2opt_cHS and classical 2opt

Table 10 .
Relatively comparison for the solutions of 2opt_cHS and classical 2opt

Table 11 .
Comparison of ASol results of the proposed method with different meta-heuristics from the literature