📄 054-059.html
字号:
<HTML>
<HEAD>
<META name=vsisbn content="0849398010">
<META name=vstitle content="Industrial Applications of Genetic Algorithms">
<META name=vsauthor content="Charles Karr; L. Michael Freeman">
<META name=vsimprint content="CRC Press">
<META name=vspublisher content="CRC Press LLC">
<META name=vspubdate content="12/01/98">
<META name=vscategory content="Web and Software Development: Artificial Intelligence: Other">
<TITLE>Industrial Applications of Genetic Algorithms:Software Test Data Generation from a Genetic Algorithm</TITLE>
<!-- HEADER -->
<STYLE type="text/css">
<!--
A:hover {
color : Red;
}
-->
</STYLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<!--ISBN=0849398010//-->
<!--TITLE=Industrial Applications of Genetic Algorithms//-->
<!--AUTHOR=Charles Karr//-->
<!--AUTHOR=L. Michael Freeman//-->
<!--PUBLISHER=CRC Press LLC//-->
<!--IMPRINT=CRC Press//-->
<!--CHAPTER=4//-->
<!--PAGES=054-059//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="052-054.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="059-062.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><FONT SIZE="+1"><B>PROBLEM STATEMENT</B></FONT></P>
<P>The work presented here used a modified version of Goldberg’s [4] Simple Genetic Algorithm (SGA) to generate test data for one of the test programs used in Watkins’ work [3]. The program, trityp-easy, shown in Figure 4.1, is composed of multiple nested if-then-else constructs.
</P>
<P><A NAME="Fig1"></A><A HREF="javascript:displayWindow('images/04-01.jpg',500,636)"><IMG SRC="images/04-01t.jpg"></A></P>
<P><A NAME="Fig2"></A><A HREF="javascript:displayWindow('images/04-02.jpg',500,869)"><IMG SRC="images/04-02t.jpg"></A></P>
<P><A NAME="Fig3"></A><A HREF="javascript:displayWindow('images/04-03.jpg',500,513)"><IMG SRC="images/04-03t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/04-03.jpg',500,513)"><FONT COLOR="#000077"><B>Figure 4.1</B></FONT></A> The trityp-easy program.</P>
<P>The difficulty lies in finding test data which executes each line of source code within the MUT. Here test coverage was measured by instrumenting each block of code between control statements. Viewing trityp-easy as a series of code blocks (consisting of one or more statements) punctuated by control instructions helps visualize the flow of execution and is called the control graph. The code blocks in trityp-easy are delimited by opening and closing braces such as found on lines 14 and 17 in Figure 4.1, and represent nodes in the control graph.
</P>
<P>Figure 4.2 depicts a portion of the control graph for trityp-easy up through line number 53. The blocks of sequentially executed code become the nodes of the graph. Control instructions form the edges. Measuring test coverage is simply keeping track of which edges and nodes were traversed.</P>
<P><A NAME="Fig4"></A><A HREF="javascript:displayWindow('images/04-04.jpg',475,411)"><IMG SRC="images/04-04t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/04-04.jpg',475,411)"><FONT COLOR="#000077"><B>Figure 4.2</B></FONT></A> Partial control graph of trityp-easy.</P>
<P>McCabe [5] applied concepts from graph theory to control graphs to define his well known cyclometric complexity metric. This metric provides a measure of the number of linearly independent paths through a software module. The trityp-easy program has a cyclometric complexity of 21. The work described in this chapter varied population size as a multiple of the cyclometric complexity.
</P>
<P>Source code was instrumented by adding a function call to each block of code forming a node in the control graph. In Figure 4.1, the macro“INSTRUMENT_CODE”expands to a function call passing ___LINE___ as a parameter. The line number macro is replaced with the source file line number by the C preprocessor. The line number is cached for later use when the MUT executes one of these statements. Edge and node traversal counts are updated with the cached path information after the MUT has been completely traversed by a set of test data. The trityp-easy program has eighteen distinct blocks of code. Each is marked by the‘INSTRUMENT_CODE’ preprocessor macro.</P>
<P><FONT SIZE="+1"><B>SETTING UP THE GENETIC ALGORITHM</B></FONT></P>
<P>As previously indicated, the current effort utilized Goldberg’s SGA [4], though some modifications were made to streamline the process of gathering data. Specifically, those portions of the program soliciting operator input were replaced by hardcoded parameter values. All graphical data presented in this chapter were obtained from ensemble averages of 200 runs. Each run lasted 50 generations. Table 4.1 indicates the values of other pertinent GA parameters.
</P>
<TABLE WIDTH="100%" BORDER><CAPTION ALIGN=LEFT><B>Table 4.1</B> SGA parameters
<TR>
<TH WIDTH="60%" ALIGN="LEFT">Parameter
<TH WIDTH="30%" ALIGN="LEFT">Setting
<TR>
<TD>Number of Runs
<TD>200
<TR>
<TD>Chromosome Length
<TD>24 bits
<TR>
<TD>Number of Generations
<TD>50
<TR>
<TD>Probability of Crossover
<TD>1.00
<TR>
<TD>Type of Crossover
<TD>Two Point
<TR>
<TD>Probability of Mutation
<TD>0.005
<TR>
<TD>Scaling
<TD>Not Used
<TR>
<TD>Population Size
<TD>Varied
</TABLE>
<P>Various scaling methods were investigated but were found to actually hinder the formation of stable sub-populations of test data. This is because scaling operators are designed to amplify small differences between individuals, which is a form of positive feedback. The resulting positive feedback is used in standard GA based optimizations to provide good performers with exponentially more offspring. In this application, fitness is initially used to grant more offspring to good performers. However, as a sub-population grows, fitness will decrease, limiting its size and providing negative feedback. This limits uncontrolled reproduction of the descendants of a highly fit ancestor.
</P>
<P><FONT SIZE="+1"><B>CODING</B></FONT></P>
<P>The trityp-easy program used in this work takes three 32-bit integer parameters and determines what type of triangle (if any) they form. The coding used in this work is rather simple. Each 24-bit chromosome is split into three fields or alleles of eight bits each. For trityp-easy, the process of decoding a chromosome into parameters involved a simple conversion of an 8-bit allele into a 32-bit number. This coding was chosen because it was simple and allowed the author to focus on evaluating the fitness function. This coding also decreased the size of the search space, making this problem fairly easy for the GA.
</P>
<P>Since the goal of this effort is to eventually produce a usable (automatic) tool, it is not desirable to manually produce a coding for each module evaluated. It would be very efficient to simply code complete function parameters into the chromosome. The drawback of this approach is the large size of the resulting chromosomes. Larger chromosomes take longer to process and evolve. The success of the proposed utility will be dependent on resolving this issue.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="052-054.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="059-062.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<hr width="90%" size="1" noshade>
<div align="center">
<font face="Verdana,sans-serif" size="1">Copyright © <a href="/reference/crc00001.html">CRC Press LLC</a></font>
</div>
<!-- all of the reference materials (books) have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
</BODY>
</HTML>
<!-- END FOOTER -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -