application genetics algorithm for finding shortest path

1 downloads 0 Views 782KB Size Report
Rame Likaj., Xhevahir Bajrami, Ahmet Shala And Arbnor Pajaziti, 2017. Path Finding. For A Mobile Robot Using Fuzzy And Genetic Algorithms. International ...
International Journal of Civil Engineering and Technology (IJCIET) Volume 9, Issue 4, April 2018, pp. 1516–1526, Article ID: IJCIET_09_04_168 Available online at http://www.iaeme.com/ijciet/issues.asp?JType=IJCIET&VType=9&IType=4 ISSN Print: 0976-6308 and ISSN Online: 0976-6316 © IAEME Publication

Scopus Indexed

APPLICATION GENETICS ALGORITHM FOR FINDING SHORTEST PATH IN SEVEN CITIES Astrit Sallauka, Xhevahir Bajrami*, Ramë Likaj Faculty of Mechanical Engineering, University of Prishtina, 1000 Prishtina, Kosovo Blendi Gashi Faculty of Mechanical Engineering, University of Prizren, Faculty of Computer Science, Kosovo * Corresponding author: [email protected] ABSTRACT The purpose of this paper is to design and implement a genetic algorithm for short path network. This material addresses the construction of the minimum road network in Kosovo through GA. Due to the inclusion of some parameters, the design and implementation of short-circuit networks through traditional optimization techniques is very difficult. To overcome these problems, most researchers have applied genetic algorithms for designing and implementing short-distance networks. After reviewing the various studies involved in designing and implementing the short-range network using the genetic algorithm, we found that the genetic algorithm is an efficient optimization technique. Key words: Genetic algorithm, road network, short-distance networks, traveling salesman problem Cite this Article: Astrit Sallauka, Xhevahir Bajrami, Ramë Likaj, Blendi Gashi, Application Genetics Algorithm for Finding Shortest Path in Seven Cities, International Journal of Civil Engineering and Technology, 9(4), 2018, pp. 1516– 1526. http://www.iaeme.com/IJCIET/issues.asp?JType=IJCIET&VType=9&IType=4

1. INTRODUCTION In developing countries such as Kosovo, traffic congestion, slow speed of cars and poor service levels are the main problems facing our daily lives. These problems are due to the large increase in vehicle populations, especially private and intermediate (private taxi) transport services. In this view of rapid development it is necessary to plan and design the public transport system efficiently so that the use of the private and intermediate transport service is reduced. The transport system is efficient if the design and schedule of the shortdistance network is efficient. From the user's point of view, the system is efficient if it meets the demand by providing free and direct service to the passenger and from the operator's

http://www.iaeme.com/IJCIET/index.asp

1516

[email protected]

Astrit Sallauka, Xhevahir Bajrami, Ramë Likaj, Blendi Gashi

perspective the system is efficient if it creates as much profit as possible. This is the main challenge in short-distance planning to find the balance between these contradictory objectives, whereby different optimism techniques come to light. Among the various optimization techniques the genetic algorithm offers a new strategy with great potential for many tasks in planning and designing the short-distance network. It is an area of interest that shows how the genetic algorithm addresses the lack of conventional optimization techniques. In the current study, an attempt has been made to explore the application of genetic algorithms in circulation, schedule, combined circulation, and the scheduling and planning an integration of overall transit.

2. GENETIC ALGORITHMS Genetic algorithms (GA) are the simplest evolutionary algorithms. GA is built from all the basic components of natural evolutionary algorithms. GA is a natural algorithm, described as evolution by Charles Darwin. GA was introduced for the first time by J.H. Holland and imitates the natural algorithm of evolution

Figure 1 Schema of genetic algorithm

Chromosomes appear with a string consisting of 0 and 1, bitstring, GA performs actions in these verses rather than solutions. Same as in nature, Holland's program selects only the best samples. Each sample is attached to a variable that retains the estimated value of that sample's quality compared to other samples, this is known as fitness function. If the value of the variable for quality is high then that sample is likely to continue to be chosen as one of the best samples for future generations, thus decreasing the number of poor samples. The selection of the new gene, the progeny, is not done by a string, but by the combination of two arrays called the parent chromosome.

