Search Based Software Engineering Justyna Petke C entre for R - - PowerPoint PPT Presentation

search based software engineering
SMART_READER_LITE
LIVE PREVIEW

Search Based Software Engineering Justyna Petke C entre for R - - PowerPoint PPT Presentation

Search Based Software Engineering Justyna Petke C entre for R esearch in E volution, S earch and T esting University College London CREST Outline Search Based Software Engineering Combinatorial Interaction Testing Genetic Improvement CREST


slide-1
SLIDE 1

CREST

Search Based Software Engineering

Justyna Petke

Centre for Research in Evolution, Search and Testing University College London

slide-2
SLIDE 2

CREST

Justyna Petke Search Based Software Engineering

Outline

Search Based Software Engineering Combinatorial Interaction Testing Genetic Improvement

slide-3
SLIDE 3

CREST

Justyna Petke Search Based Software Engineering

Thank you

Mark Harman Yue Jia Yuanyuan Zhang

slide-4
SLIDE 4

CREST

Justyna Petke Search Based Software Engineering

SBSE Tutorial

Mark Harman, Phil McMinn, Jerffeson Teixeira de Souza and Shin Yoo. Search Based Software Engineering: Techniques, Taxonomy, Tutorial. Springer, 2012.

slide-5
SLIDE 5

CREST

Justyna Petke Search Based Software Engineering

What is SBSE

slide-6
SLIDE 6

CREST

Justyna Petke Search Based Software Engineering

What is SBSE

Search Based Optimisation Software Engineering

S B S E

slide-7
SLIDE 7

CREST

Justyna Petke Search Based Software Engineering

What is SBSE

In SBSE we apply search techniques to search large search spaces, guided by a fitness function that captures properties of the acceptable software artefacts we seek. potentially exhaustive pick one at random sweet spot

slide-8
SLIDE 8

CREST

Justyna Petke Search Based Software Engineering

What is SBSE

In SBSE we apply search techniques to search large search spaces, guided by a fitness function that captures properties of the acceptable software artefacts we seek.

Genetic Algorithms Hill Climbing Simulated Annealing Random Tabu Search Estimation of Distribution Algorithms Particle Swarm Optimization Ant Colonies LP Genetic Programming Greedy

slide-9
SLIDE 9

CREST

Justyna Petke Search Based Software Engineering

Why SBSE?

slide-10
SLIDE 10

CREST

Justyna Petke Search Based Software Engineering

Eight Queens Problem

slide-11
SLIDE 11

CREST

Justyna Petke Search Based Software Engineering

Eight Queens Problem

Perfect Score 0

slide-12
SLIDE 12

CREST

Justyna Petke Search Based Software Engineering

Eight Queens Problem

Two attacks Score -2

slide-13
SLIDE 13

CREST

Justyna Petke Search Based Software Engineering

Eight Queens Problem

slide-14
SLIDE 14

CREST

Justyna Petke Search Based Software Engineering

Eight Queens Problem

Three attacks Score -3

slide-15
SLIDE 15

CREST

Justyna Petke Search Based Software Engineering

That was easy

slide-16
SLIDE 16

CREST

Justyna Petke Search Based Software Engineering

Eight Queens Problem

Place 8 queens

  • n the

board So that there are no attacks

slide-17
SLIDE 17

CREST

Justyna Petke Search Based Software Engineering

Eight Queens Problem

Place 44 queens

  • n the

board So that there are no attacks

slide-18
SLIDE 18

CREST

Justyna Petke Search Based Software Engineering

Eight Queens Problem

Place 10 queens

  • n the

board So that there are no attacks

12

slide-19
SLIDE 19

CREST

Justyna Petke Search Based Software Engineering

Checking vs Generating

Task One:
 Write a method to determine which is the better of two placements of N queens Task Two:
 Write a method to construct a board placement with N non attacking queens

slide-20
SLIDE 20

CREST

Justyna Petke Search Based Software Engineering

Checking vs Generating

Task One:
 Write a method to determine which is the better of two placements of N queens Task Two:
 Write a method to construct a board placement with N non attacking queens

slide-21
SLIDE 21

CREST

Justyna Petke Search Based Software Engineering

Checking vs Generating

Search Based Software Engineering
 Write a method to determine which is the better of two solutions Conventional Software Engineering
 Write a method to construct a perfect solution

slide-22
SLIDE 22

CREST

Justyna Petke Search Based Software Engineering

Checking vs Generating

Search Based Software Engineering
 Write a method to determine which is the better of two solutions Conventional Software Engineering
 Write a method to construct a perfect solution

slide-23
SLIDE 23

CREST

Justyna Petke Search Based Software Engineering

Checking vs Generating

Search Based Software Engineering
 Write a method to determine which is the better of two solutions Conventional Software Engineering
 Write a method to construct a perfect solution

