SlideShare a Scribd company logo
IOSR Journal of Computer Engineering (IOSR-JCE)
e-ISSN: 2278-0661,p-ISSN: 2278-8727, Volume 17, Issue 1, Ver. II (Jan – Feb. 2015), PP 75-78
www.iosrjournals.org
DOI: 10.9790/0661-17127578 www.iosrjournals.org 75 | Page
Application of Genetic Algorithm and Particle Swarm
Optimization in Software Testing
Deepti Arora1
, Anurag Singh Baghel2
1,2,
(Gautam Buddha University,Uttar Pradesh,India)
Abstract: This paper will describe a method for optimizing software testing by finding the most error prone
paths in the program. This can be achieved by a meta-heuristic technique, that is by using genetic algorithm
and particle swarm optimization. As exhaustive software testing is not possible where software is tested with all
the possible inputs , those parts of software are also tested which are not error prone..Goal is to generate test
cases using both the algorithms and then comparative study is done between Particle swarm optimization and
genetic algorithm.
Keywords: Software Testing, Meta-heuristics , Genetic Algorithms, Particle Swarm Optimization, Software test
cases.
I. Introduction
Testing is the one of the crucial phase that is performed during software development. It is a primary
technique which is used to gain consumer confidence in the software. It is conducted by executing the program
developed with test inputs and comparing the observed output with the expected one .[1]Software testing is done
to identify any errors or missing requirements in contrary to the actual requirements. It is done to validate the
quality of the software testing using minimal cost and efforts and to generate high quality test cases. It uncovers
the error in the software, including errors in requirement analysis, design document, coding, system resources
and system environments, hardware problems and their interfaces to the software .[2] It is very time consuming
and laborious activity. It is costly and consumes about 50% of the cost of the software development.[3]. Main
goal of testing to find as many faults as possible in a software. As mentioned earlier it a time consuming activity
,as it is impossible to test the software unit with all the combinations of inputs so there is a need to design
minimum no. of test cases that will discover as many faults as possible . However, software testing automation
is not a straight forward process. For years a lot of research have been done in this area to generate test cases
,researchers developed methods like random test case generator, symbolic test data generators and dynamic test
data generators. This paper applied the EST (Evolutionary software testing ) techniquie.EST is the automatic
software test case generation technique which in turn will reduce the cost of development of software. EST
interprets the task of test case generation as an optimization problem and tries to solve it using a search
technique .EST uses an meta-heuristic search technique that is genetic algorithm to convert the task of test case
generation into an optimal problem. Evolutionary Testing search for optimal test parameter combinations that
satisfy a test criterion. Test criterion is represented fitness function that measures how well optimization
parameters that are automatically generated are satisfying the given test criterion .There are variety of
techniques for test case generation but in this paper we will focus on genetic algorithm and particle swarm
optimization technique.
This paper will present the result of our research in into the application of GA and PSO search
approach, to find optimal solution in the software construct.
II. Genetic Algorithm
Genetic Algorithm (GA) are heuristic search algorithm.[4]They are based on the evolutionary idea of
natural selection and genetics. Genetic algorithm is inspired by the Dalton’s theory about evolution that is
survival of the fittest. Genetic algorithm is a part of evolutionary computing which is a growing field of
Artificial Intelligence. GA exploits the historical information to direct the search in region of better performance
with in the search space. [5] In this way competition among individuals for better resources results in fittest
individual dominating over the weaker ones. Genetic Algorithms are more robust hence they are better than
conventional AI(Artificial Intelligence). GA does not break easily even if there is a slightly change in the input
and it also does not get affected by noise. GA offer benefit over typical search of optimization problem in
searching large state space, multimodal search space and n dimensional surface.
Distinct element in GA is individual and population. Individual represents single solution while
population represents set of Solutions which is currently involved in this search process. Each individual is
represented as chromosome. That is an Initial pool of chromosomes. Population size can be few dozens to
thousands. To do optimization fitness function is required to select the best solution from the population and
Application of Genetic Algorithm and Particle Swarm Optimization in Software Testing
DOI: 10.9790/0661-17127578 www.iosrjournals.org 76 | Page
discard those not so good solutions. GA consists of following operators that is Selection Operator chromosomes
are selected for cross-over based on the value of the fitness function Cross- Over Operator combine two
chromosomes to produce new chromosomes. Mutation Operator in this value is randomly changed to create new
genes in the individual.
Pseudo code of GA
Initialize (population)
Evaluate Fitness of the population
While (termination condition is met) do
{
Selection(Population)
Cross-over(Population)
Mutation(population)
Evaluate (Population)
}
GA [6] starts with randomly generated population of individuals or chromosomes .Fitness of individual
is calculated based on some fitness function. After the fitness is calculated selection of individuals is done based
on the Roulette –Wheel Selection method i.e an individual having higher fitness value has the more chance of
getting selected .Then Cross over operator is applied to produce new offspring in the population that may have
better characteristics than their parents. Mutation is done to introduce new individual in the population .its is
done by flipping the bit of the chromosomes.
III. Particle Swarm Optimization
Particle Swarm Optimization (PSO) [7] is a relatively recent heuristic search method. It is similar to
GA in the sense that both are evolutionary algorithms .It is one of the meta-heuristics approach that optimizes a
problem and try to improve candidate solution iteratively. PSO is generally used to solve those problems
whose solution can be represented as a point in an n-dimensional space. In PSO potential solution is called
particle. A number of particles are randomly set into motion through this space. Each particle posses its current
position, current velocity ,and its pbest position .Pbest is the personal best position explored so far. It also
incorporates Gbest that global best position achieved by all its individuals. It is a simple approach and it is
effective across a variety of problem domains.
Pseudo code for PSO
The PSO algorithm consists of just few steps, which are repeated until some stopping condition is
met. The steps are as follow:
 Initialize the population of individuals with current position and, velocity.
 Evaluate the fitness of the individual particle (Pbest).
 Keep track of the individual highest fitness (Gbest).
 Modify velocity based on Pbest and Gbest location.
 Update the particle position.
