Genetic Algorithm For Finding Shortest Paths Problem: June 2018

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/326918062

Genetic Algorithm for finding shortest paths Problem

Conference Paper · June 2018


DOI: 10.1145/3234698.3234725

CITATION READS
1 702

3 authors, including:

Shaymaa Alhayali Osman N. Ucan


University of Mosul Altinbas University
12 PUBLICATIONS   19 CITATIONS    34 PUBLICATIONS   152 CITATIONS   

SEE PROFILE SEE PROFILE

Some of the authors of this publication are also working on these related projects:

improving IDS alerts by using data mining techniques View project

yes this is my and we make confference in TURKYE View project

All content following this page was uploaded by Shaymaa Alhayali on 16 May 2021.

The user has requested enhancement of the downloaded file.


Genetic Algorithm for finding shortest paths Problem
Shaymaa Al-hayali Prof. Osman Ucan Assoc. Prof Oguz Bayat
Faculty of Engineering Faculty of Engineering Faculty of Engineering
Altinbas University Altinbas University Altinbas University
Istanbul, Turkey Istanbul, Turkey Istanbul, Turkey
shaymaa.alhayali@ogr.altinbas. osman.ucan@altinbas.edu.tr oguz.bayat@altinbas.edu.tr
edu.tr

ABSTRACT
Genetic algorithm is used for analyzing business problems mostly
applied to find solution for business challenges. Genetic algorithm
1. INTRODUCTION
generates many solutions to a single problem each one with In supermarkets the travel manager mostly travels around different
different performance some are better than other in performance. supermarkets. The manager wants to visit the supermarket on time
and use shortest path for this problem I use genetic algorithm to
Finding shortest path has many applications in different fields. The provide the manager with shortest path. First get all the location
purpose of this paper is to find the business problem related to data of supermarkets where the manager visits in working hours
supermarkets and give the solution to this problem using genetic and then apply genetic algorithm on these values to provide the
algorithm. In this paper we chose supermarkets in different location solution [1].
and we want to find the shortest path for the manager to visit among
these supermarkets with shortest distance, therefore in genetic This research paper is about providing the efficient method for path
algorithm the evaluation function finds all the relevant variables of finding in Business problems. Genetic algorithm processes the
Geno type and then evaluates fitness function on these Geno existing data and generates the new result which is more accurate
variables using crossover and mutation techniques for sorting out than the previous one.
relevant values. In GA the fitness function is the total time elapsed Genetic Algorithms focus on processing data and find all the
for the target to achieve their goal. We use the fitness function on possible combination and path between them which provide more
population data with respect to crossover and mutation function for efficient solution to complete the task in low cost. Genetic
training datasets. The main problems in Business, science and algorithm provides multiple solutions for a single problem.
engineering are to find the short path in different activities like
visiting different places or transferring some data in minimum time.
The genetic algorithm provides efficient method to provide
optimizations of these problems. To solve the supermarket manger
traveling problem we encode the datasets of our problem using GA
and initialize all the variables. The estimation values of the
locations are set as a parameter to genetic algorithm and find the
best method by using the MDL technique (Minimum Description
length). Genetic algorithms are very efficient for selection and
genetics of natural values.

