SlideShare a Scribd company logo
1 of 6
Download to read offline
A Fast TSP Solver Using GA on JAVA
Hiroaki SENGOKU Ikuo YOSHIHARA
Systems Development Laboratory, Graduate School of Engineering,
Hitachi, Ltd. Tohoku University
Kawasaki, 215 JAPAN Sendai, 980-77 JAPAN
Abstract
A hybrid algorithm using GA and heuristics for
rapid solution of Travelling Salesperson Problems
(TSP) is presented. We developed a JAVA program
based on this algorithm. Visiting our web pages, ev-
eryone can easily try our TSP solver. Since JAVA
programs are executable on many platforms, any one
who design a new TSP algorithm can compare his own
solver and ours on the same machine. Using our pro-
gram as the criterion, TSP researchers can evaluate
their algorithms objectively.
1 Introduction
The Genetic Algorithm (GA)[1] is an optimizing al-
gorithm that is modeled after the evolution of organ-
isms. Some of the GA's merits are that it can be easily
developed because it does not require detailed knowl-
edge about the problem, it can search globally, and it
can adapt to the changing conditions in the problem.
Despite of these merits, GA is often slower than
conventional methods such as heuristic searches. This
is because GA does not utilize explicitly the knowledge
of how to search for the solutions. Therefore, hybrid
methods that combine GA with other techniques have
been attempted.
The TSP solver we presented[2] is one of the hy-
brid methods. It uses GA and the 2opt method (sec-
tion 2.1). Owing to the 2opt, it is much faster than
other TSP solvers based on GA alone.
Generally, it is dicult to compare two approximate
algorithms objectively. Some algorithms have the ad-
vantage of high speed, but have the disadvantage of a
low success rate in
nding the optimum solution.
The best way to compare two methods is by running
them both on the same machine. But there are few
such programs in public domain[4], and we have not
found a program that can solve the problems listed in
TSPLIB[5].
Consequently, we wrote a JAVA1 program based on
1JAVA is a trademark of Sun Microsystems, Inc.
our proposed method, and made it public on our page
on the World Wide Web (WWW). JAVA programs are
executable on many platforms, so people who have de-
veloped a TSP solver can compare their programs and
ours by running both programs on the same machine
under equal conditions.
We also developed a graphical user interface. Peo-
ple can freely situate towns by using a mouse, and
solve the problem they constructed. It's easy and fun.
It's helpful for students studying the basics of com-
puter algorithms.
In section 2, we explain our method. In section 3,
we show the WWW page in which we present our TSP
program.
2 A TSP solver: 2optGA
We present a hybrid method[2] that uses GA and
the 2opt method. In our GA, the 2opt method pro-
vides mutation, while the crossover operator provides
the capability of jumping out from the local minima,
where the solution often falls where only 2opt is used.
The algorithm consists of the following steps.
Initialization: Generation of M individuals ran-
domly.
Natural Selection: Eliminate pe% individuals. The
population decreases by M 2pe=100.
Multiplication: Choose M 2pe=100 pairs of individ-
uals randomly and produce an ospring from each
pair of individuals. The population reverts to the
initial population M.
Mutation by 2opt: Choose pi% of individuals ran-
domly and improve them by the 2opt method.
The elite individual, or the individual that has
the best
tness value in the population, is always
chosen. If the individual is already improved, do
nothing, because it cannot be further improved
by 2opt.
We now describe the detail of each step.
2.1 Mutation by 2opt
The 2opt method is one of the most well-known lo-
cal search algorithms among TSP solving algorithms.
It improves the tour edge by edge and reverses the or-
der of the subtour. For example, imagine a tour as
shown in the upper part of Fig. 1. Remove the two
edges ab and cd, and reverse the order of the subtour
(from b to c), and add the two edges ac and bd. This
gives us a tour as shown in the lower part of Fig. 1.
The lower tour is shorter than the upper one because
ab + cd  ac + bd.
a
b
c
d
a
b
c
d
Figure 1: The 2opt method
We check every pair of edges, for example, ab and
cd. If ab +cd  ac +bd holds, we improve them in the
same way as shown in Fig. 1. Actually, if both ac  ab
and bd  cd hold, then it is not necessary to check the
edges. Therefore we can skip the pairs whose edges
are far away from each other.
We repeat the procedures described above until no
further improvement can be made.
2.2 Crossover in Multiplication
When we apply the 2opt method to a solution, the
solution often falls into a local minimum. Then it can-
not be improved further by the 2opt method. Con-
sider two solutions that have fallen into dierent local
minima. Potentially, each solution may have the best
subtour for a dierent part of the tour. Then, we can
make a better solution if we combine those best sub-
tours appropriately. We cannot say, of course, which
of the subtours are good, but after many trials, we can
expect ospring solutions to be located in the valley
of the global minimum as shown in Fig. 2.
We propose a new crossover operator that acquires
the longest possible sequence of parents' subtours.
We named it `Greedy Subtour Crossover (GSX)'. We
showed[3] by experiments that using the GSX, the so-
lution can pop up from local minima more eectively
than by using simulated annealing (SA) methods.
In the GSX, we use the path representation for
a genetic coding. For example, the chromosome
tour
tourlength
child
crossover
Figure 2: Pop-up from local minima.
g = (D; H; B; A; C; F; G; E) means that the salesper-
son visits towns D, H, B, A, ..., E, successively, and
returns to town D.
D H B A C F G E
B C D G H F E A
H B A C D G
F E
Pick up alphabets from the parents alternately.
Parents
Child
Add the rest of alphabets
in the random order.
Figure 3: Greedy Subtour Crossover
Algorithm: Greedy Subtour Crossover
Inputs: Chromosomes ga = (a0; a1; : : : ; an01) and
gb = (b0; b1; : : : ; bn01).
Outputs: The ospring chromosome g.
procedure crossover(ga,gb) f
fa true
fb true
choose town t randomly
choose x, where ax = t
choose y, where by = t
g t
do f
x x 01 (mod n),
y y + 1 (mod n).
if fa = true then f
if ax 62 g then f
g ax 1g,
g else f
fa false.
g
g
if fb = true then f
if by 62 g then f
g g 1by,
g else f
fb false.
g
g
g while fa = true or fb = true
if jgj  jgaj then f
add the rest of towns
to g in the random order
g
return g
g
Note that 1 in g ax 1 g is the concatenation
operator, and that sentence means to add ax before
the chromosome g.
An example is shown in Fig. 3. Suppose that chro-
mosomes of parents are ga = (D; H; B; A; C; F; G; E)
and gb = (B; C; D; G; H; F; E; A). First, choose one
town at random. In this example, town C is chosen.
Then, x = 4 and y = 1 because a4 = C and b1 = C
respectively. Now the child g is (C).
Next, pick up towns from the parents alternately.
Begin with a3 (town A) because x 4 0 1 = 3, and
next is b2 (town D) because y 1 + 1 = 2. The child
becomes g = (A; C; D).
In the same way, add a2 (town B), b3 (town
G), a1 (town H), and the child becomes g =
(H; B; A; C; D; G). Now the next town is b4 = H and
town H has already appeared in the child (remember
the salesperson may not visit the same town twice), so
we can't add any more towns from parent gb.
Therefore we add towns from parent ga. The next
town is a0 = D, but D is already used. Thus we can't
add towns from parent ga, either.
Then, we add the rest of the towns, i.e., E and F,
to the child in the random order. Finally the child is
g = (H; B; A; C; D; G; F; E).
2.3 Natural Selection
Eliminate R = M 2 pe=100 individuals. In the so-
called simple GA, the possibility of survival is pro-
portional to the
tness value, but we pay more atten-
tion to the diversity of the population. We eliminate
similar individuals to maintain the diversity in order
to avoid the immature convergence that is one of the
well-known problems in GA.
First, sort the individuals in

More Related Content

Similar to Greedy subtourcrossover.arob98

Tao Fayan_Iso and Full_volume rendering
Tao Fayan_Iso and Full_volume renderingTao Fayan_Iso and Full_volume rendering
Tao Fayan_Iso and Full_volume renderingFayan TAO
 
A Decomposition Technique For Solving Integer Programming Problems
A Decomposition Technique For Solving Integer Programming ProblemsA Decomposition Technique For Solving Integer Programming Problems
A Decomposition Technique For Solving Integer Programming ProblemsCarrie Romero
 
Histogram Gabor Phase Pattern and Adaptive Binning Technique in Feature Selec...
Histogram Gabor Phase Pattern and Adaptive Binning Technique in Feature Selec...Histogram Gabor Phase Pattern and Adaptive Binning Technique in Feature Selec...
Histogram Gabor Phase Pattern and Adaptive Binning Technique in Feature Selec...CSCJournals
 
RESEARCH ON FUZZY C- CLUSTERING RECURSIVE GENETIC ALGORITHM BASED ON CLOUD CO...
RESEARCH ON FUZZY C- CLUSTERING RECURSIVE GENETIC ALGORITHM BASED ON CLOUD CO...RESEARCH ON FUZZY C- CLUSTERING RECURSIVE GENETIC ALGORITHM BASED ON CLOUD CO...
RESEARCH ON FUZZY C- CLUSTERING RECURSIVE GENETIC ALGORITHM BASED ON CLOUD CO...ijaia
 
Distributed Formal Concept Analysis Algorithms Based on an Iterative MapReduc...
Distributed Formal Concept Analysis Algorithms Based on an Iterative MapReduc...Distributed Formal Concept Analysis Algorithms Based on an Iterative MapReduc...
Distributed Formal Concept Analysis Algorithms Based on an Iterative MapReduc...Ruairi de Frein
 
A NEW APPROACH IN DYNAMIC TRAVELING SALESMAN PROBLEM: A HYBRID OF ANT COLONY ...
A NEW APPROACH IN DYNAMIC TRAVELING SALESMAN PROBLEM: A HYBRID OF ANT COLONY ...A NEW APPROACH IN DYNAMIC TRAVELING SALESMAN PROBLEM: A HYBRID OF ANT COLONY ...
A NEW APPROACH IN DYNAMIC TRAVELING SALESMAN PROBLEM: A HYBRID OF ANT COLONY ...ijmpict
 
Linear algebra application in linear programming
Linear algebra application in linear programming Linear algebra application in linear programming
Linear algebra application in linear programming Lahiru Dilshan
 
Hybrid iterated local search algorithm for optimization route of airplane tr...
Hybrid iterated local search algorithm for optimization route of  airplane tr...Hybrid iterated local search algorithm for optimization route of  airplane tr...
Hybrid iterated local search algorithm for optimization route of airplane tr...IJECEIAES
 
C Programming Interview Questions
C Programming Interview QuestionsC Programming Interview Questions
C Programming Interview QuestionsGradeup
 
Lego like spheres and tori, enumeration and drawings
Lego like spheres and tori, enumeration and drawingsLego like spheres and tori, enumeration and drawings
Lego like spheres and tori, enumeration and drawingsMathieu Dutour Sikiric
 
Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...
Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...
Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...Ahmed Gamal Abdel Gawad
 
Operation research model for solving TSP
Operation research model for solving TSPOperation research model for solving TSP
Operation research model for solving TSPDrGovindshaysharma
 
A review of automatic differentiationand its efficient implementation
A review of automatic differentiationand its efficient implementationA review of automatic differentiationand its efficient implementation
A review of automatic differentiationand its efficient implementationssuserfa7e73
 
Double Patterning
Double PatterningDouble Patterning
Double PatterningDanny Luk
 
Comparison Study of Multiple Traveling Salesmen Problem using Genetic Algorithm
Comparison Study of Multiple Traveling Salesmen Problem using Genetic AlgorithmComparison Study of Multiple Traveling Salesmen Problem using Genetic Algorithm
Comparison Study of Multiple Traveling Salesmen Problem using Genetic AlgorithmIOSR Journals
 

Similar to Greedy subtourcrossover.arob98 (20)

1406
14061406
1406
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Tao Fayan_Iso and Full_volume rendering
Tao Fayan_Iso and Full_volume renderingTao Fayan_Iso and Full_volume rendering
Tao Fayan_Iso and Full_volume rendering
 
Computation Assignment Help
Computation Assignment Help Computation Assignment Help
Computation Assignment Help
 
A Decomposition Technique For Solving Integer Programming Problems
A Decomposition Technique For Solving Integer Programming ProblemsA Decomposition Technique For Solving Integer Programming Problems
A Decomposition Technique For Solving Integer Programming Problems
 
Histogram Gabor Phase Pattern and Adaptive Binning Technique in Feature Selec...
Histogram Gabor Phase Pattern and Adaptive Binning Technique in Feature Selec...Histogram Gabor Phase Pattern and Adaptive Binning Technique in Feature Selec...
Histogram Gabor Phase Pattern and Adaptive Binning Technique in Feature Selec...
 
RESEARCH ON FUZZY C- CLUSTERING RECURSIVE GENETIC ALGORITHM BASED ON CLOUD CO...
RESEARCH ON FUZZY C- CLUSTERING RECURSIVE GENETIC ALGORITHM BASED ON CLOUD CO...RESEARCH ON FUZZY C- CLUSTERING RECURSIVE GENETIC ALGORITHM BASED ON CLOUD CO...
RESEARCH ON FUZZY C- CLUSTERING RECURSIVE GENETIC ALGORITHM BASED ON CLOUD CO...
 
Distributed Formal Concept Analysis Algorithms Based on an Iterative MapReduc...
Distributed Formal Concept Analysis Algorithms Based on an Iterative MapReduc...Distributed Formal Concept Analysis Algorithms Based on an Iterative MapReduc...
Distributed Formal Concept Analysis Algorithms Based on an Iterative MapReduc...
 
A NEW APPROACH IN DYNAMIC TRAVELING SALESMAN PROBLEM: A HYBRID OF ANT COLONY ...
A NEW APPROACH IN DYNAMIC TRAVELING SALESMAN PROBLEM: A HYBRID OF ANT COLONY ...A NEW APPROACH IN DYNAMIC TRAVELING SALESMAN PROBLEM: A HYBRID OF ANT COLONY ...
A NEW APPROACH IN DYNAMIC TRAVELING SALESMAN PROBLEM: A HYBRID OF ANT COLONY ...
 
Linear algebra application in linear programming
Linear algebra application in linear programming Linear algebra application in linear programming
Linear algebra application in linear programming
 
Reinforcement Learning - DQN
Reinforcement Learning - DQNReinforcement Learning - DQN
Reinforcement Learning - DQN
 
Hybrid iterated local search algorithm for optimization route of airplane tr...
Hybrid iterated local search algorithm for optimization route of  airplane tr...Hybrid iterated local search algorithm for optimization route of  airplane tr...
Hybrid iterated local search algorithm for optimization route of airplane tr...
 
C Programming Interview Questions
C Programming Interview QuestionsC Programming Interview Questions
C Programming Interview Questions
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
 
Lego like spheres and tori, enumeration and drawings
Lego like spheres and tori, enumeration and drawingsLego like spheres and tori, enumeration and drawings
Lego like spheres and tori, enumeration and drawings
 
Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...
Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...
Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...
 
Operation research model for solving TSP
Operation research model for solving TSPOperation research model for solving TSP
Operation research model for solving TSP
 
A review of automatic differentiationand its efficient implementation
A review of automatic differentiationand its efficient implementationA review of automatic differentiationand its efficient implementation
A review of automatic differentiationand its efficient implementation
 
Double Patterning
Double PatterningDouble Patterning
Double Patterning
 
Comparison Study of Multiple Traveling Salesmen Problem using Genetic Algorithm
Comparison Study of Multiple Traveling Salesmen Problem using Genetic AlgorithmComparison Study of Multiple Traveling Salesmen Problem using Genetic Algorithm
Comparison Study of Multiple Traveling Salesmen Problem using Genetic Algorithm
 

Recently uploaded

Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTSérgio Sacani
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsSérgio Sacani
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |aasikanpl
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...anilsa9823
 
Broad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptxBroad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptxjana861314
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPirithiRaju
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfnehabiju2046
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxUmerFayaz5
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real timeSatoshi NAKAHIRA
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfSumit Kumar yadav
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfSumit Kumar yadav
 
Cultivation of KODO MILLET . made by Ghanshyam pptx
Cultivation of KODO MILLET . made by Ghanshyam pptxCultivation of KODO MILLET . made by Ghanshyam pptx
Cultivation of KODO MILLET . made by Ghanshyam pptxpradhanghanshyam7136
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...ssifa0344
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​kaibalyasahoo82800
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...Sérgio Sacani
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoSérgio Sacani
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfmuntazimhurra
 
G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptMAESTRELLAMesa2
 

Recently uploaded (20)

Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOST
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
 
Broad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptxBroad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptx
 
9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service
9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service
9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdf
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptx
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real time
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdf
 
CELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdfCELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdf
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdf
 
Cultivation of KODO MILLET . made by Ghanshyam pptx
Cultivation of KODO MILLET . made by Ghanshyam pptxCultivation of KODO MILLET . made by Ghanshyam pptx
Cultivation of KODO MILLET . made by Ghanshyam pptx
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on Io
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdf
 
G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.ppt
 

Greedy subtourcrossover.arob98

  • 1. A Fast TSP Solver Using GA on JAVA Hiroaki SENGOKU Ikuo YOSHIHARA Systems Development Laboratory, Graduate School of Engineering, Hitachi, Ltd. Tohoku University Kawasaki, 215 JAPAN Sendai, 980-77 JAPAN Abstract A hybrid algorithm using GA and heuristics for rapid solution of Travelling Salesperson Problems (TSP) is presented. We developed a JAVA program based on this algorithm. Visiting our web pages, ev- eryone can easily try our TSP solver. Since JAVA programs are executable on many platforms, any one who design a new TSP algorithm can compare his own solver and ours on the same machine. Using our pro- gram as the criterion, TSP researchers can evaluate their algorithms objectively. 1 Introduction The Genetic Algorithm (GA)[1] is an optimizing al- gorithm that is modeled after the evolution of organ- isms. Some of the GA's merits are that it can be easily developed because it does not require detailed knowl- edge about the problem, it can search globally, and it can adapt to the changing conditions in the problem. Despite of these merits, GA is often slower than conventional methods such as heuristic searches. This is because GA does not utilize explicitly the knowledge of how to search for the solutions. Therefore, hybrid methods that combine GA with other techniques have been attempted. The TSP solver we presented[2] is one of the hy- brid methods. It uses GA and the 2opt method (sec- tion 2.1). Owing to the 2opt, it is much faster than other TSP solvers based on GA alone. Generally, it is dicult to compare two approximate algorithms objectively. Some algorithms have the ad- vantage of high speed, but have the disadvantage of a low success rate in
  • 2. nding the optimum solution. The best way to compare two methods is by running them both on the same machine. But there are few such programs in public domain[4], and we have not found a program that can solve the problems listed in TSPLIB[5]. Consequently, we wrote a JAVA1 program based on 1JAVA is a trademark of Sun Microsystems, Inc. our proposed method, and made it public on our page on the World Wide Web (WWW). JAVA programs are executable on many platforms, so people who have de- veloped a TSP solver can compare their programs and ours by running both programs on the same machine under equal conditions. We also developed a graphical user interface. Peo- ple can freely situate towns by using a mouse, and solve the problem they constructed. It's easy and fun. It's helpful for students studying the basics of com- puter algorithms. In section 2, we explain our method. In section 3, we show the WWW page in which we present our TSP program. 2 A TSP solver: 2optGA We present a hybrid method[2] that uses GA and the 2opt method. In our GA, the 2opt method pro- vides mutation, while the crossover operator provides the capability of jumping out from the local minima, where the solution often falls where only 2opt is used. The algorithm consists of the following steps. Initialization: Generation of M individuals ran- domly. Natural Selection: Eliminate pe% individuals. The population decreases by M 2pe=100. Multiplication: Choose M 2pe=100 pairs of individ- uals randomly and produce an ospring from each pair of individuals. The population reverts to the initial population M. Mutation by 2opt: Choose pi% of individuals ran- domly and improve them by the 2opt method. The elite individual, or the individual that has the best
  • 3. tness value in the population, is always chosen. If the individual is already improved, do nothing, because it cannot be further improved by 2opt. We now describe the detail of each step.
  • 4. 2.1 Mutation by 2opt The 2opt method is one of the most well-known lo- cal search algorithms among TSP solving algorithms. It improves the tour edge by edge and reverses the or- der of the subtour. For example, imagine a tour as shown in the upper part of Fig. 1. Remove the two edges ab and cd, and reverse the order of the subtour (from b to c), and add the two edges ac and bd. This gives us a tour as shown in the lower part of Fig. 1. The lower tour is shorter than the upper one because ab + cd ac + bd. a b c d a b c d Figure 1: The 2opt method We check every pair of edges, for example, ab and cd. If ab +cd ac +bd holds, we improve them in the same way as shown in Fig. 1. Actually, if both ac ab and bd cd hold, then it is not necessary to check the edges. Therefore we can skip the pairs whose edges are far away from each other. We repeat the procedures described above until no further improvement can be made. 2.2 Crossover in Multiplication When we apply the 2opt method to a solution, the solution often falls into a local minimum. Then it can- not be improved further by the 2opt method. Con- sider two solutions that have fallen into dierent local minima. Potentially, each solution may have the best subtour for a dierent part of the tour. Then, we can make a better solution if we combine those best sub- tours appropriately. We cannot say, of course, which of the subtours are good, but after many trials, we can expect ospring solutions to be located in the valley of the global minimum as shown in Fig. 2. We propose a new crossover operator that acquires the longest possible sequence of parents' subtours. We named it `Greedy Subtour Crossover (GSX)'. We showed[3] by experiments that using the GSX, the so- lution can pop up from local minima more eectively than by using simulated annealing (SA) methods. In the GSX, we use the path representation for a genetic coding. For example, the chromosome tour tourlength child crossover Figure 2: Pop-up from local minima. g = (D; H; B; A; C; F; G; E) means that the salesper- son visits towns D, H, B, A, ..., E, successively, and returns to town D. D H B A C F G E B C D G H F E A H B A C D G F E Pick up alphabets from the parents alternately. Parents Child Add the rest of alphabets in the random order. Figure 3: Greedy Subtour Crossover Algorithm: Greedy Subtour Crossover Inputs: Chromosomes ga = (a0; a1; : : : ; an01) and gb = (b0; b1; : : : ; bn01). Outputs: The ospring chromosome g. procedure crossover(ga,gb) f fa true fb true choose town t randomly choose x, where ax = t choose y, where by = t g t do f x x 01 (mod n), y y + 1 (mod n). if fa = true then f if ax 62 g then f g ax 1g, g else f fa false. g g if fb = true then f if by 62 g then f g g 1by, g else f
  • 5. fb false. g g g while fa = true or fb = true if jgj jgaj then f add the rest of towns to g in the random order g return g g Note that 1 in g ax 1 g is the concatenation operator, and that sentence means to add ax before the chromosome g. An example is shown in Fig. 3. Suppose that chro- mosomes of parents are ga = (D; H; B; A; C; F; G; E) and gb = (B; C; D; G; H; F; E; A). First, choose one town at random. In this example, town C is chosen. Then, x = 4 and y = 1 because a4 = C and b1 = C respectively. Now the child g is (C). Next, pick up towns from the parents alternately. Begin with a3 (town A) because x 4 0 1 = 3, and next is b2 (town D) because y 1 + 1 = 2. The child becomes g = (A; C; D). In the same way, add a2 (town B), b3 (town G), a1 (town H), and the child becomes g = (H; B; A; C; D; G). Now the next town is b4 = H and town H has already appeared in the child (remember the salesperson may not visit the same town twice), so we can't add any more towns from parent gb. Therefore we add towns from parent ga. The next town is a0 = D, but D is already used. Thus we can't add towns from parent ga, either. Then, we add the rest of the towns, i.e., E and F, to the child in the random order. Finally the child is g = (H; B; A; C; D; G; F; E). 2.3 Natural Selection Eliminate R = M 2 pe=100 individuals. In the so- called simple GA, the possibility of survival is pro- portional to the
  • 6. tness value, but we pay more atten- tion to the diversity of the population. We eliminate similar individuals to maintain the diversity in order to avoid the immature convergence that is one of the well-known problems in GA. First, sort the individuals in
  • 8. tness value of adjoining individuals. If the dierence is less than (a small positive real num- ber), eliminate preceding individual while the number of eliminated individuals is less than R. Let r be the number of eliminated individuals. Next, if r R, eliminate R 0 r individuals in the order of lowest
  • 9. tness value. 3 JAVA applet 3.1 Applet on WWW We developed a JAVA applet based on the proposed method, and put it on our WWW page: http://www.hitachi.co.jp /Div/sdl/e-naiyo/e-seika22/TSP.html It is easy to use. First, using a mouse, put towns in the rectangular
  • 10. eld. Then, push the start but- ton. The applet solves the problem you've just made and displays the tour and its length (Fig. 4). The parameters of the 2optGA method, i.e., Population (M), Selection (pe), 2opt (pi), are adjustable by
  • 12. eld on the applet. We announced the web page on the Net News in Japanese (fj.* newsgroups) only once in July 1996. Since then, the page has been accessed more than 200 times a month. One person who sent us comments had mistakenly thought that GA was a tool only for experiments, and that GA would be so slow that it could not be applied to practical problems. But after accessing our web pages, he could understand why GA is usable. Figure 5: Examples of the problems the students made. We utilized the web page for education. We intro- duced the page to the students majoring in computer science at the University of Tokyo and to the audience at a Hitachi employee seminar. They enjoyed mak-
  • 13. Netscape is a trademark of Netscape Communications Corporation. Figure 4: applet on WWW ing new problems one after another and executing the applet. Some of those problems are shown in Fig. 5. Some students added and removed a few towns in their problems and watched the transformation of the solution. Some tried to alter the parameters of the 2optGA and observe what would happen. Through many trials, they got the feeling of the diculty of the TSP, and gained a concrete understanding of the optimization problems. A summary of comments from the students follows: Good Points { It's easy and fun. { I can see the progress of solving the problem simultaneously. { I had thought that web pages were only for reading, so I was surprised to see your page for solving the TSP.
  • 14. Bad Points { No grid. The coordinates of the mouse are not displayed, so I cannot put towns accu- rately into the places I want. { I can't try pre-de
  • 15. ned problems. I can't save problems. (Note: the current version of the applet can read the TSP
  • 16. le that contains the coordinates of towns.) { I want to see the convergence graph. I wish to check not only the elite but also the other individuals in the population. It would be convenient if the CPU time consumed to solve the problem was displayed. We also present the following sample problems in our WWW pages: randomly located 100 towns double circle 192 towns (C-type) double circle 192 towns (O-type) Double circle problems were used as benchmarks by Yamamura et al.[6] The minimum solutions of the problems are known and they are either C-type or O-type. ‘C’-type ‘O’-type inner / outer = 3/5 inner / outer = 4/5 Figure 6: the minimum solutions of the double cir- cle problems As shown in Fig. 6, the type of solution that will yield the minimum, depends on the number of towns and the ratio of the radii of the inner and outer circles. 3.2 Stand-alone Application The applet can also be used as a stand-alone ap- plication. First, download class
  • 17. les listed in Table 1 and sample problems listed in Table 2 from the URL: http://www.hitachi.co.jp /Div/sdl/e-naiyo/e-seika22/ Table 1: Class
  • 18. les to download. File name Size Cities.class 3k City.class 1k GA.class 3k Gene.class 3k Sort.class 1k Sortable.class 1k TSP.class 8k TspRoute.class 4k Table 2: Sample problems. File name Problem gr96.data Africa-Subproblem of 666-city TSP gr202.data Europe-Subproblem of 666-city TSP test100.dat Randomly located 100 towns c192-4682.dat Double circle 192 towns (C-type) c192-4684.dat Double circle 192 towns (O-type) Africa-Subproblem of 666-city TSP and Europe- Subproblem of 666-city TSP are contained in TSPLIB[5]. TSP.class contains the main method, so execute that
  • 19. le as a JAVA application with arguments `
  • 22. le- name', is the name of the TSP
  • 23. le that contains the location of towns of the TSP to be solved. The second arguments, `generation', is the maximum generation to be evolved. Optional ags listed in Table 3 can be used. Each line in the TSP
  • 24. le represents the coordinates of a town and consists of two
  • 25. elds separated by a comma. The
  • 26. rst
  • 27. eld means the X coordinate of the town and the second
  • 28. eld means the Y coordinate. The cost between two towns is measured as the Eu- clidean distance between the coordinates of each town. If the TSP
  • 29. le contains the line EDGE_WEIGHT_TYPE: GEO the cost is de
  • 30. ned by the geographical distance of two towns, i.e., the distance on the earth, instead of
  • 31. Table 3: Optional ags of TSP.class Option Meaning Default -p M The population 100 -e pe Eliminate pe% individuals 30 -R pi Improve pi% individuals by 2opt 20 -v Increment verbosity level the Euclidean distance. The X and Y coordinates de- scribed above mean the latitude and the longitude re- spectively. If the TSP
  • 32. le contains the line Min: n where n is the positive real number, the program will stop when the elite, whose tour length is n, is found. On Windows295 with the Java Development Kit (JDK)[7], for example, type the following command in the MS-DOS2 Prompt window. java TSP -v -p 200 gr96.data 300 That command means to solve the TSP stored in the
  • 33. le `gr96.data' (Africa-Subproblem of 666-city TSP in TSPLIB[5]), where the population is 200, and the maximum generation is 300. The output from the command follows (partially omitted): C:java TSP -v -p 200 gr96.data 300 File: gr96.data Population: 200 Selection: 30 % 2 opt: 20 % 1:3[93 94 92 91 76 11111111111111111111 27 64 95]57284 2:253[94 93 95 64 65 1111111111111111 76 91 92]55840 3:119[37 34 33 32 10 1111111111111111 31 35 36]55481 19:1251[49 51 52 54 50 111111111111 47 46 45]55332 44:2646[93 94 92 91 76 111111111111 65 64 95]55322 120:7132[41 40 39 38 78 1111111111 49 48 42]55291 165:9780[49 45 46 47 53 1111111111 54 52 51]55259 180:10692[52 51 49 45 46 11111111 48 50 54]55209 The program outputs the elite, when a new elite is 2MS-DOS and Windows are registered trademarks of Mi- crosoft Corporation found, in the following format: g : i [ tour ] ` where g, i, tour, and ` mean the generation, the ID of the individual, the tour (a list of towns in the visiting order) that corresponds to the individual, and the length of the tour. The last line, for example, says that a new elite is found at 180th generation, it is the 10692nd individual, and the length of the tour is 55209. According to TSPLIB, it is the minimum solution. 4 Conclusion We presented an algorithm for rapid solution of the TSP that combines the GA and the 2opt method. We published a program based on the algorithm on our web pages. Because the program is written in JAVA language and can be executed on many platforms, any- one can verify the eciency of our algorithm. Anyone who designed a new algorithm can compare his own TSP solver with ours by running both programs on the same machine. Our TSP solver is useful as a criterion for evaluating the performance of TSP solvers. References [1] Holland, J.H.: Adaptation in Natural and Arti
  • 34. - cial Systems, Univ. of Michigan Press (1975) [2] Sengoku, H., Yoshihara, I.: A Fast TSP Solu- tion using Genetic Algorithm (Japanese), Infor- mation Processing Society of Japan 46th Nat'l Conv. (1993) [3] Sengoku, H., Yoshihara, I.: An Evaluation of Op- timizing Capability of Genetic Algorithm | GA vs SA | (Japanese), Information Processing So- ciety of Japan 47th Nat'l Conv. (1993) [4] Moscato, P.: TSPBIB, http://www.ing.unlp.edu. ar/cetad/mos/TSPBIB_home.html [5] Reinelt, G.: TSPLIB, ftp://softlib.rice.edu/pub/ tsplib/tsplib.tar [6] Yamamura, M., Ono, T., Kobayashi, S.: Character-Preserving Genetic Algorithms for Traveling Salesman Problem (Japanese), Jour- nal of Japanese Society for Arti
  • 35. cial Intelligence Vol.7, No.6 (1992) [7] Cornell, G., Horstmann, C.S.: core JAVA, Sun- Soft Press (1996)