PSO starts with initialization of particle velocity and current position. Here particle is in 2-D space .
Fitness value of the particle is calculated according to function. If the fitness of the particle is better than its
previous value update particle x and y position that is its personal best position. Also if the value is better than
gbest position update global best position of the particle. Apply equations to update the x and y velocity vector
of the particles. Process repeats until termination criteria is met or the optimal solution is found.
IV. Implementation
Genetic Algorithm is implemented in c language. result is as follows. GA approach to problem to
maximize the function (1) F(x)=x3
-x2
. X represent 5 digit unsigned binary integer .i.e x can take value [0,31].
Four randomly generated solution to problem are 14,18,24,30. Fitness of the individual is calculated by the
function F(x).String no. 4 has the maximum value having more chances of getting selected. here N is 4 . One
point Crossover is performed in a couple. New offspring is generated. Mutation is performed. We get new
generation Again the process is repeated till the maximum possible value of the solution is obtained .Luckily in
this case in the second iteration we will get desired value. Whereas In most of the cases GA traps in local
optima. But here We have got the global optimum solution.
Application of Genetic Algorithm and Particle Swarm Optimization in Software Testing
DOI: 10.9790/0661-17127578 www.iosrjournals.org 77 | Page
Table 1
String
N o.
Initial Population Value of x F(x)=X3
-x2
pi Expected
Count(N*pi)
1 01111 15 3150 0.072 0.289
2 10010 18 5508 0.126 0.505
3 10101 21 8820 0.202 0.809
4 11110 30 26100 0.598 2.395
Sum 43578 1 4
Average 10894 0.25 1
Max 26100 0.598 2.395
Table 2
Before
Crossover
After
Crossover
Mutation
Of element 3 at
position 2
New
Generation is as follows
(Value of x)
01111 01110 01110 14
10010 10011 10011 19
10101 10100 10110 22
11110 11111 11111 31
Particle Swarm Optimization
For Mathematical function (2) val=(x-15)4
-(y-20)2
+9
Particle is initialized with current position and velocity. Program will search for optimal solution
through the movement of particle. Program will keep track of personal best and global best position of the
particle and update its position and velocity .Optimal solution here is to minimize the mathematical function
.PSO is implemented in C language. How the particle moves in the search space to find global best solution is
shown in the Fig 1 & Fig 2. Finally the optimum solution is found when x=15 and y=20.For more complex
problems where it is not possible to easily solve the problem mathematically ,these algorithms can be used.
Figure 1 Movement of particles to find optimum solution
Figure 2 Global best solution
Application of Genetic Algorithm and Particle Swarm Optimization in Software Testing
DOI: 10.9790/0661-17127578 www.iosrjournals.org 78 | Page
V. Comparison Of GA And PSO
Genetic Algorithm and Particle Swarm Optimization technique are both evolutionary search algorithm
and have been applied in variety of problem domains.[8 &9] GA can be applied to number of problems like N-
queens problem, Travel salesman problem to find optimal solution. GA suffers from the drawback that it traps in
local optima, that is it does not know how to sacrifice short term fitness for long term fitness. It does not keep in
account the global best position of the individual. This drawback is overcome by Particle Swarm optimization
technique which tracks the particle personal best position as well as global best position ,hence it moves toward
global optima without getting trapped in local optima. GA has been popular because of its parallel nature of
search ,and essentially because it can solve non linear ,multi model problems. It can handle both Continuous and
discrete variables where as PSO can easily handle Continuous variables. In comparison to GA ,PSO has few
parameters and it is easy to implement .Calculation of PSO Algorithm is very simple though it is difficult to
implement with problem of non coordinate system .It is problem dependent, Problem having continuous
variables PSO is superior to GA .Many researchers have compared both the technologies .PSO outperforms
GA, and is more effective in general however superiority of PSO is problem dependent.
VI. Conclusion
PSO is relatively recent heuristic approach, It is similar to Genetic algorithm in a way that they both are
population based evolutionary algorithms. Paper is reported on the application of Genetic Algorithm and
Particle Swarm Optimization. Paper described the basic concepts of GA and PSO ,how the test cases are
generated using genetic algorithm and how they are useful in finding the optimal solution to the problem.
Comparative study is done between both the algorithm where GA can be useful and how PSO overcome the
drawback of GA. We also intend to extend the approach described here so that it is useful to solve many
problems like knapsack problem.
References
[1]. B. Beizer,Software testing techniques, Second Edition, Van Nostrand Reinhold, NewYork, 1990.
[2]. Nirmal Kumar Gupta and Dr. Mukesh Kumar Rohil,, Using Genetic Algorithm for Unit Testing Of Object Oriented Software,
IJSSST, Vol.10, No.3.
[3]. S. Desikan and G. Ramesh, ,Software testing principles & practices, Pearson Education, 2007.
[4]. K. F. Man, ,K. S. Tang, and S. Kwong,,Genetic Algorithms: Concepts and Applications, IEEE Transaction on Industrial Electronics
,VOL. 43, NO. 5, October 1996..
[5]. Abhishek Singhal, Swati Chandna and Abhay Bansal, Optimization of Test Cases Using Genetic Algorithm, International Journal of
Emerging Technology and Advanced Engineering ISSN 2250-2459, Volume 2, Issue 3, March 2012.
[6]. Sanjay Singla, Dharminder Kumar, H M Rai3 and Priti Singla, Hybrid PSO Approach to Automate Test Data Generation for Data
Flow Coverage with Dominance Concepts, International Journal of Advanced Science and Technology Vol. 37, December, 2011
[7]. K. Agrawal and G. Srivastava, Towards software test data generation using discrete quantum particle swarm optimization, ISEC,
Mysore,India, pp. 65-68, February 2010
[8]. Andreas Windisch, Stefan Wappler and Joachim Wegener, Applying Particle Swarm Optimization to Software Testing,
GECCO’07, July 7–11, 2007, London, England, United Kingdom Copyright 2007 ACM 978-1-59593-697-4/07/0007.
[9]. Praveen Ranjan Srivastava1 and Tai-hoon Kim2, Application of Genetic Algorithm in Software Testing,, International Journal of
Software Engineering and Its Applications Vol. 3, No.4, October 2009.

