Metrics Are Fitness Functions Too Mark Harman John Clark Brunel University The University of York Uxbridge, Middlesex Heslington, York UB8 3PH, UK YO10 5DD, UK. Mark.Harman@brunel.ac.uk jac@cs.york.ac.uk Keywords: Search Based Software Engineering, Fitness, Optimisation, Genetic Algorithms Abstract Metrics, whether collected statically or dynamically, and whether constructed from source code, systems or pro- cesses, are largely regarded as a means of evaluating some property of interest. This viewpoint has been very successful in developing a body of knowledge, theory and experience in the application of metrics to estimation, predication, as- sessment, diagnosis, analysis and improvement. This paper shows that there is an alternative, complementary, view of a metric: as a fitness function, used to guide a search for optimal or near optimal individuals in a search space of possible solutions. This ‘Metrics as Fitness Functions’ (MAFF) approach offers a number of additional benefits to metrics research and practice because it allows metrics to be used to improve software as well as to assess it and because it provides an additional mechanism of metric analysis and validation. This paper presents a brief survey of search-based ap- proaches and shows how metrics have been combined with the search based techniques to improve software systems. It describes the properties of a metric which make it a good fitness function and explains the benefits for metric analysis and validation which accrue from the MAFF approach. 1. Introduction The title of this paper could equally well have been ‘Fit- ness functions are metrics too’ since the paper sets out to establish a one-to-one correspondence between fitness func- tions (used in optimisation and, in particular, in search- based software engineering) and software metrics. The advantage of establishing this correspondence is that techniques associated with search-based optimisation can be deployed in the analysis and validation of software met- rics, while the wealth of research and development of soft- ware metrics can be used at the heart of search-based ap- proaches to software engineering — as the fitness functions which guide the search. The paper presents a brief overview of search-based ap- proaches to software engineering (SBSE) and the metrics that have already been used in SBSE, before moving on to define the characteristics of a metric that would make it a good candidate for a search-based approach to optimizing a software engineering problem. The paper then gives sev- eral examples of the way in which techniques associated with search based optimisation can be used to assist in the analysis and validation of software metrics. The principal contributions of this paper are as follows: • The paper shows how concepts from the search based software engineering community can be useful in met- rics research. Specifically, it is shown: – How the combination of (possibly very different) metrics can be explored using multi objective fit- ness functions; – How fitness landscape visualisation techniques can be used to analyse metrics; – How a sequence of optimisation steps can be used as a metric validation technique; – How optimisation can yield insight into anoma- lies, hidden assumptions and similar shortcom- ings in a putative metric definition. • The paper also shows that metrics can be very useful in search based software engineering. The one-to-one correspondence between metrics and fitness functions means that many metrics can be used as the guiding force behind the search for optimal or near optimal so- lutions to many software engineering problems. The paper sets out the problem characteristics which are likely to lead to success in the application of a search- based approach, with the metric as a fitness function. 1 Proceedings of the 10th International Symposium on Software Metrics (METRICS’04) 1530-1435/04 $ 20.00 IEEE Authorized licensed use limited to: IEEE Xplore. Downloaded on October 29, 2008 at 10:47 from IEEE Xplore. Restrictions apply.