slide-24
SLIDE 24

CREST

Justyna Petke Search Based Software Engineering

Checking vs Generating

Search Based Software Engineering
 Write a fitness function to determine which is the better of two solutions Conventional Software Engineering
 Write a method to construct a perfect solution

slide-25
SLIDE 25

CREST

Justyna Petke Search Based Software Engineering

Checking vs Generating

Search Based Software Engineering
 Write a fitness function to guide a search Conventional Software Engineering
 Write a method to construct a perfect solution

slide-26
SLIDE 26

CREST

Justyna Petke Search Based Software Engineering

Checking vs Generating

Search Based Software Engineering
 Write a fitness function to guide an automated search Conventional Software Engineering
 Write a method to construct a perfect solution

slide-27
SLIDE 27

CREST

Justyna Petke Search Based Software Engineering

What is SBSE

let’s listen to software engineers ... ... what sort of things do they say?

slide-28
SLIDE 28

CREST

Justyna Petke Search Based Software Engineering

Software Engineers Say

Requirements: We need to satisfy business and technical concerns Management: We need to reduce risk while maintaining completion time Design: We need increased cohesion and decreased coupling T esting: We need fewer tests that find more nasty bugs Refactoring: We need to optimise for all metrics M1,..., Mn

slide-29
SLIDE 29

CREST

Justyna Petke Search Based Software Engineering

Software Engineers Say

Requirements: We need to satisfy business and technical concerns Management: We need to reduce risk while maintaining completion time Design: We need increased cohesion and decreased coupling T esting: We need fewer tests that find more nasty bugs Refactoring: We need to optimise for all metrics M1,..., Mn

slide-30
SLIDE 30

CREST

Justyna Petke Search Based Software Engineering

Software Engineers Say

Requirements: We need to satisfy business and technical concerns Management: We need to reduce risk while maintaining completion time Design: We need increased cohesion and decreased coupling T esting: We need fewer tests that find more nasty bugs Refactoring: We need to optimise for all metrics M1,..., Mn

slide-31
SLIDE 31

CREST

Justyna Petke Search Based Software Engineering

Software Engineers Say

Requirements: We need to satisfy business and technical concerns Management: We need to reduce risk while maintaining completion time Design: We need increased cohesion and decreased coupling T esting: We need fewer tests that find more nasty bugs Refactoring: We need to optimise for all metrics M1,..., Mn

slide-32
SLIDE 32

CREST

Justyna Petke Search Based Software Engineering

Software Engineers Say

Requirements: We need to satisfy business and technical concerns Management: We need to reduce risk while maintaining completion time Design: We need increased cohesion and decreased coupling T esting: We need fewer tests that find more nasty bugs Refactoring: We need to optimise for all metrics M1,..., Mn

slide-33
SLIDE 33

CREST

Justyna Petke Search Based Software Engineering

Software Engineers Say

Requirements: We need to satisfy business and technical concerns Management: We need to reduce risk while maintaining completion time Design: We need increased cohesion and decreased coupling T esting: We need fewer tests that find more nasty bugs Refactoring: We need to optimise for all metrics M1,..., Mn

slide-34
SLIDE 34

CREST

Justyna Petke Search Based Software Engineering

Software Engineers Say

Requirements: We need to satisfy business and technical concerns Management: We need to reduce risk while maintaining completion time Design: We need increased cohesion and decreased coupling T esting: We need fewer tests that find more nasty bugs Refactoring: We need to optimise for all metrics M1,..., Mn Requirements: We need to satisfy business and technical concerns Management: We need to reduce risk while maintaining completion time Design: We need increased cohesion and decreased coupling T esting: We need fewer tests that find more nasty bugs Refactoring: We need to optimise for all metrics M1,..., Mn

slide-35
SLIDE 35

CREST

Justyna Petke Search Based Software Engineering

Software Engineers Say

Requirements: We need to satisfy business and technical concerns Management: We need to reduce risk while maintaining completion time Design: We need increased cohesion and decreased coupling T esting: We need fewer tests that find more nasty bugs Refactoring: We need to optimise for all metrics M1,..., Mn

All have been addressed in the SBSE literature

slide-36
SLIDE 36

CREST

Justyna Petke Search Based Software Engineering

Search Based Optimisation

Mechanical Engineering Electronic Engineering Civil Engineering Aerospace Engineering What makes Software Engineering so special ?

slide-37
SLIDE 37

CREST

Justyna Petke Search Based Software Engineering

Search Based Optimisation

Mechanical Engineering Electronic Engineering Civil Engineering Aerospace Engineering What makes Software Engineering so special ?

slide-38
SLIDE 38

CREST

Justyna Petke Search Based Software Engineering

Fitness Evaluation

Physical Engineering cost: $20,000.00 Virtual Engineering cost: $0.00.0000000002