More Related Content

What's hot (16)

PDF
50120140504022
IAEME Publication
 
PDF
Coevolution of Second-order-mutant
IJECEIAES
 
PPTX
Introduction to particle swarm optimization
Mrinmoy Majumder
 
PDF
EVOLUTIONARY COMPUTING TECHNIQUES FOR SOFTWARE EFFORT ESTIMATION
ijcsit
 
PDF
E034023028
ijceronline
 
PDF
Data Science - Part XIV - Genetic Algorithms
Derek Kane
 
PDF
A Non-Revisiting Genetic Algorithm for Optimizing Numeric Multi-Dimensional F...
ijcsa
 
PDF
Biology-Derived Algorithms in Engineering Optimization
Xin-She Yang
 
PDF
Explainable AI in Drug Hunting
Ed Griffen
 
PPTX
Optimization technique genetic algorithm
Uday Wankar
 
PDF
Genetic Algorithms
adil raja
 
PDF
AUTOMATIC GENERATION AND OPTIMIZATION OF TEST DATA USING HARMONY SEARCH ALGOR...
csandit
 
PDF
The potential role of ai in the minimisation and mitigation of project delay
Pieter Rautenbach
 
PPTX
Introduction to genetic programming
abhishek singh
 
DOC
Dowload Paper.doc.doc
butest
 
