Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks...

85
Introduction to SBSE (2/2) Shin Yoo CS454, Autumn 2018, School of Computing, KAIST

Transcript of Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks...

Page 1: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Introduction to SBSE (2/2)

Shin Yoo CS454, Autumn 2018, School of Computing, KAIST

Page 2: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

New Classroom

• E3-1 Room 1101,

• Starting from next Tuesday

Page 3: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Let’s start with terms.

Page 4: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples
Page 5: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples
Page 6: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples
Page 7: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Meta-heuristic

• Strategies that guide the search of the acceptable solution

• Approximate and usually non-deterministic

• Not problem specific

Page 8: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Meta-heuristic

• Strategies that guide the search of the acceptable solution

• Approximate and usually non-deterministic

• Not problem specific

• Smart trial and error

Page 9: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples
Page 10: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Let’s play Super Mario Bros.

Page 11: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Let’s play Super Mario Bros.

http://arxiv.org/pdf/1203.1895v3.pdf

Page 12: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Let’s play Super Mario Bros.

Page 13: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Player A

Page 14: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Player A• Read the game manual to see

which button does what.

Page 15: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Player A• Read the game manual to see

which button does what.

• Google the level map and get familiar with it.

Page 16: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Player A• Read the game manual to see

which button does what.

• Google the level map and get familiar with it.

• Carefully, very carefully, plan when to press each button, for how long.

Page 17: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Player A• Read the game manual to see

which button does what.

• Google the level map and get familiar with it.

• Carefully, very carefully, plan when to press each button, for how long.

• Grab the controller and execute the plan.

Page 18: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Player B

Page 19: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Player B

• Grab the controller.

Page 20: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Player B

• Grab the controller.

• Play.

Page 21: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Player B

• Grab the controller.

• Play.

• Die.

Page 22: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Player B

• Grab the controller.

• Play.

• Die.

• Repeat until level is cleared.

Page 23: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Player B

• Grab the controller.

• Play.

• Die.

• Repeat until level is cleared.

Intelligence lies in how differently you die next time.

Page 24: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Mario analogy goes a long way

Page 25: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Mario analogy goes a long way

• You make small changes to your last attempt (“okay, I will press A slightly later this time”).

Page 26: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Mario analogy goes a long way

• You make small changes to your last attempt (“okay, I will press A slightly later this time”).

• You combine different bits of solutions (“Okay, jump over here, but then later do not jump over there”).

Page 27: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Mario analogy goes a long way

• You make small changes to your last attempt (“okay, I will press A slightly later this time”).

• You combine different bits of solutions (“Okay, jump over here, but then later do not jump over there”).

• You accidentally discover new parts of the map (“Oops, how did I find this secret passage?”)

Page 28: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Eight Queens Problem

Place 8 queens on a chessboard so that no pair attacks each other.

Page 29: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Eight Queens Problem

Page 30: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Eight Queens Problem

Page 31: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Eight Queens Problem

Perfect solution: score 0

Page 32: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Eight Queens Problem

Two attacks: score -2

Page 33: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Eight Queens Problem

Two attacks: score -2

Page 34: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Eight Queens Problem

Two attacks: score -2

Page 35: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Eight Queens Problem

Page 36: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Eight Queens Problem

Three attacks: score -3

Page 37: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Eight Queens Problem

Three attacks: score -3

Page 38: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Eight Queens Problem

Three attacks: score -3

Page 39: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Two Approaches

Page 40: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Two Approaches

Build an algorithmthat produces a solution to the problem by placing one piece at a time

Page 41: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Two Approaches

Build an algorithmthat produces a solution to the problem by placing one piece at a time

Build an algorithmthat compares two solutions to the problem; try different solutions, keep the better one, until you solve the problem

Page 42: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Does it scale?

Page 43: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

44 Queens Problem

Place 44 Queens on the board with no attack.

Page 44: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

1012 Queens Problem

Place 1012 Queens on the board with no attack.

Page 45: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Trial and Error• Abundance of computational resources means

many domains are adopting (knowingly or not) a similar approach.

• Corpus-based NLP

• Go (the only competitive AI players are based on Monte-Carlo Method)

• Many application of machine learning

Page 46: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Key Ingredients• What are we going to try this time? (representation)

• How is it different from what we tried before? (operators)

• How well did we do this time? (fitness/objective function)

• Minor (but critical) ingredients: constraints

Page 47: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

8 Queens Problem

• Representation: 8 by 8 matrix

• Operators: generate one valid board position from the current position, following the rule about Queen’s movement

• Fitness function: number of attacks (to be minimised)

Page 48: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

8 Queens Problem

• Representation: 8 by 8 matrix

• Operators: generate one valid board position from the current position, following the rule about Queen’s movement

• Fitness function: number of attacks (to be minimised)

Page 49: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Super Mario Bros.• Representation: a list of (button, start_time, end_time)

• Operators: change button type in one tuple, increase/decrease start_time or end_time

• Fitness function: the distance you travelled without dying

Page 50: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Super Mario Bros.• Representation: a list of (button, start_time, end_time)

• Operators: change button type in one tuple, increase/decrease start_time or end_time

• Fitness function: the distance you travelled without dying