slide-39
SLIDE 39

CREST

Justyna Petke Search Based Software Engineering

Traditional Engineering Artifact Optimisation goal Fitness computed

  • n a representation

Software Engineering Artifact Optimisation goal Fitness computed directly Maximise compression Minimise fuel consumption Maximise cohesion Minimise coupling

slide-40
SLIDE 40

CREST

Justyna Petke Search Based Software Engineering

Growth Trends

slide-41
SLIDE 41

CREST

Justyna Petke Search Based Software Engineering

Polynomial rise in publications

slide-42
SLIDE 42

CREST

Justyna Petke Search Based Software Engineering

Percentage of Paper Number

  • n SBSE
slide-43
SLIDE 43

CREST

Justyna Petke Search Based Software Engineering

S B S T

slide-44
SLIDE 44

CREST

Justyna Petke Search Based Software Engineering

Structural

slide-45
SLIDE 45

CREST

Justyna Petke Search Based Software Engineering

Structural

find tests to cover branches, statements & dataflow, etc.

slide-46
SLIDE 46

CREST

Justyna Petke Search Based Software Engineering

CIT

slide-47
SLIDE 47

CREST

Justyna Petke Search Based Software Engineering

Augment

slide-48
SLIDE 48

CREST

Justyna Petke Search Based Software Engineering

Augment

find new tests from old tests

slide-49
SLIDE 49

CREST

Justyna Petke Search Based Software Engineering

Regression

slide-50
SLIDE 50

CREST

Justyna Petke Search Based Software Engineering

Regression

find good subsets and

  • rders of tests
slide-51
SLIDE 51

CREST

Justyna Petke Search Based Software Engineering

SPLs

slide-52
SLIDE 52

CREST

Justyna Petke Search Based Software Engineering

Mutation

slide-53
SLIDE 53

CREST

Justyna Petke Search Based Software Engineering

State based

slide-54
SLIDE 54

CREST

Justyna Petke Search Based Software Engineering

Model based

slide-55
SLIDE 55

CREST

Justyna Petke Search Based Software Engineering

Black box

slide-56
SLIDE 56

CREST

Justyna Petke Search Based Software Engineering

56

Just some of the many SBSE applications

Agent Oriented Aspect Oriented Assertion Generation Bug Fixing Component Oriented Design Effort Estimation Heap Optimisation Model Checking Predictive Modelling Probe distribution Program Analysis Program Comprehension Program Transformation Project Management Protocol Optimisation QoS Refactoring Regression Testing Requirements Reverse Engineering SOA Software Maintenance and Evolution Test Generation UIO generation

slide-57
SLIDE 57

CREST

Justyna Petke Search Based Software Engineering

Author statistics

more than 1250 authors more than 1150 papers more than 390 institutions more than 50 countries

source: SBSE repository, July 2013.

slide-58
SLIDE 58

CREST

Justyna Petke Search Based Software Engineering

SBSE Key Ingredients

The choice of the representation of the problem The definition of the fitness function

slide-59
SLIDE 59

CREST

Justyna Petke Search Based Software Engineering

Overall Architecture

  • f SBSE Approach
slide-60
SLIDE 60

CREST

Justyna Petke Search Based Software Engineering

Search Based Algorithms Used

slide-61
SLIDE 61

CREST

Justyna Petke Search Based Software Engineering

Random Search

slide-62
SLIDE 62

CREST

Justyna Petke Search Based Software Engineering

Random Solution

Score -3

slide-63
SLIDE 63

CREST

Justyna Petke Search Based Software Engineering

Random Search

slide-64
SLIDE 64

CREST

Justyna Petke Search Based Software Engineering

Hill Climbing

Select a starting solution s ∈ Solutions Repeat Select s′ ∈ Neighborhood(s) such that fitness(s′) > fitness(s) according to ascent strategy s ← s′
 Until fitness(s) ≥ fitness(s′), ∀s′ ∈ Neighbourhood(s)

slide-65
SLIDE 65

CREST

Justyna Petke Search Based Software Engineering

Hill Climbing

Score -2

slide-66
SLIDE 66

CREST

Justyna Petke Search Based Software Engineering

Hill Climbing

Score -1

slide-67
SLIDE 67

CREST

Justyna Petke Search Based Software Engineering

Hill Climbing

Select a starting solution s ∈ Solutions Repeat Select s′ ∈ Neighborhood(s) such that fitness(s′) > fitness(s) according to ascent strategy s ← s′
 Until fitness(s) ≥ fitness(s′), ∀s′ ∈ Neighbourhood(s) Will the algorithm always find an optimal solution ?

slide-68
SLIDE 68

CREST

Justyna Petke Search Based Software Engineering

Hill Climbing

slide-69
SLIDE 69

CREST

Justyna Petke Search Based Software Engineering