PDF
Application of Genetic Algorithm in Software Engineering: A Review
IRJESJOURNAL
 
50120140504022
IAEME Publication
 
Coevolution of Second-order-mutant
IJECEIAES
 
Introduction to particle swarm optimization
Mrinmoy Majumder
 
EVOLUTIONARY COMPUTING TECHNIQUES FOR SOFTWARE EFFORT ESTIMATION
ijcsit
 
E034023028
ijceronline
 
Data Science - Part XIV - Genetic Algorithms
Derek Kane
 
A Non-Revisiting Genetic Algorithm for Optimizing Numeric Multi-Dimensional F...
ijcsa
 
Biology-Derived Algorithms in Engineering Optimization
Xin-She Yang
 
Explainable AI in Drug Hunting
Ed Griffen
 
Optimization technique genetic algorithm
Uday Wankar
 
Genetic Algorithms
adil raja
 
AUTOMATIC GENERATION AND OPTIMIZATION OF TEST DATA USING HARMONY SEARCH ALGOR...
csandit
 
The potential role of ai in the minimisation and mitigation of project delay
Pieter Rautenbach
 
Introduction to genetic programming
abhishek singh
 
Dowload Paper.doc.doc
butest
 
Application of Genetic Algorithm in Software Engineering: A Review
IRJESJOURNAL
 

Similar to Application of Genetic Algorithm and Particle Swarm Optimization in Software Testing (20)

PDF
Using particle swarm optimization to solve test functions problems
riyaniaes
 
PPTX
An automatic test data generation for data flow
WafaQKhan
 
PDF
Hybrid approaches in Network Optical Routing with QoS based on Genetic Algori...
IDES Editor
 
PPT
Application of Genetic Algorithm in Software Testing
Ghanshyam Yadav
 
PDF
Genetic algorithm
Respa Peter
 
PDF
Performance Analysis of GA and PSO over Economic Load Dispatch Problem
IOSR Journals
 
PDF
Da35573574
IJERA Editor
 
PDF
IJWMN -A Hybrid GAPSO Optimization Approach
ijwmn
 
PDF
A HYBRID GAPSO OPTIMIZATION APPROACH....
ijwmn
 
PDF
A comparison of particle swarm optimization and the genetic algorithm by Rani...
Pim Piepers
 
PPTX
BGA.pptx
ShubhamKamble942039
 
PPTX
Particle Swarm Optimization
QasimRehman
 
PDF
Introduction to Genetic Algorithms and Evolutionary Computation
Aleksander Stensby
 
PPT
Swarm intelligence pso and aco
satish561
 
PPTX
nature inspired algorithms
Gaurav Goel
 
PPTX
Genetic Algorithm
Ankit Chaudhary
 
PDF
Optimazation
Ahmed M. Elkholy
 
PDF
Comparison
Tomasz Waszczyk
 
PPTX
Genetic algorithms
RimpleDhamija
 
PDF
A Review On Genetic Algorithm And Its Applications
Karen Gomez
 
Using particle swarm optimization to solve test functions problems
riyaniaes
 
An automatic test data generation for data flow
WafaQKhan
 
Hybrid approaches in Network Optical Routing with QoS based on Genetic Algori...
IDES Editor
 
Application of Genetic Algorithm in Software Testing
Ghanshyam Yadav
 
Genetic algorithm
Respa Peter
 
Performance Analysis of GA and PSO over Economic Load Dispatch Problem
IOSR Journals
 
Da35573574
IJERA Editor
 
IJWMN -A Hybrid GAPSO Optimization Approach
ijwmn
 
A HYBRID GAPSO OPTIMIZATION APPROACH....
ijwmn
 
A comparison of particle swarm optimization and the genetic algorithm by Rani...
Pim Piepers
 
Particle Swarm Optimization
QasimRehman
 
Introduction to Genetic Algorithms and Evolutionary Computation
Aleksander Stensby
 