Page 51: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Universal Viewpoint• There are many algorithms in computational

intelligence; you do need to learn individual algorithms in detail.

• However, I also want to communicate a frame of thinking, not only individual algorithms.

• The tuple of (representation, operators, fitness function) can be a universal platform to understand different classes of algorithms.

• We will revisit individual algorithms, using this tuples.

Page 52: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Design dictates solution

Page 53: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Design dictates solution• Incorrect representation: what happens if we use (button, pressed_time) instead?

Page 54: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Design dictates solution• Incorrect representation: what happens if we use (button, pressed_time) instead?

• Using wrong operators: what happens if we decrease/increase start_time and end_time by 5 seconds?

Page 55: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Design dictates solution• Incorrect representation: what happens if we use (button, pressed_time) instead?

• Using wrong operators: what happens if we decrease/increase start_time and end_time by 5 seconds?

• Missing constraints: what happens if we swap the order of two tuples?

Page 56: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Design dictates solution• Incorrect representation: what happens if we use (button, pressed_time) instead?

• Using wrong operators: what happens if we decrease/increase start_time and end_time by 5 seconds?

• Missing constraints: what happens if we swap the order of two tuples?

• Measuring the wrong fitness: what happens if we use the time elapsed until death? Or the final score?

Page 57: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Exploitation vs. Exploration

• Exploitation: if a candidate solution looks promising, optimisation should focus on that particular direction. However,

• Exploration: unexplored solution space may contain something *much better*.

• How to balance these two is critical to all learning/optimisation algorithms.

Page 58: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Machines are Dumb and Lazy

• Like human, they will do the minimum work that passes your criteria, i.e. design of the optimisation problem.

• Not because of their work ethic, but because of the fact that, usually, minimum work is the easiest to find solution.

Page 59: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Case Study: GenProg• GenProg uses stochastic optimisation to modify

existing faulty software code, until it passes all tests.

• We can only tell it to try until it passes all tests, not until the program is correct.

Anecdotes borrowed from Wes Weimer’s SSBSE 2013 Keynote: https://www.cs.virginia.edu/~weimer/p/weimer-ssbse2013.pdf

Page 60: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Things GenProg Did…

Page 61: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Things GenProg Did…• nullhttpd: test case for POST function failed;

GenProg removed the entire functionality.

Page 62: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Things GenProg Did…• nullhttpd: test case for POST function failed;

GenProg removed the entire functionality.

• sort: test required output to be sorted; GenProg’s fix was to always output an empty set.

Page 63: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Things GenProg Did…• nullhttpd: test case for POST function failed;

GenProg removed the entire functionality.

• sort: test required output to be sorted; GenProg’s fix was to always output an empty set.

• Tests compared output.txt to correct_output.txt; GenProg deleted correct_output.txt and printed nothing.

Page 64: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Current State of the Art• Low hanging fruits almost gone: “I applied algorithm X to problem Y” no

longer counts.

• Metric-based optimisation (where fitness equals an existing SE metric) is starting to be criticised. Compare the following two papers:

• M. Harman and J. Clark. Metrics are fitness functions too. In 10th International Software Metrics Symposium (METRICS 2004), pages 58–69, Los Alamitos, California, USA, Sept. 2004. IEEE Computer Society Press.

• C. Simons, J. Singer, and D. R. White. Search-based refactoring: Metrics are not enough. In M. Barros and Y. Labiche, editors, Search-Based Software Engineering, volume 9275 of Lecture Notes in Computer Science, pages 47–61. Springer International Publishing, 2015.

Page 65: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

How to do better?

• Try to learn from human engineers more.

• Eventually, solutions from SBSE should be adopted because humans accept it, not because the fitness value is above an arbitrary cut-off point X.

• Turing-test as fitness function!

Page 66: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Expected Learning Outcome

• Understand basic metaheuristic algorithms; learn how to implement and adapt one to a given problem.

• Embrace metaheuristic optimisation as a valid tool for software engineers.

• Gain knowledge of the literature; learn case studies for various software development lifecycle stages.

Page 67: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Problem Domains

Page 68: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Structural Testing• Take CS453 Automated Software Testing:)

• Intuitively: define the input constraints required to achieve structural coverage; solve the constraints using optimisation.

• Symbolic execution + constraints solver

• Dynamic analysis + metaheuristic optimisation

• Either way, huge advances in the last decade.

• Clearly defined fitness function, industry demand (at least on achieving coverage)

Page 69: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Structural Testing• Take CS453 Automated Software Testing:)

• Intuitively: define the input constraints required to achieve structural coverage; solve the constraints using optimisation.

• Symbolic execution + constraints solver

• Dynamic analysis + metaheuristic optimisation

• Either way, huge advances in the last decade.

• Clearly defined fitness function, industry demand (at least on achieving coverage)

IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, VOL. SE-2, NO. 3, SEPTEMBER 1976

Automatic Generation of Floating-Point Test DataWEBB MILLER AND DAVID L. SPOONER

Abstract-For numerical programs, or more generally for programswith floating-point data, it may be that large savings of time andstorage are made possible by using numerical maximization methodsinstead of symbolic execution to generate test data. Two examples,a matrix factorization subroutine and a sorting method, illustrate thetypes of data generation problems that can be successfully treatedwith such maximization techniques.