Simulated Annealing

slide-70
SLIDE 70

CREST

Justyna Petke Search Based Software Engineering

Simulated Annealing

Select a starting solution s ∈ Solutions Select an initial temperature t > 0 Repeat iterations ← 0 Repeat Select s′ ∈ Neighbourhood(s) at random δ ← fitness(s) − fitness(s′)
 If δ < 0 Then s ← s′ Else Generate random number r, 0 ≤ r < 1 If r < e^(−δ/t) Then s ← s′ iterations ← iterations + 1 Until iterations = num solutions
 Decrease t according to cooling schedule Until Stopping Condition Reached

slide-71
SLIDE 71

CREST

Justyna Petke Search Based Software Engineering

Genetic Algorithm

slide-72
SLIDE 72

CREST

Justyna Petke Search Based Software Engineering

Genetic Algorithm

Randomly generate or seed initial population P Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and offspring Mutate P′ P←P′ Until Stopping Condition Reached

slide-73
SLIDE 73

CREST

Justyna Petke Search Based Software Engineering

Case Study

slide-74
SLIDE 74

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation

Given: a test suite, T, the set of permutations of T, PT, and a function from PT to real numbers, f : P T → R 
 Problem: to find T′ ∈ PT such that (∀T′′)(T′′ ∈ PT) (T′′not equals T′) [ f(T′) ≥ f(T′′) ]

slide-75
SLIDE 75

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Given: a test suite, T, fault detection history for each test case 
 Problem: find T’ that maximises fault detection rate

slide-76
SLIDE 76

CREST

Justyna Petke Search Based Software Engineering

SBSE Key Ingredients

The choice of the representation of the problem The definition of the fitness function

slide-77
SLIDE 77

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Representation

t1 t3 t6 t2 t5 t4 t1 t3 t2 t6 t5 t4

Neighbouring Solution

slide-78
SLIDE 78

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Fitness Function Average Percentage of Faults Detected (APFD) metric * higher APFD implies earlier fault detection

* Sebastian G. Elbaum, Alexey G. Malishevsky, and Gregg Rothermel. Prioritizing test cases for regression testing. In International Symposium on Software Testing and Analysis, pages 102–112. ACM Press, 2000.

slide-79
SLIDE 79

CREST

Justyna Petke Search Based Software Engineering

Overall Architecture

  • f SBSE Approach
slide-80
SLIDE 80

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Search Algorithm

slide-81
SLIDE 81

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm

slide-82
SLIDE 82

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Randomly generate or seed initial population P Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

slide-83
SLIDE 83

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Randomly generate or seed initial population P Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t1 t3 t6 t2 t5 t4 t2 t5 t1 t3 t6 t4 t1 t3 t2 t6 t5 t4 t6 t4 t3 t5 t1 t2

slide-84
SLIDE 84

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Evaluate fitness of each individual in P Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t1 t3 t6 t2 t5 t4 t2 t5 t1 t3 t6 t4 t1 t3 t2 t6 t5 t4 t6 t4 t3 t5 t1 t2

APFD=68% APFD=55% APFD=72% APFD=78%

slide-85
SLIDE 85

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Select parents from P according to selection mechanism Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t1 t3 t6 t2 t5 t4

APFD=68%

t2 t5 t1 t3 t6 t4

APFD=55%

slide-86
SLIDE 86

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Select parents from P according to selection mechanism Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t1 t3 t6 t2 t5 t4

APFD=68%

slide-87
SLIDE 87

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Select parents from P according to selection mechanism Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t1 t3 t2 t6 t5 t4

APFD=72%

t6 t4 t3 t5 t1 t2

APFD=78%

slide-88
SLIDE 88

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Select parents from P according to selection mechanism Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t6 t4 t3 t5 t1 t2

APFD=78%

slide-89
SLIDE 89

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Select parents from P according to selection mechanism Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t6 t4 t3 t5 t1 t2

APFD=78%

t1 t3 t6 t2 t5 t4

APFD=68%

2-way tournament selection

slide-90
SLIDE 90

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Recombine parents to form new offspring Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

slide-91
SLIDE 91

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Crossover * Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring P′

* Giulio Antoniol, Massimiliano Di Penta, and Mark Harman. Search-based techniques applied to optimization of project planning for a massive maintenance project. In 21st IEEE International Conference on Software Maintenance, pages 240–249, Los Alamitos, California, USA, 2005. IEEE Computer Society Press.

slide-92
SLIDE 92

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Recombine parents to form new offspring Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t1 t3 t6 t2 t5 t4 t6 t4 t3 t5 t1 t2

slide-93
SLIDE 93

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Recombine parents to form new offspring Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t1 t3 t6 t2 t5 t4 t6 t4 t3 t5 t1 t2 t6 t4 t3 t1 t3 t6