CCS Concepts
• Theory of computation Evolutionary algorithms • Software
and its engineering Genetic programming • Mathematics of Figure 1 Genetic Algorithm reproduction cycle
computing~Paths and connectivity problems
Figure 1 shows the genetic algorithm reproduction cycle process.
Keywords Parents are selected at random with selection chances biased in
Genetic algorithm, MDL, data processing, evolutionary algorithm, relation to chromosome evaluations. In genetic algorithm parent’s
management system. classes are selected in random bases and use mutation and cross
over operator for the values. Mutation is the modification of data
sets which restore the missing information in the population data.
Permission to make digital or hard copies of all or part of this work for
personal or classroom use is granted without fee provided that copies are
not made or distributed for profit or commercial advantage and that copies 2. DATA COLLECTION
bear this notice and the full citation on the first page. To copy otherwise, We collect the location data of supermarkets and store these
or republish, to post on servers or to redistribute to lists, requires prior locations in a set of arrays. In figure 2 the data is shown in the form
specific permission and/or a fee. of latitude and longitude in the form of blue dots which are the
ICEMIS’18, June 19–21, 2018, Istanbul, Turkey. locations of supermarkets [1].
Copyright 2018 ACM ISBN 978-1-4503-6392-1/18/04…$15.00.
DOI: https://doi.org/10.1145/3234698.3234725 All of the locations data are stored in the form of an array
respectively in array variable X and Y. In figure 2 below the blue
dotes shows the manager location which he need to visit by using
the short path for this purpose we calculate the values by genetic 4 EMTE HEUV 5741JJ BEEKE 51. 5.63
algorithm. BEEK EN ELPL N 529 23
DONK N 73 DONK 3
5 EMTE MER 5258A BERLI 51. 5.39
BERLICU CURI X CUM 679 886
M USPL NB 52
N 30
6 EMTE MAR 4112JS BEUSI 51. 5.29
BEUSICH KT 20 CHEM 948 276
EM FR 99
7 EMTE LICH 7271A BORC 52. 6.52
BORCUL TENH E ULO 117 536
O ORST 63
Figure 2 supermarket locations
7
The location data is random the path between these locations are 8 EMTE VERK 5831E BOXM 51. 5.94
too long which takes time to traverse all the points. The data in BOXMEE UYLS H EER 646 985
figure 2 shown in form of blue dots are all the super market in R TR 11 01
9 EMTE MOL 5306V BRAK 51. 5.10
different places which can be sort out using genetic algorithm.
BRAKEL ENKA N EL 810 761
FR MPS 23
3. GENETIC ALGORITHM WG 3
Genetic algorithms are a very important tool for business problems 1 EMTE MOE 4826H BRED 51. 4.79
and optimizations. This algorithm improves the performance of 0 BREDA RWY N A 608 059
task by finding Business intelligence solution from the exiting MOERWIJ K 23 53
datasets in our case we will get the locations of supermarkets as our K
datasets [2]. The solution generate from Genetic algorithm are 1 EMTE HEKS 4823JT BRED 51. 4.74
mostly better than existing one. These solutions are possible by 1 BREDA ENW A 622 434
genetic algorithm which gets the data and process it to find HEKSEN AAG 9
improved results. In table1.1 we have the data of supermarkets WAAG 37
locations like name, address, city, postal code lat. and long which 1 EMTE ST 5266A CROM 51. 5.23
we used in genetic algorithm [8]. 2 CROMVO LAM D VOIRT 660 157
We use permutation and Cross over technique of Genetic algorithm IRT BERT 52
for the supermarket population data. In Mutation the population USST
data is modified and regenerate the missing values. If we have the R 55
following populating data (1.38 -69.4 326.44 0.1) after applying 1 EMTE VIAN 4101X CULE 51. 5.22
the permutation operator the data is optimized (1.38 -67.5 326.44 3 CULEMB ENSE A MBOR 952 259
0.1). ORG STR 3 G 83
1 EMTE MAA 5431B CUYK 51. 5.88
Cross over is the technique for recombination of population data. 4 CUIJK SBUR R 729 003
This method effectively searches the important variables in G 24 51
processing of a population data. 1 EMTE L 7591G DENE 52. 7.00
5 DENEKA VOO E KAMP 374 273
1.1 Table 1 location data of EMET stores. MP R 10 29
1 EMTE DIDE 6951C DIERE 52. 6.10
6 DIEREN RNA W N 051 018
N Name Addre Postal City Lat Lon 44 33
o ss Code g 1 EMTE JULIA 5087B DIESS 51. 5.17
7 DIESSEN NAST B EN 478 801
0 HEADQU CORR 5466R VEGH 51. 5.52
FR R 42 68
ARTERS IDOR B EL 606 709
1 EMTE Looier 5104G DONG 51. 4.94
VEGHEL 11
8 Dongen splein N EN 625 229
1 EMTE 4241B ARKE 51. 4.99
25 651 1
ARKEL VRIE W L 864 304
1 EMTE KRIS 3314K DORD 51. 4.66
SPLN
9 DORDRE PYNS L RECH 801 547
14
CHT EWG T 11
2 EMTE CLAS 4341E ARNE 51. 3.67
KRISPIJN 68
ARNEMU INAS R MUID 500 728
SEWEG
IDEN FR TR 5 EN 01
2 EMTE AALB 5151E DRUN 51. 5.13
3 EMTE LARE 7437B BATH 52. 6.28
0 DRUNEN ERSE E EN 685 236
BATHME NSE M MEN 249 999
STR 5 25
N FR WG 06
18
The table above shows the existing location data of manager and
using this data we get the shortest paths between these super
markets. There are also old paths between these locations but after
using Genetic algorithm the newly discovered paths are far more Similarly, we can call the same function and pass the number of
better than existing one [9]. generation parameter in X instead of population. Figure 4 below
shows the performance overview of genetic algorithm.
4. PROCEDURE
In this study we use the genetic algorithm to find the shortest path
TSP30 - Overview of Performance
for the Manager of supermarket using genetic algorithm. The
algorithm gets the values of all the locations and generate the 1600