Index Terns-Automatic test data generation, branching, data con-straints, execution path, software evaluation systems.

INTRODUCTIONR ESEARCH in program evaluation and verification has

only rarely (e.g., [1]) begun with the explicit require-ment that the program deal with real numbers as op-

posed to integers. This may be an oversight since there aretheoretical results which suggest the desirability of this as-sumption. Specifically, a general procedure of Tarski [2]shows that certain properties, undecidable (in the technicalsense) for "integer" programs, are decidable for "numerical"programs. Examples of this phenomenon arise when one asksif there exists a set of data driving execution of a certain kindof program down a given path.Moreover, there is practical evidence supporting the case for

automatic verification of special properties of numerical pro-grams. Proving "numerical correctness," i.e., verifying a satis-factory level of insensitivity to rounding error, is sometimesmuch easier than proving that the program performs properlyin exact arithmetic. The ideal and contaminated results canoften be meaningfully compared with only minimal under-standing of the program. Simple, portable, general-purposesoftware [31, [4] can easily provide answers which haveeluded specialists in roundoff analysis. This work [3], [4]also shows the possible advantage of using, e.g., numericalmaximization methods to do the verification, avoiding thealternative of using, e.g., computer symbolic manipulation(5], [6].This paper considers automatic test data generation, a prob-

lem which arises in such fields as automatic software evalua-tion systems [7] and in automatic roundoff analysis [4] . Ourcontention is that automatic test data generation is sometimesbest formulated and solved as a numerical maximization prob-lem. The reader should be warned that our scheme is only

Manuscript received September 9, 1975; revised February 23, 1976.This work was supported in part by the National Science Foundationunder Grant GJ-42968.W. Miller is with the Department of Computer Science, Pennsylvania

State University, University Park, PA 16802.D. L. Spooner was with the Department of Computer Science, Penn-

sylvania State University, University Park, PA 16802. He is now withthe Department of Computer Science, Cornell University, Ithaca, NY.

"heuristic" in that it is not guaranteed to produce a set of testdata executing a given path whenever such data exist. (Onthe other hand, we know of no guaranteed data generationscheme whose execution time does not, in the worst case,grow at least exponentially with the length of the executionpath.)

NUMERICAL MAXIMIZATION METHODS FORGENERATING TEST DATA

Given the problem of generating floating-point test data ourapproach begins by fixing all integer parameters of the givenprogram (e.g., the dimensions of the data in a matrix programor the number of iterations in an iterative method) so that theonly unresolved decisions controlling program flow are com-parisons involving real values. Then, as will be seen, an execu-tion path takes the form of a straight-line program of float-ing-point assignment statements interspersed with "pathconstraints" of the form ci = 0, ci > 0, or ci >0. Each ci is adata-dependent real value possibly defined in terms of pre-viously computed results. For instance, a path which takesthe true branch of a test "IF(X.NE.Y)" has a constraint c > 0,where, e.g., C = ABS(X - Y) or c = (X - Y)2. (We will not discussin any detail the philosophical and practical difficulties asso-ciated with equality tests when computation is contaminatedby rounding error. Nor will we consider the problem of (auto-matically or manually) generating the straight-line program;we have nothing new to add on this subject.)The situation is clarified by an example. Consider the fol-

lowing subprogram of Moler [8] .

SUBROUTINE DECOMP(N,NDIM,A,IP)REAL A(NDIM,NDIM) ,TINTEGER IP (NDIM)

cC MATRIX TRIANGULARIZATION BY GAUSSIAN ELIMINATION.C INPUT..C N = ORDER OF MATRIX.C NDIM = DECLARED DIMENSION OF ARRAY A.C A = MATRIX TO BE TRIANGULARIZED.C OUTPUT..C A(I,J), I.LE.J = UPPER TRIANGULAR FACTOR, U.C A(I,J), I.GT.J = MULTIPLIERS = LOWER TRIANGULAR

FACTOR, I-L.IC IP(K), K.LT.N = INDEX OF K-TH PIVOT ROW.

IP(N) = (-1)**(NUMBER OF INTERCHANGES) OR 0.C USE 'SOLVE' TO OBTAIN SOLUTION OF LINEAR SYSTEM.C DETERM(A) = IP(N)*A(1, 1)*A(2 ,2)* *A(N,N).C IF IP(N)=o, A IS SINGULAR, SOLVE WILL DIVIDE BY ZERO.C INTERCHANGES FINISHED IN U, ONLY PARTLY IN L.

223

Page 70: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Structural Testing• Take CS453 Automated Software Testing:)

• Intuitively: define the input constraints required to achieve structural coverage; solve the constraints using optimisation.

• Symbolic execution + constraints solver

• Dynamic analysis + metaheuristic optimisation

• Either way, huge advances in the last decade.

• Clearly defined fitness function, industry demand (at least on achieving coverage)

IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, VOL. SE-2, NO. 3, SEPTEMBER 1976

Automatic Generation of Floating-Point Test DataWEBB MILLER AND DAVID L. SPOONER