slide-94
SLIDE 94

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Recombine parents to form new offspring Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t1 t3 t6 t2 t5 t4 t6 t4 t3 t5 t1 t2 t6 t4 t3 t1 t3 t6 t4 t5 t2

slide-95
SLIDE 95

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Recombine parents to form new offspring Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t1 t3 t6 t2 t5 t4 t6 t4 t3 t5 t1 t2 t6 t4 t3 t1 t2 t5 t1 t3 t6 t4 t5 t2

slide-96
SLIDE 96

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Construct new population P′ from parents & offspring Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t1 t3 t6 t2 t5 t4 t6 t4 t3 t5 t1 t2 t6 t4 t3 t1 t2 t5 t1 t3 t6 t4 t5 t2

slide-97
SLIDE 97

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Mutate P′ from parents & offspring Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t1 t3 t6 t2 t5 t4 t6 t4 t3 t5 t1 t2 t6 t4 t3 t1 t2 t5 t1 t3 t6 t4 t5 t2

slide-98
SLIDE 98

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Mutate P′ from parents & offspring Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t1 t3 t6 t2 t5 t4 t6 t4 t3 t5 t1 t2 t6 t4 t3 t1 t2 t5 t1 t3 t6 t4 t5 t2

slide-99
SLIDE 99

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm Mutate P′ from parents & offspring Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t1 t3 t6 t5 t2 t4 t6 t3 t4 t5 t1 t2 t6 t4 t1 t3 t2 t5 t3 t1 t6 t4 t5 t2

slide-100
SLIDE 100

CREST

Justyna Petke Search Based Software Engineering

Test Case Prioritisation in Regression Testing

Genetic Algorithm P←P′ from parents & offspring Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

t1 t3 t6 t5 t2 t4 t6 t3 t4 t5 t1 t2 t6 t4 t1 t3 t2 t5 t3 t1 t6 t4 t5 t2

slide-101
SLIDE 101

CREST

Justyna Petke Search Based Software Engineering

Genetic Algorithm

Genetic Algorithm Randomly generate or seed initial population P Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

slide-102
SLIDE 102

CREST

Justyna Petke Search Based Software Engineering

Genetic Programming

Genetic Algorithm Randomly generate or seed initial population P Repeat Evaluate fitness of each individual in P Select parents from P according to selection mechanism Recombine parents to form new offspring Construct new population P′ from parents and

  • ffspring

Mutate P′ P←P′ Until Stopping Condition Reached

slide-103
SLIDE 103

CREST

Justyna Petke Search Based Software Engineering

Genetic Programming Initial Population

* http://www.genetic-programming.com/crossover.gif

slide-104
SLIDE 104

CREST

Justyna Petke Search Based Software Engineering

Genetic Programming Crossover

* http://www.genetic-programming.com/crossover.gif

slide-105
SLIDE 105

CREST

Justyna Petke Search Based Software Engineering

Genetic Programming Mutation

* http://www.genetic-programming.com/crossover.gif

slide-106
SLIDE 106

CREST

Justyna Petke Search Based Software Engineering

Multi-Objective Optimisation

slide-107
SLIDE 107

CREST

Justyna Petke Search Based Software Engineering

Software Engineers Say

Requirements: We need to satisfy business and technical concerns Management: We need to reduce risk while maintaining completion time Design: We need increased cohesion and decreased coupling T esting: We need fewer tests that find more nasty bugs Refactoring: We need to optimise for all metrics M1,..., Mn

slide-108
SLIDE 108

CREST

Justyna Petke Search Based Software Engineering

Software Engineers Say

Requirements: We need to satisfy business and technical concerns Management: We need to reduce risk while maintaining completion time Design: We need increased cohesion and decreased coupling T esting: We need fewer tests that find more nasty bugs Refactoring: We need to optimise for all metrics M1,..., Mn

slide-109
SLIDE 109

CREST

Justyna Petke Search Based Software Engineering

Objective 1 Objective 2

Pareto Front

each white circle is a non-dominated solution found by a search algorithm

slide-110
SLIDE 110

CREST

Justyna Petke Search Based Software Engineering

Objective 3 Objective 4

Pareto Front

different objectives have different pareto fronts

slide-111
SLIDE 111

CREST

Justyna Petke Search Based Software Engineering

Objective 1 Objective 2 Objective 3

slide-112
SLIDE 112

CREST

Justyna Petke Search Based Software Engineering

Pareto optimal SBSE

Given: n fitness functions, f1, . . . , fn that take some vector

  • f parameters

Pareto optimality combines a set of measurements, fi , into a single ordinal scale metric, F: F( 1) > F( 2)
 ⇔
 ∀i. fi ( 1) ≥ fi ( 2) ∧ ∃i. fi ( 1) > fi ( 2)

‾ x ‾ x ‾ x ‾ x ‾ x ‾ x ‾ x