possible paths through which manager visit the supermarkets [4]. 1400

1200
We collect all the locations and using MATLAB with respect to lat.
1000
and long values from locations get all the possible paths between

Distance
800
them. Figure 3 show the basic Genetic algorithm process which
600
used crossover and mutation method for sorting and cleaning the
400
data variables to get the accurate result [12]. In first step we have
200
the population data which is passed to fitness function which
0
evaluates the data and forward to next step for collecting final 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31
Best
Worst
results. [16] Generations (1000) Average

Figure 4 performance overview

5. GENETIC ALGORITHM INTEGRATION


TO FIND SHORTEST PATH
Initial CrossOver Mutation Fitness To find the shortest paths between selected locations we integrate
Population Operation Population Evaluation genetic algorithm for the values. We do not have any defined set of
limited boundaries of locations in population data [3].
What we have to do is to plot the given location and find the
minimal path to traverse all location. The function for plotting the
locations is as follow
filename = 'DataEMTEstores.xlsx';
Figure 3 Process of Genetic algorithms sheet = 1;
4.1 Population data We found lat and long values of location and get the range from
First take the population data and map the data in 2D array which values F and G in Figure 5
generates the random paths the pseudo code function below is for
xlRange = 'F:G';
permutations [18].
FunctionPop=create permutations(NVARS,FitnessFcn,options)
totalPopulationSize=sum(options.PopulationSize);
n = NVARS;
pop = cell(totalPopulationSize,1);
fori=1: totalPopulationSizepop{i}= randperm(n);
end

4.2 Traveling Distance