Abstract-For numerical programs, or more generally for programswith floating-point data, it may be that large savings of time andstorage are made possible by using numerical maximization methodsinstead of symbolic execution to generate test data. Two examples,a matrix factorization subroutine and a sorting method, illustrate thetypes of data generation problems that can be successfully treatedwith such maximization techniques.

Index Terns-Automatic test data generation, branching, data con-straints, execution path, software evaluation systems.

INTRODUCTIONR ESEARCH in program evaluation and verification has

only rarely (e.g., [1]) begun with the explicit require-ment that the program deal with real numbers as op-

posed to integers. This may be an oversight since there aretheoretical results which suggest the desirability of this as-sumption. Specifically, a general procedure of Tarski [2]shows that certain properties, undecidable (in the technicalsense) for "integer" programs, are decidable for "numerical"programs. Examples of this phenomenon arise when one asksif there exists a set of data driving execution of a certain kindof program down a given path.Moreover, there is practical evidence supporting the case for

automatic verification of special properties of numerical pro-grams. Proving "numerical correctness," i.e., verifying a satis-factory level of insensitivity to rounding error, is sometimesmuch easier than proving that the program performs properlyin exact arithmetic. The ideal and contaminated results canoften be meaningfully compared with only minimal under-standing of the program. Simple, portable, general-purposesoftware [31, [4] can easily provide answers which haveeluded specialists in roundoff analysis. This work [3], [4]also shows the possible advantage of using, e.g., numericalmaximization methods to do the verification, avoiding thealternative of using, e.g., computer symbolic manipulation(5], [6].This paper considers automatic test data generation, a prob-

lem which arises in such fields as automatic software evalua-tion systems [7] and in automatic roundoff analysis [4] . Ourcontention is that automatic test data generation is sometimesbest formulated and solved as a numerical maximization prob-lem. The reader should be warned that our scheme is only

Manuscript received September 9, 1975; revised February 23, 1976.This work was supported in part by the National Science Foundationunder Grant GJ-42968.W. Miller is with the Department of Computer Science, Pennsylvania

State University, University Park, PA 16802.D. L. Spooner was with the Department of Computer Science, Penn-

sylvania State University, University Park, PA 16802. He is now withthe Department of Computer Science, Cornell University, Ithaca, NY.

"heuristic" in that it is not guaranteed to produce a set of testdata executing a given path whenever such data exist. (Onthe other hand, we know of no guaranteed data generationscheme whose execution time does not, in the worst case,grow at least exponentially with the length of the executionpath.)

NUMERICAL MAXIMIZATION METHODS FORGENERATING TEST DATA

Given the problem of generating floating-point test data ourapproach begins by fixing all integer parameters of the givenprogram (e.g., the dimensions of the data in a matrix programor the number of iterations in an iterative method) so that theonly unresolved decisions controlling program flow are com-parisons involving real values. Then, as will be seen, an execu-tion path takes the form of a straight-line program of float-ing-point assignment statements interspersed with "pathconstraints" of the form ci = 0, ci > 0, or ci >0. Each ci is adata-dependent real value possibly defined in terms of pre-viously computed results. For instance, a path which takesthe true branch of a test "IF(X.NE.Y)" has a constraint c > 0,where, e.g., C = ABS(X - Y) or c = (X - Y)2. (We will not discussin any detail the philosophical and practical difficulties asso-ciated with equality tests when computation is contaminatedby rounding error. Nor will we consider the problem of (auto-matically or manually) generating the straight-line program;we have nothing new to add on this subject.)The situation is clarified by an example. Consider the fol-

lowing subprogram of Moler [8] .

SUBROUTINE DECOMP(N,NDIM,A,IP)REAL A(NDIM,NDIM) ,TINTEGER IP (NDIM)

cC MATRIX TRIANGULARIZATION BY GAUSSIAN ELIMINATION.C INPUT..C N = ORDER OF MATRIX.C NDIM = DECLARED DIMENSION OF ARRAY A.C A = MATRIX TO BE TRIANGULARIZED.C OUTPUT..C A(I,J), I.LE.J = UPPER TRIANGULAR FACTOR, U.C A(I,J), I.GT.J = MULTIPLIERS = LOWER TRIANGULAR

FACTOR, I-L.IC IP(K), K.LT.N = INDEX OF K-TH PIVOT ROW.

IP(N) = (-1)**(NUMBER OF INTERCHANGES) OR 0.C USE 'SOLVE' TO OBTAIN SOLUTION OF LINEAR SYSTEM.C DETERM(A) = IP(N)*A(1, 1)*A(2 ,2)* *A(N,N).C IF IP(N)=o, A IS SINGULAR, SOLVE WILL DIVIDE BY ZERO.C INTERCHANGES FINISHED IN U, ONLY PARTLY IN L.

223

IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, SEPTEMBER 1976

between four and seven seconds of CPU time on our IBM370/168, at ten cents per second. However, this is in someways pessimistic since we neither took the trouble nor had theappropriate software to explicitly generate the straight-lineprogram. Instead, we essentially executed the Fortran pro-gram each of the, e.g., 1147 times to determine the constraintsand the assignment statements along the given path.)

ACKNOWLEDGMENTThe authors wish to thank the referee who pointed out ref-