slide-113
SLIDE 113

CREST

Justyna Petke Search Based Software Engineering

Case Study

slide-114
SLIDE 114

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Given: A test suite of n tests, T, a set of m test goals {r1,...,rm}, that must be satisfied, and subsets of T, Tis, one associated with each of the ris such that any one of the test cases tj belonging to Ti can be used to achieve requirement ri. Problem: Find a representative set, T′, of test cases from T that satisfies all ris.

slide-115
SLIDE 115

CREST

Justyna Petke Search Based Software Engineering

Minimum Hitting Set Problem

t7 t6 t5 t4 t3 t2 t1 t8 t9 t10

requirement 1 requirement 2 requirement 3 requirement 4 requirement 5

slide-116
SLIDE 116

CREST

Justyna Petke Search Based Software Engineering

Minimum Hitting Set Problem

t6 t3

requirement 1 requirement 2 requirement 3 requirement 4 requirement 5

slide-117
SLIDE 117

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Representation

1 1 1

t1 t2 t3 t4 t5 t6 appears in a solution

slide-118
SLIDE 118

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Representation

1 1 1 1

Neighbouring Solution

1 1 1

slide-119
SLIDE 119

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Fitness Function structural coverage fault history coverage execution cost

slide-120
SLIDE 120

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Fitness Function structural coverage maximise fault history coverage maximise execution cost minimise

slide-121
SLIDE 121

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Search Algorithm

slide-122
SLIDE 122

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Nondominated Sorting Genetic Algorithm II (NSGA-II)*

* K. Deb, A. Pratap, S. Agarwal, and T. Meyarivan. A fast and elitist multiobjective genetic algorithm: 
 NSGA-II. IEEE Transactions on Evolutionary Computation, 6:182–197, April 2002.

slide-123
SLIDE 123

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Nondominated Sorting Genetic Algorithm II (NSGA-II)*

* K. Deb, A. Pratap, S. Agarwal, and T. Meyarivan. A fast and elitist multiobjective genetic algorithm: 
 NSGA-II. IEEE Transactions on Evolutionary Computation, 6:182–197, April 2002.

slide-124
SLIDE 124

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Nondominated Sorting Genetic Algorithm II (NSGA-II)*

pick an individual from a non-dominated pair via crowding distance

* K. Deb, A. Pratap, S. Agarwal, and T. Meyarivan. A fast and elitist multiobjective genetic algorithm: 
 NSGA-II. IEEE Transactions on Evolutionary Computation, 6:182–197, April 2002.

slide-125
SLIDE 125

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Nondominated Sorting Genetic Algorithm II (NSGA-II)*

pick an individual from a non-dominated pair via crowding distance

selects individuals that are far from the others in order to create a wider Pareto front * K. Deb, A. Pratap, S. Agarwal, and T. Meyarivan. A fast and elitist multiobjective genetic algorithm: 
 NSGA-II. IEEE Transactions on Evolutionary Computation, 6:182–197, April 2002.

slide-126
SLIDE 126

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Single-Point Crossover

1 1 1 1 1 1 1

slide-127
SLIDE 127

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Single-Point Crossover

1 1 1 1 1 1 1

slide-128
SLIDE 128

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Single-Point Crossover

1 1 1 1 1 1 1 1 1 1 1 1 1 1

slide-129
SLIDE 129

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Mutation

1 1 1

slide-130
SLIDE 130

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Mutation

1 1 1 1 1 1 1

slide-131
SLIDE 131

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Shin Yoo and Mark Harman. Pareto efficient multi-objective test case selection. In International 
 Symposium on Software Testing and Analysis (ISSTA’07), pages 140 – 150, London, United Kingdom, 
 July 2007. Association for Computer Machinery.

slide-132
SLIDE 132

CREST

Justyna Petke Search Based Software Engineering

Test Suite Minimisation

Yoo, Nilsson and Harman, FSE 2011

Speedup (x times) 5 10 15 20 25 30

NSGA2/JOMP1 NSGA2/JOMP2 NSGA2/JOMP4 NSGA2/GPU SPEA2/JOMP1 SPEA2/JOMP2 SPEA2/JOMP4 SPEA2/GPU TAEA/JOMP1 TAEA/JOMP2 TAEA/JOMP4 TAEA/GPU tcas totinfo flex gzip sed space−1 space−2 space−3 space−4 replace bash haifa

Yoo, Harman and Ur, EMSE 2013

regression test time reduced by between 33% and 82% while retaining fault detection capability improved performance up to 25 times using GPGPU

slide-133
SLIDE 133

CREST

Justyna Petke Search Based Software Engineering

Summary

In SBSE we apply search techniques to search large search spaces, guided by a fitness function that captures properties of the acceptable software artefacts we seek.

Search Based Optimisation Software Engineering