Swarm intelligence pso and aco
satish561
 
nature inspired algorithms
Gaurav Goel
 
Genetic Algorithm
Ankit Chaudhary
 
Optimazation
Ahmed M. Elkholy
 
Comparison
Tomasz Waszczyk
 
Genetic algorithms
RimpleDhamija
 
A Review On Genetic Algorithm And Its Applications
Karen Gomez
 
Ad

More from IOSR Journals (20)

PDF
A011140104
IOSR Journals
 
PDF
M0111397100
IOSR Journals
 
PDF
L011138596
IOSR Journals
 
PDF
K011138084
IOSR Journals
 
PDF
J011137479
IOSR Journals
 
PDF
I011136673
IOSR Journals
 
PDF
G011134454
IOSR Journals
 
PDF
H011135565
IOSR Journals
 
PDF
F011134043
IOSR Journals
 
PDF
E011133639
IOSR Journals
 
PDF
D011132635
IOSR Journals
 
PDF
C011131925
IOSR Journals
 
PDF
B011130918
IOSR Journals
 
PDF
A011130108
IOSR Journals
 
PDF
I011125160
IOSR Journals
 
PDF
H011124050
IOSR Journals
 
PDF
G011123539
IOSR Journals
 
PDF
F011123134
IOSR Journals
 
PDF
E011122530
IOSR Journals
 
PDF
D011121524
IOSR Journals
 
A011140104
IOSR Journals
 
M0111397100
IOSR Journals
 
L011138596
IOSR Journals
 
K011138084
IOSR Journals
 
J011137479
IOSR Journals
 
I011136673
IOSR Journals
 
G011134454
IOSR Journals
 
H011135565
IOSR Journals
 
F011134043
IOSR Journals
 
E011133639
IOSR Journals
 
D011132635
IOSR Journals
 
C011131925
IOSR Journals
 
B011130918
IOSR Journals
 
A011130108
IOSR Journals
 
I011125160
IOSR Journals
 
H011124050
IOSR Journals
 
G011123539
IOSR Journals
 
F011123134
IOSR Journals
 
E011122530
IOSR Journals
 
D011121524
IOSR Journals
 
Ad

Recently uploaded (20)

PDF
Decision support system in machine learning models for a face recognition-bas...
TELKOMNIKA JOURNAL
 
PDF
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
PDF
Generative AI & Scientific Research : Catalyst for Innovation, Ethics & Impact
AlqualsaDIResearchGr
 
PPTX
CST413 KTU S7 CSE Machine Learning Neural Networks and Support Vector Machine...
resming1
 
PPTX
CST413 KTU S7 CSE Machine Learning Introduction Parameter Estimation MLE MAP ...
resming1
 
PPTX
Precooling and Refrigerated storage.pptx
ThongamSunita
 
PDF
01-introduction to the ProcessDesign.pdf
StiveBrack
 
PPTX
Stability of IBR Dominated Grids - IEEE PEDG 2025 - short.pptx
ssuser307730
 
PDF
PROGRAMMING REQUESTS/RESPONSES WITH GREATFREE IN THE CLOUD ENVIRONMENT
samueljackson3773
 
PPSX
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
 
DOCX
Engineering Geology Field Report to Malekhu .docx
justprashant567
 
PDF
June 2025 Top 10 Sites -Electrical and Electronics Engineering: An Internatio...
elelijjournal653
 
PDF
PRIZ Academy - Process functional modelling
PRIZ Guru
 
PPTX
Functions in Python Programming Language
BeulahS2
 