erence [9] and made other helpful suggestions. The final formof our Heapsort example was prompted by J. King's informalconjecture that our methods are not much more efficient thanrandom generation of test data until a set is found whichcauses the given path to be executed.

REFERENCES[1] T. Hull et al., "The correctness of numerical algorithms," in Proc.

ACM Conf. Proving Assertions about Programs, New MexicoState University, Jan. 6-7, 1972.

[2] A. Tarski, A Decision Method for Elementary Algebra and Geom-etry. Berkeley, CA: University of California Press, 1951.

[3] W. Miller, "Software for roundoff analysis," Ass. Comput. Mach.Trans. Math. Software, vol. 1, pp. 108-128, 1975.

[4] W. Miller and D. Spooner, "Software for roundoff analysis, II,"be published in Ass. Comput. Mach. Trans. Math. Software.

[5] W. Kahan, "One numerical analyst's experience with one symbolmanipulator," SIAM Rev., vol. 16, p. 129, 1974.

[6] D. Stoutemyer, "Automatic error analysis using computer alge-braic manipulation," submitted for publication.

[7] C. Ramamoorthy and S.-B. Ho, "Testing large software with au-tomated software evaluation systems," IEEE Trans. SoftwareEng., vol. 1, pp. 46-58, 1975.

[8] C. Moler, "Algorithm 423, linear equation solver," Commun. Ass.Comput. Mach., vol. 15, p. 274, Apr. 1972.

[9] R. Boyer, B. Elspas, and K. Levitt, "SELECT-A formal systemfor testing and debugging programs by symbolic execution," inProc. 1975 Int. Conf. Reliable Software; also SIGPLANNotices,vol. 10, pp. 234-245, June 1975.

[101 L. Clarke, "A system to generate test data and symbolically ex-ecute programs," Dept. Comp. Sci., Univ. of Colorado, Rep. CU-CS-060-75, Feb. 1975.

[11] J. King, "Symbolic execution and program testing," submittedfor publication.

[12] P. Gill and W. Murray, Ed., Numerical Methods for Constrain tedOptimization. New York: Academic, 1974.

[13] W. Swann, "Direct search methods," in Numerical Methods forUnconstrained Optimization, W. Murray, Ed. New York: Aca-demic, 1972, pp. 13-28.

[14] -, Constrained optimization by direct search," in NumericalMethods for Unconstrained Optimization, W. Murray, Ed. NewYork: Academic, 1972, pp. 191-217.

[15] A. Aho, J. Hopcroft, and J. Ullman, The Design and Analysis ofComputer Algorithms. Reading, MA: Addison-Wesley, 1974.

Webb Miller was born in Walla Walla, WA, onNovember 30, 1943. He received the B.S. De-gree in mathematics from Whitman College,Walla Walla, WA, in 1966 and the Ph.D. degreein mathematics from the University of Washing-ton, Seattle, in 1969.He is currently an Associate Professor in the

Department of Computer Science, PennsylvaniaState University, State College, and is trying tofind time to pursue his interests in rounding er-ror analysis and computational complexity.

David L. Spooner was born in State College,PA, on April 13, 1953. He received the B.S. de-gree in computer science from PennsylvaniaState University, University Park, PA, in 1975.He is currently a graduate student at Cornell

University, Ithaca, NY. His major interests arein the areas of programming languages and com-piler design.Mr. Spooner is a member of the Association

for Computing Machinery, Phi Kappa Phi, andUpsilon Pi Epsilon.

226

Page 71: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Structural Testing• Take CS453 Automated Software Testing:)

• Intuitively: define the input constraints required to achieve structural coverage; solve the constraints using optimisation.

• Symbolic execution + constraints solver

• Dynamic analysis + metaheuristic optimisation

• Either way, huge advances in the last decade.

• Clearly defined fitness function, industry demand (at least on achieving coverage)

IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, VOL. SE-2, NO. 3, SEPTEMBER 1976

Automatic Generation of Floating-Point Test DataWEBB MILLER AND DAVID L. SPOONER

Abstract-For numerical programs, or more generally for programswith floating-point data, it may be that large savings of time andstorage are made possible by using numerical maximization methodsinstead of symbolic execution to generate test data. Two examples,a matrix factorization subroutine and a sorting method, illustrate thetypes of data generation problems that can be successfully treatedwith such maximization techniques.

Index Terns-Automatic test data generation, branching, data con-straints, execution path, software evaluation systems.

INTRODUCTIONR ESEARCH in program evaluation and verification has

only rarely (e.g., [1]) begun with the explicit require-ment that the program deal with real numbers as op-

posed to integers. This may be an oversight since there aretheoretical results which suggest the desirability of this as-sumption. Specifically, a general procedure of Tarski [2]shows that certain properties, undecidable (in the technicalsense) for "integer" programs, are decidable for "numerical"programs. Examples of this phenomenon arise when one asksif there exists a set of data driving execution of a certain kindof program down a given path.Moreover, there is practical evidence supporting the case for