2.1. Chromosome The term "chromosome" in biology represents a macro-molecule with four different bases for coding genetic information, genotype, while GA is defined as bitstring, range of 0 and 1, but there are other chromosome definition options in GA.

http://www.iaeme.com/IJCIET/index.asp

1517

[email protected]

Application Genetics Algorithm for Finding Shortest Path in Seven Cities

Data input, bitstring, is usually generated at random values, while the size of arrays depends on the type of problem. Each string, chromosome, represents a solution to the problem that the algorithm needs to resolve, the group of these strings being called population. If we have a problem finding maximum value from the function ( ) where the possible values of x are between 0 and 100 then all possible solutions are presented as the bitstring starting value 0 to value 100.

0

0

0

0

0

0

0

0

 0

0

1

1

0

0

1

0

0

 100

In addition to bitstring, values 0 and 1, we can often encounter other chromosome definitions. Definition of letters (A, B, C, D, E), natural numbers (1, -4.3, 3.2, 0), data list (R1, R2, R3), etc. If we want to choose the shortest route for any target, and we map the locations in letters, then a route may be ABCDEF or DBACEF.

2.2. Fitness Function Fitness function (FF) is a very important link between the genetic algorithm and the system being optimized. FF inputs are chromosomes, while outputs are a list of numbers, values that should be approximate to the amount of difference between outputs and targets. These targets are used to calculate the characteristics of the chromosomes. The range of target values varies by problem. Therefore FF is used in order to have a generalized but scalable problem. Calculating the value of FF from the target can be done by linear, exponential scaling, and limiting the value of the sigma function.

Figure 2 Definition of chromosomes through letters

In the linear scale FF of the chromosome , there are linear links to the target value ,

and

are constant values.

In exponential escalation FF of the chromosome , take the value of the target to power of . ,

.

elevated

is the exponent value that changes when solving the problem.

http://www.iaeme.com/IJCIET/index.asp

1518

[email protected]

Astrit Sallauka, Xhevahir Bajrami, Ramë Likaj, Blendi Gashi

In the escalation with the value limit of the sigma function, FF of the chromosome takes the value of the difference between the target value and the value of the change of the mean value of the target and the standard deviation of the entire population: (̅ ) , is cardinal number, ̅ is the average value of the target value, is the standard deviation of the population.

2.3. Solution Before cross-over action is performed, the selection of high quality parent chromosomes is always done. Choosing the parent chromosome is random, chromosome evaluation plays a role in this choice, chromosomes with high-value chromosomes are more likely to opt for generating new generations. Choosing chromosomes can be calculated through three characteristics: threshold, spread and effectiveness. The most common method for choice is FF, the higher the FF value, the greater the probability of choice. The threshold sets the difference between the current choice and the required choice between parent chromosomes. Propagation shows the number of times that chromosome tends to cross-over. Effectiveness shows the time spent on the algorithm. After selecting FF chromosomes that have a value greater than the average of the entire population, the population that will be created will be smaller, because chromosomes with FF having a lower value than the average will be eliminated. The election creates another casual populace, but with the best chromosomes.

Figure 3 Choosing the parent chromosomes

2.4. Crossover Crossover makes the difference of two parent chromosomes in order to release another chromosome of higher quality. It's similar to the natural crossover method. After performing the crossover action, the offspring will have parental chromosome similarities in order to approach the problem as much as possible. Through these changes, the algorithm can find other solutions based on other chromosomes. This value change method is called bit-flip. The possibility of cross-over is about 0.7, but the bigger the possibility of changing the bits, this also increases the possibility of changing invalid bits.

http://www.iaeme.com/IJCIET/index.asp

1519

[email protected]

Application Genetics Algorithm for Finding Shortest Path in Seven Cities

Figure 4 Replacement of chromosome parent bits

There are various techniques for cross-over in the chromosome and each technique is used for different coding chromosomes. The most commonly used techniques are One-point crossover, Two-point crossover and Cut and splice.

2.5. One-Point Crossover Each offspring is the result of the union of parent gene chromosomes. For fusions of genes, a point is assigned to the parent chromosome and after that point all the genes are changed.

Figure 5 One-point crossover

2.6. Two-Point Crossover Unlike a one-point crossover, the two-point crossover sets that the change of bits will be made from the middle of the two selected locations.

Figure 6 Two-point crossover