We will use a fitness function for traveling manager. This will give
the total distance travelled for the ordered set of supermarkets. We
have a function score which store the traveling manager fitness
values [3]. Figure 5 random path
functionScores= Traveling_Manager_Fitness (x,distances)
The fitness is the total distance traveled for an ordered set of We do not have any defined set of limited boundaries of locations
supermarkets in X. DISTANCE (A, B) is the distance from the what we have to do is to plot the given location and find the minimal
supermarket A to B. The function for the score is path to traverse all location
Scores = zeros(size(x,1),1);
subsetA =xlsread(filename,sheet,xlRange);
for j = 1: size(x,1)
here population cell is used as a parameter It will read all rows from excel of F and G
p = x{j};
f = distances(p(end), p (1)); In this papers for genetic algorithm we take 134 supermarkets.
for i = 2: length(p) Declaring an 2D array to store all X and Y values
f = f + distances(p(i-1), p (i));
end smLocations = zeros(supermarkets,2);
scores(j) = f; Start with record number 1 as this will be the starting and the end
end point.
n = 1; optimoptions(@ga,'PopulationType',custom','InitialPopulationRan
ge', ...
while (n <= supermarkets)
Use below for number of generation
Store all X and Y value in Array
options = optimoptions(@ga, 'GenerationType', 'custom', ...
x = subsetA(n,1); [1;supermarkets]);
y = subsetA(n,2); Finally, we will call all functions that we have created

smLocations(n,1) = x; options=optimoptions(options,'CreationFcn',@create_permutation
s,'CrossoverFcn' ,
smLocations(n,2) = y; @crossover_permutation,'MutationFcn',@mutate_permutation,'Pl
otFcn',
n = n+1; plot_manager_map,'MaxGenerations',500,PopulationSize',60,'Ma
xStallGenerations',200, 'UseVectorized',true);
end
At the end to call the genetic algorithm with problem information.
Plotting all super market location according to Lat and Long where
'bo' value will mark the location with blue circle numberOfVariables = supermarkets;
plot(smLocations(:,1),smLocations(:,2),'bo'); [x,fval,reason,output]=ga(FitnessFcn,numberOfVariables,options)
Blue circles represent the locations of each supermarket where the ;
manager
6. RESULT
has to visit. Manager has to start visiting from location 0 which will Using Genetic algorithm, we read the F and G columns from the
be first location [5]. table 1 (column „lat and long‟) which are the locations for the
supermarkets. - Declaring an array to store the all the X and Y
Defining array distances which will store the distance value values. The Genetic algorithm created Distances matrix by using
between two supermarkets which will be the distance matrix fitness function for all the supermarkets [15]. We will be creating
distances = zeros(supermarkets); required functions for travelling manager. These functions will
distinguish the manager path parameter like population size and
for count=1: supermarkets, number of generations [12]. Individual functions are used to
for count1=1: count, generate the results based on parameters and to calculate the
minimal traveling distances [14]. The best route we found is store
x1 = smLocations(count,1); in variable in serial number from 1 -134.
y1 = smLocations(count,2); (Number of supermarkets) x = cell [1×40 double]
x2 = smLocations(count1,1); The distance of the best route is shown in the figure 6 below
y2 = smLocations(count1,2);
distances (count, count1) =sqrt((x1-x2) ^2+(y1-y2) ^2);
distances (count1, count) =distances (count, count1);
end;
We will be creating required function for travelling manager. These
functions will distinguish the Manager path parameter like
population size and number of generations [17]. Individual
functions are used to generate the results based on parameters and
to calculate the minimal traveling distances [6].
Figure 6 shortest distance to the largest location
typecreate_permutations.m The plot shows in Figure 6 (Genetic Algorithm) the location of the
typecrossover_permutation.m supermarkets in dots as well as the path found by the genetic
algorithm after evaluating all the values from which the manager
typemutate_permutation.m will travel. The manager can start his travel from headquarter
typetraveling_manager_fitness.m VEGHEL which is the first place the starting point of city and end
on the same point in minimum time with low cost [10].
FitnessFcn=@(x)traveling_manager_fitness(x,distances);
typetraveling_manager_plot.m%smLocationsplot_manager_map
= @(options,supermarket,flag)
traveling_manager_plot(options,supermarket,flag,smLocations);

For generic algorithm integration we will create and options


container for population range using custom data type options =
7. CONCLUSION [7] Cheng Guo, Xiaoyong Yang, 2001. “A Programming of Genetic
From the result we provide the shortest path for the manager of Algorithm in Matlab7.0,” Modern Applied Science, Vol. 5, No. 1,
supermarkets using genetic algorithm for visiting all the locations February.
on time and low cost. [8] Zhu Gofeng, 2013. "Application of genetic algorithm in
automati test generation [J]", Computer Knowledge and
The existing location data in the form of latitude and longitude
Technology, pp. 1626-1629.
through which we draw the paths shows that the path generated by
genetic algorithm are far more better and shorter than the normal [9] Lei Yingjie, Zhang Shanwen, 2014. "Genetic algorithm toolbox
paths [13]. In our data sets we applied mutation and crossover and its application MATLAB [M]" in , Xi'an Electronic and
feature of genetic algorithm for data optimization and reproduced Science University press, pp. 206-320.
the missing values of locations. Crossover function evaluate the [10] Wang, L., et al, 2003. Scheduling Problem of Flexible and the
population data and search all the possible paths between the Genetic Algorithm, vol. 5. Qinghua University Press, China.
locations [7].
[11] Chen Zelin, Zang Qingbiao, 2010. Test bank design and
Using genetic algorithm in our problem we improved and optimize algorithm of test system based on java [J], Journal of Chongqing
the paths between locations in this way we speed up and improve University of Technology (Natural Science), vol. 24, No. 3, 48-55,
Genetic Algorithm information about the manager traveling (In Chinese).
problem through which we gained the shortest distance. The new
data from existing one is modified and gave us more relevant results [12] Wen-xiu ZHANG, Yi LIANG, 2000. Mathematical
which are more Flexible [11]. Foundation of Genetic Algorithms, Xi'an:Xi'an Jiaotong University
Press.
In genetic algorithm the basic issues for the implementations is to
process the large amount of population’s data. In which the [13] Xue-hui REN, Xiao-Jian ZHOU, Hui-sheng GUAN, Yong
selection of relevant variable and deletion of unused data is difficult ZHANG, 2009. "Automatic Test Paper Based on Niche Genetic
to find out. Algorithm", Journal of Lanzhou University of Technology, vol. 31,
pp. 94-97, Dec.
8. REFERENCES [14] Gong Dunwei, Sun Xiaoyan. 2009. Co-evolution theory and
[1] C.F. Juang, 2004. A hybrid of genetic algorithm and particle application of genetic algorithm,Beijing:Science .
swarm optimization for recurrent network design IEEE Trans Syst
[15] Bozdogan, H. (1987). Model selection and Akaike’s
Man Cybernet – Part B Cybernet, 34 (2), pp. 997-1006
Information Criterion (AIC): The general theory and its analytical
[2] L. Chambers, 1995. Practical handbook of genetic algorithms: extensions. Psychometrika, 52(3), 345:370
new frontiers, vol. 2, CRC Press.
[16] Rajwinder Kaur, Prabhpreet Kaur, 2016. Optimizing the
[3] Soryani, M and Rafat, N, 2006. ‘Application of Genetic Genetic Algorithm to resynthesize iris Patterns from iris Code
Algorithms to Feature Subset Selection in a Farsi OCR’, Template, International Journal of Current Engineering and
Proceedings of World Academy of Science, Engineering and Technology, Vol.6, No.1, Feb.
Technology Volume 18 December 2006 ISSN 1307- 6884
[17] Pardeep Kumar, Pawan Kumar, Ram Bhool, Virender Upneja,
[4] R. Nakano, 1991. T. YamadaConventional genetic algorithm 2016. An efficient Genetic Algorithm Approach for Minimising the
for job shop problems, Jan. Makespan of Job Shop Scheduling Problems, International Journal
[5] .I.T.Alander, 1994. “An indexed bibliography of genetic of Science, Engineering and Technology Research (IJSETR).
algorithms: Years 1957-1 993,” Dept. Informat. Technol., Volume 5, Issue 5, May 2016.
Production Econ., University of Vaasa, Finland, Rep. Ser. 94-1, [18] Saad Alharbi, Ibrahim Venkat, 2017. A Genetic Algorithm
Feb. Based Approach for Solving the Minimum Dominating Set of
[6]Genetic algorithms: Concepts andapplications Queens problem. Journal of Optimization, Volume 2017(2017),
https://www.researchgate.net/publication/3217198_Genetic_algori Article ID 5650364, 8 pages. http://doi.org/10.1155/20175650364.
thms_Concepts_and_applications
Columns on Last Page Should Be Made As Close As
Possible to Equal Length
Authors’ background
Your Name Title* Research Field Personal website

Osman ucan Professor.Dr algorithms -


Oguz bayat assistant algorithms -
professor.Dr
Shaymaa alhayali Phd Genetic -
candidate algorithms
*This form helps us to understand your paper better, the form itself will not be published. *Title can be chosen from:
master student, Phd candidate, assistant professor, lecture, senior lecture, associate professor, full professor

View publication stats

You might also like