automatic verification of special properties of numerical pro-grams. Proving "numerical correctness," i.e., verifying a satis-factory level of insensitivity to rounding error, is sometimesmuch easier than proving that the program performs properlyin exact arithmetic. The ideal and contaminated results canoften be meaningfully compared with only minimal under-standing of the program. Simple, portable, general-purposesoftware [31, [4] can easily provide answers which haveeluded specialists in roundoff analysis. This work [3], [4]also shows the possible advantage of using, e.g., numericalmaximization methods to do the verification, avoiding thealternative of using, e.g., computer symbolic manipulation(5], [6].This paper considers automatic test data generation, a prob-

lem which arises in such fields as automatic software evalua-tion systems [7] and in automatic roundoff analysis [4] . Ourcontention is that automatic test data generation is sometimesbest formulated and solved as a numerical maximization prob-lem. The reader should be warned that our scheme is only

Manuscript received September 9, 1975; revised February 23, 1976.This work was supported in part by the National Science Foundationunder Grant GJ-42968.W. Miller is with the Department of Computer Science, Pennsylvania

State University, University Park, PA 16802.D. L. Spooner was with the Department of Computer Science, Penn-

sylvania State University, University Park, PA 16802. He is now withthe Department of Computer Science, Cornell University, Ithaca, NY.

"heuristic" in that it is not guaranteed to produce a set of testdata executing a given path whenever such data exist. (Onthe other hand, we know of no guaranteed data generationscheme whose execution time does not, in the worst case,grow at least exponentially with the length of the executionpath.)

NUMERICAL MAXIMIZATION METHODS FORGENERATING TEST DATA

Given the problem of generating floating-point test data ourapproach begins by fixing all integer parameters of the givenprogram (e.g., the dimensions of the data in a matrix programor the number of iterations in an iterative method) so that theonly unresolved decisions controlling program flow are com-parisons involving real values. Then, as will be seen, an execu-tion path takes the form of a straight-line program of float-ing-point assignment statements interspersed with "pathconstraints" of the form ci = 0, ci > 0, or ci >0. Each ci is adata-dependent real value possibly defined in terms of pre-viously computed results. For instance, a path which takesthe true branch of a test "IF(X.NE.Y)" has a constraint c > 0,where, e.g., C = ABS(X - Y) or c = (X - Y)2. (We will not discussin any detail the philosophical and practical difficulties asso-ciated with equality tests when computation is contaminatedby rounding error. Nor will we consider the problem of (auto-matically or manually) generating the straight-line program;we have nothing new to add on this subject.)The situation is clarified by an example. Consider the fol-

lowing subprogram of Moler [8] .

SUBROUTINE DECOMP(N,NDIM,A,IP)REAL A(NDIM,NDIM) ,TINTEGER IP (NDIM)

cC MATRIX TRIANGULARIZATION BY GAUSSIAN ELIMINATION.C INPUT..C N = ORDER OF MATRIX.C NDIM = DECLARED DIMENSION OF ARRAY A.C A = MATRIX TO BE TRIANGULARIZED.C OUTPUT..C A(I,J), I.LE.J = UPPER TRIANGULAR FACTOR, U.C A(I,J), I.GT.J = MULTIPLIERS = LOWER TRIANGULAR

FACTOR, I-L.IC IP(K), K.LT.N = INDEX OF K-TH PIVOT ROW.

IP(N) = (-1)**(NUMBER OF INTERCHANGES) OR 0.C USE 'SOLVE' TO OBTAIN SOLUTION OF LINEAR SYSTEM.C DETERM(A) = IP(N)*A(1, 1)*A(2 ,2)* *A(N,N).C IF IP(N)=o, A IS SINGULAR, SOLVE WILL DIVIDE BY ZERO.C INTERCHANGES FINISHED IN U, ONLY PARTLY IN L.

223

IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, SEPTEMBER 1976

between four and seven seconds of CPU time on our IBM370/168, at ten cents per second. However, this is in someways pessimistic since we neither took the trouble nor had theappropriate software to explicitly generate the straight-lineprogram. Instead, we essentially executed the Fortran pro-gram each of the, e.g., 1147 times to determine the constraintsand the assignment statements along the given path.)

ACKNOWLEDGMENTThe authors wish to thank the referee who pointed out ref-

erence [9] and made other helpful suggestions. The final formof our Heapsort example was prompted by J. King's informalconjecture that our methods are not much more efficient thanrandom generation of test data until a set is found whichcauses the given path to be executed.

REFERENCES[1] T. Hull et al., "The correctness of numerical algorithms," in Proc.

ACM Conf. Proving Assertions about Programs, New MexicoState University, Jan. 6-7, 1972.

[2] A. Tarski, A Decision Method for Elementary Algebra and Geom-etry. Berkeley, CA: University of California Press, 1951.

[3] W. Miller, "Software for roundoff analysis," Ass. Comput. Mach.Trans. Math. Software, vol. 1, pp. 108-128, 1975.

[4] W. Miller and D. Spooner, "Software for roundoff analysis, II,"be published in Ass. Comput. Mach. Trans. Math. Software.

[5] W. Kahan, "One numerical analyst's experience with one symbolmanipulator," SIAM Rev., vol. 16, p. 129, 1974.

[6] D. Stoutemyer, "Automatic error analysis using computer alge-braic manipulation," submitted for publication.