S B S E

slide-134
SLIDE 134

CREST

Justyna Petke Search Based Software Engineering

Exercises

slide-135
SLIDE 135

CREST

Justyna Petke Search Based Software Engineering

Overall Architecture

  • f SBSE Approach
slide-136
SLIDE 136

CREST

Justyna Petke Search Based Software Engineering

Release Planning

Repository

requirements and change requests

slide-137
SLIDE 137

CREST

Justyna Petke Search Based Software Engineering

Repository

Release 1 Release 2 Release 3 Product or Service

Release Planning

slide-138
SLIDE 138

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system What are the objectives ? customer requirements, customer importance, implementation cost time to market, frequency of use, risk and other

slide-139
SLIDE 139

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system Objectives: maximise customer satisfaction while minimising the cost what about

slide-140
SLIDE 140

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system How to measure customer satisfaction ? How to measure cost ? How to measure fitness? How to represent a solution ? Which search algorithm to choose ?

slide-141
SLIDE 141

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system Multi-objective fitness function: maximise customer satisfaction while minimising the cost what about

slide-142
SLIDE 142

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system Multi-objective fitness function: How to measure customer satisfaction ?while minimising the cost what about

slide-143
SLIDE 143

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system Multi-objective fitness function: assign weights to each customer and importance of each requirement to them

slide-144
SLIDE 144

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system Multi-objective fitness function: customer_satisfaction = sum(customer_value*(value of requirement to the customer) )

slide-145
SLIDE 145

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system Multi-objective fitness function: How to measure the cost ?while minimising the cost what about

slide-146
SLIDE 146

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system Multi-objective fitness function: assign weight to each requirement while minimising the cost what about

slide-147
SLIDE 147

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system Multi-objective fitness function: requirement_cost = sum (requirement_cost)while minimising the cost what about

slide-148
SLIDE 148

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system Multi-objective fitness function: maximise customer satisfaction while minimising the cost while minimising the cost what about

slide-149
SLIDE 149

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system Weighted-sum approach for fitness: fitness = w*customer_satisfaction + (1-w)*requirement_cost

slide-150
SLIDE 150

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system What about requirement dependencies ? customer requirements, customer importance, implementation cost

slide-151
SLIDE 151

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system What about requirement dependencies ? assign fitness 0 if dependencies broken requirements, customer importance, implementation cost

slide-152
SLIDE 152

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system What about requirement dependencies ? consider each requirement and all its prerequisites as a new single requirement

slide-153
SLIDE 153

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system How to represent a solution ? customer requirements, customer importance, implementation cost

slide-154
SLIDE 154

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Representation

1 1 1

r1 r2 r3 r4 r5 r6 appears in a solution

slide-155
SLIDE 155

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system Which search algorithm you could use ? customer requirements, customer importance, implementation cost

slide-156
SLIDE 156

CREST

Justyna Petke Search Based Software Engineering

Requirements Analysis

Problem: Select a set of software requirements for the release of the next version of a software system Which search algorithm you could use ? (multi-objective) genetic algorithm, hill climbing, random search, simulated annealing, simplex algorithm, greedy …

slide-157
SLIDE 157

CREST

Justyna Petke Search Based Software Engineering

Next Release Problem

* Yuanyuan Zhang, Mark Harman, and Afshin Mansouri. The multi-objective next release problem. 
 In GECCO 2007: Proceedings of the 9th annual conference on Genetic and evolutionary computation, pages 1129 – 1137, London, UK, July 2007. ACM Press. 


slide-158
SLIDE 158

CREST

Justyna Petke Search Based Software Engineering

Search Based Software Engineering Applications

slide-159
SLIDE 159

CREST

Justyna Petke Search Based Software Engineering

What is SBSE

Search Based Optimisation Software Engineering

S B S E

slide-160
SLIDE 160

CREST

Justyna Petke Search Based Software Engineering

Why SBSE ?

slide-161
SLIDE 161

CREST

Justyna Petke Search Based Software Engineering

Repository

Release 1 Release 2 Release 3 Product or Service

Release Planning

slide-162
SLIDE 162

CREST

Justyna Petke Search Based Software Engineering

Repository

Release 1 Release 2 Release 3 Product or Service

Can use linear programming …

slide-163
SLIDE 163

CREST

Justyna Petke Search Based Software Engineering

Items

Knapsack 1 Knapsack 2 Knapsack 3 Knapsacks

Knapsack Problem

slide-164
SLIDE 164

CREST

Justyna Petke Search Based Software Engineering

Items

Knapsack 1 Knapsack 2 Knapsack 3 Knapsacks

NP-hard Problem

slide-165
SLIDE 165

CREST

Justyna Petke Search Based Software Engineering

Items

Knapsack 1 Knapsack 2 Knapsack 3 Knapsacks

Release Planning using ILP