2.7. Cut and Splice This method allows dividing points, for the change of bits, to be different for the position, for parent chromosomes, so the size of the offspring may not be the same as the size of the parent chromosomes.

http://www.iaeme.com/IJCIET/index.asp

1520

[email protected]

Astrit Sallauka, Xhevahir Bajrami, Ramë Likaj, Blendi Gashi

Figure 7 Cut and splice crossover

2.8. Mutation After selecting the chromosomes for population the algorithm first checks for whether crossover action should be performed and then if the mutation in these chromosomes can be applied, changing the bite positions within the chromosome, the algorithm continues with the mutation of the chromosomes. Replacement of the bits inside the chromosome is random, two bits are picked and receive opposite values. However, the chromosome mutation potential is very low, about 0.001.

Figure 8. Successive chromosome without mutation

Figure 9. Successive chromosome with mutation of the last bits

3. NUMERICAL RESULTS 3.1. Traveling Salesman Problem Choosing the shortest route to visit the given locations. First we put the map data of Kosovo along with the cities in the MATLAB work space: load(‘kosova.mat’); plot(kosova(:,1), kosova(:,2), ‘Color’, ‘red’); hold on; cities = 7;

Figure 10 Map of Kosova

http://www.iaeme.com/IJCIET/index.asp

1521

[email protected]

Application Genetics Algorithm for Finding Shortest Path in Seven Cities load('7locations.mat'); plot(locations(:,1), locations(:,2),'bo');

Figure 11 Seven locations of Kosovo distances = zeros(cities); for count1=1:cities, for count2=1:count1, x1 = locations(count1,1); y1 = locations (count1,2); x2 = locations (count2,1); y2 = locations (count2,2); distances(count1,count2)=sqrt((x1-x2)^2+(y1-y2)^2); distances(count2,count1)=distances(count1,count2); end; end;

Since we are not dealing with bitstring, we need to create population, crossover and mutation functions. type create_permutations.m function pop = create_permutations(NVARS,FitnessFcn,options) totalPopulationSize = sum(options.PopulationSize); n = NVARS; pop = cell(totalPopulationSize,1); for i = 1:totalPopulationSize pop{i} = randperm(n);

http://www.iaeme.com/IJCIET/index.asp

1522

[email protected]

Astrit Sallauka, Xhevahir Bajrami, Ramë Likaj, Blendi Gashi end type crossover_permutation.m function xoverKids

= crossover_permutation(parents,options,NVARS, ...

FitnessFcn,thisScore,thisPopulation) nKids = length(0parents)/2; xoverKids = cell(nKids,1); index = 1; for i=1:nKids parent = thisPopulation{parents(index)}; index = index + 2; p1 = ceil((length(parent) -1) * rand); p2 = p1 + ceil((length(parent) - p1- 1) * rand); child = parent; child(p1:p2) = fliplr(child(p1:p2)); xoverKids{i} = child; end type mutate_permutation.m function mutationChildren = mutate_permutation(parents ,options,NVARS, ... FitnessFcn, state, thisScore,thisPopulation,mutationRate) mutationChildren = cell(length(parents),1); for i=1:length(parents) parent = thisPopulation{parents(i)}; p = ceil(length(parent) * rand(1,2)); child = parent; child(p(1)) = parent(p(2)); child(p(2)) = parent(p(1)); mutationChildren{i} = child; end

http://www.iaeme.com/IJCIET/index.asp

1523

[email protected]

Application Genetics Algorithm for Finding Shortest Path in Seven Cities type traveling_salesman_fitness.m function scores = traveling_salesman_fitness(x,distances) scores = zeros(size(x,1),1); for j = 1:size(x,1) p = x{j}; f = distances(p(end),p(1)); for i = 2:length(p) f = f + distances(p(i-1),p(i)); end scores(j) = f; end FitnessFcn = @(x) traveling_salesman_fitness(x,distances);

We create a new function for our custom data inputs. type plotProblem.m function state = plotProblem(options,state,flag,lokacionet) persistent kosova if strcmpi(flag,'init') load('kosova.mat'); end plot(kosova(:,1),kosova(:,2),'Color','red'); axis([-0.1 1.5 -0.2 1.2]);

hold on; [unused,i] = min(state.Score); genotype = state.Population{i}; plot(locations(:,1), locations (:,2),'bo'); plot(locations (genotype,1), locations (genotype,2)); hold off