[7] C. Ramamoorthy and S.-B. Ho, "Testing large software with au-tomated software evaluation systems," IEEE Trans. SoftwareEng., vol. 1, pp. 46-58, 1975.

[8] C. Moler, "Algorithm 423, linear equation solver," Commun. Ass.Comput. Mach., vol. 15, p. 274, Apr. 1972.

[9] R. Boyer, B. Elspas, and K. Levitt, "SELECT-A formal systemfor testing and debugging programs by symbolic execution," inProc. 1975 Int. Conf. Reliable Software; also SIGPLANNotices,vol. 10, pp. 234-245, June 1975.

[101 L. Clarke, "A system to generate test data and symbolically ex-ecute programs," Dept. Comp. Sci., Univ. of Colorado, Rep. CU-CS-060-75, Feb. 1975.

[11] J. King, "Symbolic execution and program testing," submittedfor publication.

[12] P. Gill and W. Murray, Ed., Numerical Methods for Constrain tedOptimization. New York: Academic, 1974.

[13] W. Swann, "Direct search methods," in Numerical Methods forUnconstrained Optimization, W. Murray, Ed. New York: Aca-demic, 1972, pp. 13-28.

[14] -, Constrained optimization by direct search," in NumericalMethods for Unconstrained Optimization, W. Murray, Ed. NewYork: Academic, 1972, pp. 191-217.

[15] A. Aho, J. Hopcroft, and J. Ullman, The Design and Analysis ofComputer Algorithms. Reading, MA: Addison-Wesley, 1974.

Webb Miller was born in Walla Walla, WA, onNovember 30, 1943. He received the B.S. De-gree in mathematics from Whitman College,Walla Walla, WA, in 1966 and the Ph.D. degreein mathematics from the University of Washing-ton, Seattle, in 1969.He is currently an Associate Professor in the

Department of Computer Science, PennsylvaniaState University, State College, and is trying tofind time to pursue his interests in rounding er-ror analysis and computational complexity.

David L. Spooner was born in State College,PA, on April 13, 1953. He received the B.S. de-gree in computer science from PennsylvaniaState University, University Park, PA, in 1975.He is currently a graduate student at Cornell

University, Ithaca, NY. His major interests arein the areas of programming languages and com-piler design.Mr. Spooner is a member of the Association

for Computing Machinery, Phi Kappa Phi, andUpsilon Pi Epsilon.

226

IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, SEPTEMBER 1976

between four and seven seconds of CPU time on our IBM370/168, at ten cents per second. However, this is in someways pessimistic since we neither took the trouble nor had theappropriate software to explicitly generate the straight-lineprogram. Instead, we essentially executed the Fortran pro-gram each of the, e.g., 1147 times to determine the constraintsand the assignment statements along the given path.)

ACKNOWLEDGMENTThe authors wish to thank the referee who pointed out ref-

erence [9] and made other helpful suggestions. The final formof our Heapsort example was prompted by J. King's informalconjecture that our methods are not much more efficient thanrandom generation of test data until a set is found whichcauses the given path to be executed.

REFERENCES[1] T. Hull et al., "The correctness of numerical algorithms," in Proc.

ACM Conf. Proving Assertions about Programs, New MexicoState University, Jan. 6-7, 1972.

[2] A. Tarski, A Decision Method for Elementary Algebra and Geom-etry. Berkeley, CA: University of California Press, 1951.

[3] W. Miller, "Software for roundoff analysis," Ass. Comput. Mach.Trans. Math. Software, vol. 1, pp. 108-128, 1975.

[4] W. Miller and D. Spooner, "Software for roundoff analysis, II,"be published in Ass. Comput. Mach. Trans. Math. Software.

[5] W. Kahan, "One numerical analyst's experience with one symbolmanipulator," SIAM Rev., vol. 16, p. 129, 1974.

[6] D. Stoutemyer, "Automatic error analysis using computer alge-braic manipulation," submitted for publication.

[7] C. Ramamoorthy and S.-B. Ho, "Testing large software with au-tomated software evaluation systems," IEEE Trans. SoftwareEng., vol. 1, pp. 46-58, 1975.

[8] C. Moler, "Algorithm 423, linear equation solver," Commun. Ass.Comput. Mach., vol. 15, p. 274, Apr. 1972.

[9] R. Boyer, B. Elspas, and K. Levitt, "SELECT-A formal systemfor testing and debugging programs by symbolic execution," inProc. 1975 Int. Conf. Reliable Software; also SIGPLANNotices,vol. 10, pp. 234-245, June 1975.