PDF
13th International Conference of Security, Privacy and Trust Management (SPTM...
ijcisjournal
 
PDF
Tesia Dobrydnia - An Avid Hiker And Backpacker
Tesia Dobrydnia
 
PDF
Python Mini Project: Command-Line Quiz Game for School/College Students
MPREETHI7
 
PDF
Artificial Neural Network-Types,Perceptron,Problems
Sharmila Chidaravalli
 
PDF
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
PDF
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 
Decision support system in machine learning models for a face recognition-bas...
TELKOMNIKA JOURNAL
 
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
Generative AI & Scientific Research : Catalyst for Innovation, Ethics & Impact
AlqualsaDIResearchGr
 
CST413 KTU S7 CSE Machine Learning Neural Networks and Support Vector Machine...
resming1
 
CST413 KTU S7 CSE Machine Learning Introduction Parameter Estimation MLE MAP ...
resming1
 
Precooling and Refrigerated storage.pptx
ThongamSunita
 
01-introduction to the ProcessDesign.pdf
StiveBrack
 
Stability of IBR Dominated Grids - IEEE PEDG 2025 - short.pptx
ssuser307730
 
PROGRAMMING REQUESTS/RESPONSES WITH GREATFREE IN THE CLOUD ENVIRONMENT
samueljackson3773
 
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
 
Engineering Geology Field Report to Malekhu .docx
justprashant567
 
June 2025 Top 10 Sites -Electrical and Electronics Engineering: An Internatio...
elelijjournal653
 
PRIZ Academy - Process functional modelling
PRIZ Guru
 
Functions in Python Programming Language
BeulahS2
 
13th International Conference of Security, Privacy and Trust Management (SPTM...
ijcisjournal
 
Tesia Dobrydnia - An Avid Hiker And Backpacker
Tesia Dobrydnia
 
Python Mini Project: Command-Line Quiz Game for School/College Students
MPREETHI7
 
Artificial Neural Network-Types,Perceptron,Problems
Sharmila Chidaravalli
 
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 

Application of Genetic Algorithm and Particle Swarm Optimization in Software Testing

  • 1. IOSR Journal of Computer Engineering (IOSR-JCE) e-ISSN: 2278-0661,p-ISSN: 2278-8727, Volume 17, Issue 1, Ver. II (Jan – Feb. 2015), PP 75-78 www.iosrjournals.org DOI: 10.9790/0661-17127578 www.iosrjournals.org 75 | Page Application of Genetic Algorithm and Particle Swarm Optimization in Software Testing Deepti Arora1 , Anurag Singh Baghel2 1,2, (Gautam Buddha University,Uttar Pradesh,India) Abstract: This paper will describe a method for optimizing software testing by finding the most error prone paths in the program. This can be achieved by a meta-heuristic technique, that is by using genetic algorithm and particle swarm optimization. As exhaustive software testing is not possible where software is tested with all the possible inputs , those parts of software are also tested which are not error prone..Goal is to generate test cases using both the algorithms and then comparative study is done between Particle swarm optimization and genetic algorithm. Keywords: Software Testing, Meta-heuristics , Genetic Algorithms, Particle Swarm Optimization, Software test cases. I. Introduction Testing is the one of the crucial phase that is performed during software development. It is a primary technique which is used to gain consumer confidence in the software. It is conducted by executing the program developed with test inputs and comparing the observed output with the expected one .[1]Software testing is done to identify any errors or missing requirements in contrary to the actual requirements. It is done to validate the quality of the software testing using minimal cost and efforts and to generate high quality test cases. It uncovers the error in the software, including errors in requirement analysis, design document, coding, system resources and system environments, hardware problems and their interfaces to the software .[2] It is very time consuming and laborious activity. It is costly and consumes about 50% of the cost of the software development.[3]. Main goal of testing to find as many faults as possible in a software. As mentioned earlier it a time consuming activity ,as it is impossible to test the software unit with all the combinations of inputs so there is a need to design minimum no. of test cases that will discover as many faults as possible . However, software testing automation is not a straight forward process. For years a lot of research have been done in this area to generate test cases ,researchers developed methods like random test case generator, symbolic test data generators and dynamic test data generators. This paper applied the EST (Evolutionary software testing ) techniquie.EST is the automatic software test case generation technique which in turn will reduce the cost of development of software. EST interprets the task of test case generation as an optimization problem and tries to solve it using a search technique .EST uses an meta-heuristic search technique that is genetic algorithm to convert the task of test case generation into an optimal problem. Evolutionary Testing search for optimal test parameter combinations that satisfy a test criterion. Test criterion is represented fitness function that measures how well optimization parameters that are automatically generated are satisfying the given test criterion .There are variety of techniques for test case generation but in this paper we will focus on genetic algorithm and particle swarm optimization technique. This paper will present the result of our research in into the application of GA and PSO search approach, to find optimal solution in the software construct. II. Genetic Algorithm Genetic Algorithm (GA) are heuristic search algorithm.[4]They are based on the evolutionary idea of natural selection and genetics. Genetic algorithm is inspired by the Dalton’s theory about evolution that is survival of the fittest. Genetic algorithm is a part of evolutionary computing which is a growing field of Artificial Intelligence. GA exploits the historical information to direct the search in region of better performance with in the search space. [5] In this way competition among individuals for better resources results in fittest individual dominating over the weaker ones. Genetic Algorithms are more robust hence they are better than conventional AI(Artificial Intelligence). GA does not break easily even if there is a slightly change in the input and it also does not get affected by noise. GA offer benefit over typical search of optimization problem in searching large state space, multimodal search space and n dimensional surface. Distinct element in GA is individual and population. Individual represents single solution while population represents set of Solutions which is currently involved in this search process. Each individual is represented as chromosome. That is an Initial pool of chromosomes. Population size can be few dozens to thousands. To do optimization fitness function is required to select the best solution from the population and
  • 2. Application of Genetic Algorithm and Particle Swarm Optimization in Software Testing DOI: 10.9790/0661-17127578 www.iosrjournals.org 76 | Page discard those not so good solutions. GA consists of following operators that is Selection Operator chromosomes are selected for cross-over based on the value of the fitness function Cross- Over Operator combine two chromosomes to produce new chromosomes. Mutation Operator in this value is randomly changed to create new genes in the individual. Pseudo code of GA Initialize (population) Evaluate Fitness of the population While (termination condition is met) do { Selection(Population) Cross-over(Population) Mutation(population) Evaluate (Population) } GA [6] starts with randomly generated population of individuals or chromosomes .Fitness of individual is calculated based on some fitness function. After the fitness is calculated selection of individuals is done based on the Roulette –Wheel Selection method i.e an individual having higher fitness value has the more chance of getting selected .Then Cross over operator is applied to produce new offspring in the population that may have better characteristics than their parents. Mutation is done to introduce new individual in the population .its is done by flipping the bit of the chromosomes. III. Particle Swarm Optimization Particle Swarm Optimization (PSO) [7] is a relatively recent heuristic search method. It is similar to GA in the sense that both are evolutionary algorithms .It is one of the meta-heuristics approach that optimizes a problem and try to improve candidate solution iteratively. PSO is generally used to solve those problems whose solution can be represented as a point in an n-dimensional space. In PSO potential solution is called particle. A number of particles are randomly set into motion through this space. Each particle posses its current position, current velocity ,and its pbest position .Pbest is the personal best position explored so far. It also incorporates Gbest that global best position achieved by all its individuals. It is a simple approach and it is effective across a variety of problem domains. Pseudo code for PSO The PSO algorithm consists of just few steps, which are repeated until some stopping condition is met. The steps are as follow:  Initialize the population of individuals with current position and, velocity.  Evaluate the fitness of the individual particle (Pbest).  Keep track of the individual highest fitness (Gbest).  Modify velocity based on Pbest and Gbest location.  Update the particle position. PSO starts with initialization of particle velocity and current position. Here particle is in 2-D space . Fitness value of the particle is calculated according to function. If the fitness of the particle is better than its previous value update particle x and y position that is its personal best position. Also if the value is better than gbest position update global best position of the particle. Apply equations to update the x and y velocity vector of the particles. Process repeats until termination criteria is met or the optimal solution is found. IV. Implementation Genetic Algorithm is implemented in c language. result is as follows. GA approach to problem to maximize the function (1) F(x)=x3 -x2 . X represent 5 digit unsigned binary integer .i.e x can take value [0,31]. Four randomly generated solution to problem are 14,18,24,30. Fitness of the individual is calculated by the function F(x).String no. 4 has the maximum value having more chances of getting selected. here N is 4 . One point Crossover is performed in a couple. New offspring is generated. Mutation is performed. We get new generation Again the process is repeated till the maximum possible value of the solution is obtained .Luckily in this case in the second iteration we will get desired value. Whereas In most of the cases GA traps in local optima. But here We have got the global optimum solution.
  • 3. Application of Genetic Algorithm and Particle Swarm Optimization in Software Testing DOI: 10.9790/0661-17127578 www.iosrjournals.org 77 | Page Table 1 String N o. Initial Population Value of x F(x)=X3 -x2 pi Expected Count(N*pi) 1 01111 15 3150 0.072 0.289 2 10010 18 5508 0.126 0.505 3 10101 21 8820 0.202 0.809 4 11110 30 26100 0.598 2.395 Sum 43578 1 4 Average 10894 0.25 1 Max 26100 0.598 2.395 Table 2 Before Crossover After Crossover Mutation Of element 3 at position 2 New Generation is as follows (Value of x) 01111 01110 01110 14 10010 10011 10011 19 10101 10100 10110 22 11110 11111 11111 31 Particle Swarm Optimization For Mathematical function (2) val=(x-15)4 -(y-20)2 +9 Particle is initialized with current position and velocity. Program will search for optimal solution through the movement of particle. Program will keep track of personal best and global best position of the particle and update its position and velocity .Optimal solution here is to minimize the mathematical function .PSO is implemented in C language. How the particle moves in the search space to find global best solution is shown in the Fig 1 & Fig 2. Finally the optimum solution is found when x=15 and y=20.For more complex problems where it is not possible to easily solve the problem mathematically ,these algorithms can be used. Figure 1 Movement of particles to find optimum solution Figure 2 Global best solution
  • 4. Application of Genetic Algorithm and Particle Swarm Optimization in Software Testing DOI: 10.9790/0661-17127578 www.iosrjournals.org 78 | Page V. Comparison Of GA And PSO Genetic Algorithm and Particle Swarm Optimization technique are both evolutionary search algorithm and have been applied in variety of problem domains.[8 &9] GA can be applied to number of problems like N- queens problem, Travel salesman problem to find optimal solution. GA suffers from the drawback that it traps in local optima, that is it does not know how to sacrifice short term fitness for long term fitness. It does not keep in account the global best position of the individual. This drawback is overcome by Particle Swarm optimization technique which tracks the particle personal best position as well as global best position ,hence it moves toward global optima without getting trapped in local optima. GA has been popular because of its parallel nature of search ,and essentially because it can solve non linear ,multi model problems. It can handle both Continuous and discrete variables where as PSO can easily handle Continuous variables. In comparison to GA ,PSO has few parameters and it is easy to implement .Calculation of PSO Algorithm is very simple though it is difficult to implement with problem of non coordinate system .It is problem dependent, Problem having continuous variables PSO is superior to GA .Many researchers have compared both the technologies .PSO outperforms GA, and is more effective in general however superiority of PSO is problem dependent. VI. Conclusion PSO is relatively recent heuristic approach, It is similar to Genetic algorithm in a way that they both are population based evolutionary algorithms. Paper is reported on the application of Genetic Algorithm and Particle Swarm Optimization. Paper described the basic concepts of GA and PSO ,how the test cases are generated using genetic algorithm and how they are useful in finding the optimal solution to the problem. Comparative study is done between both the algorithm where GA can be useful and how PSO overcome the drawback of GA. We also intend to extend the approach described here so that it is useful to solve many problems like knapsack problem. References [1]. B. Beizer,Software testing techniques, Second Edition, Van Nostrand Reinhold, NewYork, 1990. [2]. Nirmal Kumar Gupta and Dr. Mukesh Kumar Rohil,, Using Genetic Algorithm for Unit Testing Of Object Oriented Software, IJSSST, Vol.10, No.3. [3]. S. Desikan and G. Ramesh, ,Software testing principles & practices, Pearson Education, 2007. [4]. K. F. Man, ,K. S. Tang, and S. Kwong,,Genetic Algorithms: Concepts and Applications, IEEE Transaction on Industrial Electronics ,VOL. 43, NO. 5, October 1996.. [5]. Abhishek Singhal, Swati Chandna and Abhay Bansal, Optimization of Test Cases Using Genetic Algorithm, International Journal of Emerging Technology and Advanced Engineering ISSN 2250-2459, Volume 2, Issue 3, March 2012. [6]. Sanjay Singla, Dharminder Kumar, H M Rai3 and Priti Singla, Hybrid PSO Approach to Automate Test Data Generation for Data Flow Coverage with Dominance Concepts, International Journal of Advanced Science and Technology Vol. 37, December, 2011 [7]. K. Agrawal and G. Srivastava, Towards software test data generation using discrete quantum particle swarm optimization, ISEC, Mysore,India, pp. 65-68, February 2010 [8]. Andreas Windisch, Stefan Wappler and Joachim Wegener, Applying Particle Swarm Optimization to Software Testing, GECCO’07, July 7–11, 2007, London, England, United Kingdom Copyright 2007 ACM 978-1-59593-697-4/07/0007. [9]. Praveen Ranjan Srivastava1 and Tai-hoon Kim2, Application of Genetic Algorithm in Software Testing,, International Journal of Software Engineering and Its Applications Vol. 3, No.4, October 2009.