http://www.iaeme.com/IJCIET/index.asp

1524

[email protected]

Astrit Sallauka, Xhevahir Bajrami, Ramë Likaj, Blendi Gashi

displayResults = @(options,state,flag) plotProblem(options, state, flag, locations);

Now we set the options for GA algorithm. options = gaoptimset('PopulationType', 'custom','PopInitRange', [1;cities]); options = gaoptimset(options,'CreationFcn',@create_permutations, ... 'CrossoverFcn',@crossover_permutation, ... 'MutationFcn',@mutate_permutation, ... 'PlotFcn', displayResults, ... 'Generations',500,'PopulationSize',60, ... 'StallGenLimit',200,'Vectorized','on');

We run the GA using fitness function defined earlier, cities and options. [x,fval,reason,output] = ga(FitnessFcn,cities,[],[],[],[],[],[],[],options)

Result: Optimization terminated: average change in the fitness value less than options.TolFun. x = [1x7 double] fval = 2.0861 reason = 1 output = problemtype: 'unconstrained' rngstate: [1x1 struct] generations: 201 funccount: 12120 message: 'Optimization terminated: average change in the fitness value less than options.TolFun.'

Figure 12. Choosen path through GA

4. CONCLUSIONS http://www.iaeme.com/IJCIET/index.asp

1525

[email protected]

Application Genetics Algorithm for Finding Shortest Path in Seven Cities

Genetic algorithms offer the opportunity to find a better solution, it uses solutions that creates at random until they reach a perfect solution to that problem. Using the proposed method we can design and implement short road networks and optimize them through genetic algorithm.

REFERENCES [1]

Bajrami, X., et al.” (2016, June). Genetic and Fuzzy logic algorithms for robot path finding. In Embedded Computing (MECO), 2016 5th Mediterranean Conference on (pp. 195-199). IEEE

[2]

Berisha, J., Bajrami, X., Shala, A., & Likaj, R. (2016, June). Application of Fuzzy Logic Controller for obstacle detection and avoidance on real autonomous mobile robot. In Embedded Computing (MECO), 2016 5th Mediterranean Conference on (pp. 200-205). IEEE

[3]

Rame Likaj., Xhevahir Bajrami, Ahmet Shala And Arbnor Pajaziti, 2017. Path Finding For A Mobile Robot Using Fuzzy And Genetic Algorithms. International Journal of Mechanical Engineering & Technology (IJMET)

[4]

Jain, Lakhmi C., and N. M. Martin. Fusion of Neural Networks, Fuzzy Systems and Genetic Algorithms: Industrial Applications. N.p.: CRC, 1998.

[5]

Russell, Stuart J., Peter Norvig, and Ernest Davis. Artificial Intelligence: A Modern Approach. 3rd ed. Upper Saddle River, NJ: Prentice Hall, 2010.

[6]

Goldberg, David E. Genetic Algorithms in Search, Optimization, and Machine Learning.

[7]

Poli, Riccardo, W. B. Langdon, Nicholas F. McPhee, and John R. Koza. A Field Guide to Genetic Programming. S.I.: , Lulu.com, 2008.

[8]

Mitchell, Melanie. An Introduction to Genetic Algorithms. Cambridge, MA: MIT, 1996.

[9]

Rich, Elaine. Artificial Intelligence. New York: McGraw-Hill, 1983.

[10]

K. S. Suresh, K. S. Ravichandran, S. Ananthakrishn an and E. Ponmani, Emergence of Multi Objective Genetic Algorithm in Robot Path Planning – A Survey, International Journal of Mechanical Engineering and Technology 8(8), 2017, pp. 1449–1457.

[11]

Uttam Roy and Mrinmoy Majumder. Estimation and Analysis of Cycle Efficiency for Shell and Tube Heat Exchanger by Gen etic Algorithm. International Journal of Mechanical Engineering and Technology, 8(2), 2017, pp. 93–101.

[12]

R.P.S. Manikandan and Dr. A.M. Kalpana, Design of Transactional Prediction using Plan Mine and Genetic Algorithms. International Journal of Computer Engineering and Technology, 7(6), 2016, pp. 50–54.

http://www.iaeme.com/IJCIET/index.asp

1526

[email protected]