[101 L. Clarke, "A system to generate test data and symbolically ex-ecute programs," Dept. Comp. Sci., Univ. of Colorado, Rep. CU-CS-060-75, Feb. 1975.

[11] J. King, "Symbolic execution and program testing," submittedfor publication.

[12] P. Gill and W. Murray, Ed., Numerical Methods for Constrain tedOptimization. New York: Academic, 1974.

[13] W. Swann, "Direct search methods," in Numerical Methods forUnconstrained Optimization, W. Murray, Ed. New York: Aca-demic, 1972, pp. 13-28.

[14] -, Constrained optimization by direct search," in NumericalMethods for Unconstrained Optimization, W. Murray, Ed. NewYork: Academic, 1972, pp. 191-217.

[15] A. Aho, J. Hopcroft, and J. Ullman, The Design and Analysis ofComputer Algorithms. Reading, MA: Addison-Wesley, 1974.

Webb Miller was born in Walla Walla, WA, onNovember 30, 1943. He received the B.S. De-gree in mathematics from Whitman College,Walla Walla, WA, in 1966 and the Ph.D. degreein mathematics from the University of Washing-ton, Seattle, in 1969.He is currently an Associate Professor in the

Department of Computer Science, PennsylvaniaState University, State College, and is trying tofind time to pursue his interests in rounding er-ror analysis and computational complexity.

David L. Spooner was born in State College,PA, on April 13, 1953. He received the B.S. de-gree in computer science from PennsylvaniaState University, University Park, PA, in 1975.He is currently a graduate student at Cornell

University, Ithaca, NY. His major interests arein the areas of programming languages and com-piler design.Mr. Spooner is a member of the Association

for Computing Machinery, Phi Kappa Phi, andUpsilon Pi Epsilon.

226

Page 72: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Oracle Problem

Page 73: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Oracle Problem• Coverage is not enough: “was the last execution correct?”

Page 74: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Oracle Problem• Coverage is not enough: “was the last execution correct?”

• Test oracle tells you whether the observed execution was correct or not

Page 75: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Oracle Problem• Coverage is not enough: “was the last execution correct?”

• Test oracle tells you whether the observed execution was correct or not

• Formal specification can serve as one; manual inspection by human can serve as one. But how do we automatically generate oracles?

Page 76: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Oracle Problem• Coverage is not enough: “was the last execution correct?”

• Test oracle tells you whether the observed execution was correct or not

• Formal specification can serve as one; manual inspection by human can serve as one. But how do we automatically generate oracles?

• We want to test the code; we automatically generate test from the code; we want to check whether the test passed; we automatically generate test oracle from the co… wait a minute!

Page 77: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Oracle Problem• Coverage is not enough: “was the last execution correct?”

• Test oracle tells you whether the observed execution was correct or not

• Formal specification can serve as one; manual inspection by human can serve as one. But how do we automatically generate oracles?

• We want to test the code; we automatically generate test from the code; we want to check whether the test passed; we automatically generate test oracle from the co… wait a minute!

• This is a very hard problem; one which the state of the art does not know how to solve.

Page 78: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Testing non-functional properties

• Worst-Case Execution Time Analysis: strictly necessary for certain embedded systems (e.g. airbag controller), very hard to do statically; genetic algorithm has been very successful.

• J. Wegener and M. Grochtmann. Verifying timing constraints of real-time systems by means of evolutionary testing. Real-Time Systems, 15(3):275 – 298, 1998.

Page 79: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Requirements Engineering• Next Release Problem: given cost and benefit

(expected revenue) for each features, what is the best subset of features to be released for budget B?

• 0-1 Knapsack (NP-complete)

• But release decisions are more political than NP-complete.

• Sensitivity Analysis: requirements data are usually estimates; which estimation will have the largest impact on the project, if it is off by X%?

Page 80: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Project Management & Planning

• Quantitatively simulate and measure the communication overhead (linear? logarithmic?)

• Robust planning: search for the tradeoff between overrun risk, project duration, and amount of overtime assignment

Page 81: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Design/architecture/refactoring

• Cluster software models to achieve certain structural properties (cohesion/coupling).

• Ironically, SBSE has also been used to analyse refactoring metrics: metric A and B both claim that they measure the same concept - optimising for A resulted in worse value of B, and vice versa :)

Page 82: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Genetic Improvement• Given a source code, can we automatically improve its non-functional

properties (such as speed)?

• Genetic Programming has been successfully applied to make genome-sequencing software 70 times faster. 70!

• W. Langdon and M. Harman. Optimizing existing software with genetic programming. Transactions on Evolutionary Computation, 19(1):118–135, 2015.

• Evolve a specialised version of MiniSAT solver for problem classes.

• J. Petke, M. Harman, W. B. Langdon, and W. Weimer. Using genetic improvement and code transplants to specialise a C++ program to a problem class. In proceedings of the 17th European Conference on Genetic Programming, volume 8599 of LNCS, pages 137–149. Springer, 2014.

Page 83: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Code Transplantation• Software X has feature A, which you want to have in

software Y. Can we automatically extract and transplant feature A from X to Y?

• E. T. Barr, M. Harman, Y. Jia, A. Marginean, and J. Petke. Automated software transplantation. In Proceedings of the 2015 International Symposium on Software Testing and Analysis, ISSTA 2015, pages 257–269.

Page 84: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

Summary

• Key ingredients to SBSE: representation, operators, fitness function.

• Design dictates solutions.

• Applications across all software development lifecycle activities, and beyond.

Page 85: Introduction to SBSE (2/2) · 2018-12-08 · Place 8 queens on a chessboard so that no pair attacks each other. Eight Queens Problem. Eight Queens Problem. ... programs. Examples

SBSE Repository

• http://crestweb.cs.ucl.ac.uk/resources/sbse_repository/