*A. Bagnall,

  • V. Rayward-Smith, I. Whittley

The next release problem

  • Inf. Softw. Technol., 43 (14) (2001), pp. 883–890
slide-166
SLIDE 166

CREST

Justyna Petke Search Based Software Engineering

Items

Knapsack 1 Knapsack 2 Knapsack 3 Knapsacks

Can use greedy …

slide-167
SLIDE 167

CREST

Justyna Petke Search Based Software Engineering

Items

Knapsack 1 Knapsack 2 Knapsack 3 Knapsacks

Heuristics can give you better solutions :)

slide-168
SLIDE 168

CREST

Justyna Petke Search Based Software Engineering

Items

Knapsack 1 Knapsack 2 Knapsack 3 Knapsacks

Heuristics can give you better solutions :) (see CIT)

slide-169
SLIDE 169

CREST

Justyna Petke Search Based Software Engineering

Why SBSE ?

slide-170
SLIDE 170

CREST

Justyna Petke Search Based Software Engineering

SBSE’s Industrial Applications and Tools

Joachim Wegener and Oliver Bühler. GECCO 2004 testing scenarios

slide-171
SLIDE 171

CREST

Justyna Petke Search Based Software Engineering

SBSE’s Industrial Applications and Tools

Wasif Afzal, Richard Torkar, Robert Feldt and Greger Wikstrand. SSBSE 2010 fault prediction

slide-172
SLIDE 172

CREST

Justyna Petke Search Based Software Engineering

SBSE’s Industrial Applications and Tools

Nikolai Tillmann, Jonathan de Halleux and Tao Xie. ASE 2014 test case generation

slide-173
SLIDE 173

CREST

Justyna Petke Search Based Software Engineering Combinatorial Interaction Testing Mutation Testing Regression Testing Code Clone Detection Software Fault Predication

CREST Research Projects

slide-174
SLIDE 174

CREST

Justyna Petke Search Based Software Engineering Search Based Software Engineering (SBSE) Combinatorial Interaction Testing Mutation Testing Regression Testing Code Clone Detection Software Fault Predication

CREST Research Projects

slide-175
SLIDE 175

CREST

Justyna Petke Search Based Software Engineering

Bug Fixing

GP GP

  • A. Arcuri and X.
  • Yao. A Novel

Co-evolutionary Approach to Automatic Software Bug Fixing. (CEC ’08)

The original program serves as an ideal oracle for the re-evolution of fragments of new code.

“ ”

slide-176
SLIDE 176

CREST

Justyna Petke Search Based Software Engineering

Migration

GP GP

  • W. B. Langdon and M. Harman

Evolving a CUDA kernel from an nVidia template (CEC'10)

GPU

slide-177
SLIDE 177

CREST

Justyna Petke Search Based Software Engineering

Migration

GP GP

  • W. B. Langdon and M. Harman

Evolving a CUDA kernel from an nVidia template (CEC'10)

__device__ int kernel978(const uch *g_idata, const int strstart1, const int strstart2) { int thid = 0; int pout = 0; int pin = 0 ; int offset = 0; int num_elements = 258; for (offset = 1 ; G_idata( strstart1+ pin ) == G_idata( strstart2+ pin ) ;offset ++ ) { if(!ok()) break; thid = G_idata( strstart2+ thid ) ; pin = offset ; } return pin ; }

Blue - fixed by template. Black - default Red - evolved Grey – evolved but no impact.

Code can be re-evolved from one environment to an entirely new environment and programming language.

“ ”

GPU

slide-178
SLIDE 178

CREST

Justyna Petke Search Based Software Engineering

Trading Functional & Non- Functional Requirements

  • D. R. White, J. Clark, J. Jacob, and S. Poulding.

Searching for resource-efficient programs: Low-power pseudorandom number generators (SEAL 2008)

slide-179
SLIDE 179

CREST

Justyna Petke Search Based Software Engineering

SBSE Public Tools

AUSTIN applied to real-world embedded automotive industry: Daimler, B&M Systemtechnik. Recommended for testing C. Kiran Lakhotia,Mark Harman,and Hamilton Gross. I&ST 2013

slide-180
SLIDE 180

CREST

Justyna Petke Search Based Software Engineering

SBSE Public Tools

EvoSuite automatically generates test cases for Java code. An excellent and highly recommended tool.

Gordon Fraser and Andrea Arcuri. ESEC/FSE 2011

slide-181
SLIDE 181

CREST

Justyna Petke Search Based Software Engineering

Yuanyuan Zhang

slide-182
SLIDE 182

CREST

Justyna Petke Search Based Software Engineering

Summary

In SBSE we apply search techniques to search large search spaces, guided by a fitness function that captures properties of the acceptable software artefacts we seek.

Search Based Optimisation Software Engineering

S B S E