Documente Academic
Documente Profesional
Documente Cultură
Brian Korver1
briank@cs.pdx.edu
∫e
2
be known. Instead, system components need only be dx (EQ 1)
tested for failure during operation, which ensures that −2
components which are used more often contribute propor-
tionally more to the overall reliability estimate. Combined random points (x,y) are chosen from the range − 2 < x < 2 ,
with self-checking algorithms which respond to randomly- 0 ≤ y ≤ 1 . As can be seen from Figure 1, darts thrown ran-
generated inputs, the method obviates the need for valid, domly at that range can be expected to fall below the func-
nontrivial input data and an external oracle. tion
x2
−( )
2.0 The Monte Carlo Method f(x) = e 2
(EQ 2)
1
Crude Monte Carlo
be informed of whether a given point falls above or below sley & Handscomb, 1964, pp. 21-22). Thus, many
the function. improvements—called variance reduction techniques—
have been developed to reduce the required sample sizes.
According to Hammersley and Handsomb,
3.0 Crude Monte Carlo
The so-called variance-reducing techniques, which
lie at the heart of good Monte Carlo work, are tech-
The most general version of the Monte Carlo method of niques which reduce the coefficient of 1/n in the
reliability prediction is based on the “structure function” sampling variance of the final estimator, where n is
the sample size (or, perhaps more generally, the
which says that the state of a system is the product of the amount of labour expended on the calculation).
states of its components (Kaufmann, Grouchko, & Cruon,
1977, p. 56; Melchers, 1987, p. 91). Specifically, if For instance, Kumamoto, Tanaka, Inoue, and Henley
describe a variance reduction technique that increased the
xi = { 10 ifotherwise
component e i is in a good state, efficiency of a Monte Carlo simulation by 934-fold (1980,
p. 379). However, for the sake of simplicity and without
loss of generality, this paper describes the application of
then the state of the system y is crude Monte Carlo to the reliability simulation of software
systems.
n
y = ∏ xi (EQ 3)
i=1
4.0 Reliability Simulation
for components in series, and
Because the reliability of each component is based on
n
probability distributions, the reliability of each component
y = 1− ∏ ( 1 − xi) (EQ 4) in a system flow chart can be modelled by a set of random
i=1
numbers. For instance, if the reliability of a component is
for components in parallel. Since system behavior is 0.8, then successful operation of that component can be
based on the behavior of system components, the possible represented by the numbers from 0.0 through 0.79 and
error in the resulting reliability estimate is reduced (Kamat failure by the numbers from 0.8 through 0.99 (Amstadter,
& Riley, 1975, p. 73). 1971, p. 176). By generating random numbers as the sys-
tem flow chart is traced, it is possible to simulate the state
While “crude”—or “direct”—Monte Carlo is statistically of each component. These component states can then be
sound and easy to understand, it can be a computationally combined using the structure function to determine the
expensive technique. Since most systems are highly reli- state of the system. Since “each execution of a simulation
able, crude Monte Carlo simulations require large sample tells only whether a particular set of conditions did or did
sizes to obtain a sufficient quantity of failures to provide not” exist, the Monte Carlo method is an experimental
reliable estimates. Moreover, since the standard error of problem-solving technique such that “many simulation
the final result is inversely proportional to the square root runs have to be made to understand the relationships
of the sample size n, the sample size must be increased k2 - involved in the system” (Gordon, 1978, pp. 42, 43). Each
fold to reduce the standard error by a factor of k (Hammer- repetition of the simulation results in another independent
estimate of the reliability of the system. As the number of
simulations increases, the sample mean of these indepen-
FIGURE 1. Monte Carlo Integration
dent estimates approaches the actual characteristics of the
system (Amstadter, 1971, p. 176). According to Verma,
1
Fu, and Moses,
f(x)
tem failure domain (which may not have a simple FIGURE 3. Results from Listing 1
boundary). (1989, p. 895)
0.04
That is, the Monte Carlo method computes the statistical Actual Failure Intensity is 0.01925
0.035
expectation of the reliability distributions (Zaremba, 1968,
p. 304). Thus, because estimates of system reliability are 0.03
Failure Intensity
based on probability distributions functions representing
0.025
the failure rates of components, the Monte Carlo method
will accurately simulate system reliability whatever the 0.02
complexity of those distributions, even in the case that 0.015
they are entirely empirical.
0.01
30 Trial Mean
0.005
Standard Deviation
5.0 System Reliability Estimation 0
0 500 1000 1500 2000 2500
Consider the arbitrary, trivial three-component system Number of System Simulations
with the failure intensities shown in Figure 2. Listing 1
demonstrates the use of Monte Carlo methods to simulate
the behavior of this system and thus can be used to esti-
mate its reliability. The failure of one of the two compo- 6.0 MTBF Estimation
nents that form the series subsystem causes the failure of
the entire subsystem. A given iteration of the subsystem is
Listing 2 demonstrates the use of Monte Carlo methods to
simulated by testing the state of the first component of the
estimate the mean time between failures (MTBF) of the
subsystem by generating a random number in the range
system shown in Figure 2 by counting the average amount
[0,1]. If the first component does not fail, then the state of
of time (measured here in iterations) between each failure.
the second component is tested. If the series subsystem
Given sample size n with t1, t2, ..., tn being the number of
fails, then the parallel component is tested. If it too fails,
successful iterations between failures,
then the entire system fails. After a number of these sys-
tem simulations have been performed, the failure intensity n
∑t
of the system is calculated by dividing the number of 1
MTBF = i (EQ 5)
observed failures by the total number of simulations. The n
i=1
actual failure intensity for this system is 0.01925.1 The
results from actual simulation runs of Listing 1 are given (Shooman, 1983, pp. 570-571). As each run of successes
in Figure 3. As the number of system simulations until a failure occurs constitutes a geometric experiment,
increases, the simulation results converage to the actual the actual MTBF of the system in Figure 2 is 51.948.2 The
mean. results from actual simulation runs of Listing 2 are given
in Figure 4. Because each sample in a MTBF estimate
consists of the number of Bernoulli trials until a failure
occurs, the variance of the results is less than that of the
single Bernoulli trial simulated failure intensity.
80 Component Description
Actual MTBF is 51.948
1 Generate a system of linear equations
70
2 Check if the system has been generated ran-
Failure Intensity
domly
60
3 Reduce the matrix to echelon form using
Gaussian elimination
50
4 Check if the matrix is in echelon form
40
5 Backsolve to obtain the roots
6 Check if the roots are a solution to the system
30 Trial Mean of linear equations
30
Standard Deviation
20 hierarchical structure, while other decompositions
0 500 1000 1500 2000 2500
may show a graph with loops in it. (1974, p. 336)
FIGURE 6. Results from Listing 3 That is, if you are trying to empirically determine the
probability that a king will come up in a poker deck, a
0.0006 pinochle deck will not suffice. More importantly, these
arbitrary limits facilitated the random testing of the indi-
0.0004 vidual components which was necessary in order to com-
pare the analytically computed failure intensity with the
Failure Intensity
0.0002
results of the Monte Carlo simulation. The results of these
tests demonstrate that Monte Carlo simulation techniques
match the analytically computed failure intensities. The
0
results from actual simulation runs of Listing 3 are given
in Figure 6. However, these results could not be compared
-0.0002 to the “actual” failure intensity since there is no reliable
30 Trial Mean
Standard Deviation method of analytically calculating the failure intensity of
-0.0004 software systems.
0 500 1000 1500 2000 2500
Number of System Simulations Similarly, “bugs” which were triggered by calls to a ran-
dom number generator were inserted into each of the com-
form. However, to increase accuracy, all component fail- ponents. For 500 system simulations, the results of the
ures should be included in failure rate calculations. For analytically-computed failure intensity and the results of
serial components, it is important to note that simple sys- the Monte Carlo reliability simulation were relatively
tem composition calculations would result in counting close. Example results from these tests are shown in
some component failures more than once since a failure by Table 2.
component pj causes component pi to fail. Thus, the fail-
ure intensity of component pi is computed by factoring out TABLE 2. Monte Carlo Simulation Tests
those errors caused by component pj.4
Component System
The technique employed in Listing 3 can be used to deter- Failure Intensity Failure Intensity
mine if components not related by “uses” are effecting 1 3 5 Actual Simulated % Error
each other. By conducting a number of one-run simula-
tions, the number of times each component fails indepen- 0.25 0.10 0.05 0.03625 0.03041 16.11
dently and the number of times they fail together can be 0.03 0.10 0.05 0.00435 0.00459 05.52
counted. Whether one is causing the other to fail can be 0.03 0.20 0.05 0.00720 0.00837 16.25
determined by the standard test of independence.5 0.03 0.20 0.10 0.00840 0.00726 13.57
Amstadter, B.L. (1971). Reliability mathematics: Funda- Hammersley, J.M., & Handscomb, D.C. (1964). Monte
mentals; practices; procedures. New York: McGraw- Carlo methods. New York: John Wiley & Sons, Inc.
Hill Book Company.
Hamlet, D. (1992, July). Are we testing for true reliabil-
Babbit, A., Powell, S.T., & Hamlet, D. (1990). Prototype ity? IEEE Software, pp. 21-27.
testing tools. In Proceedings of the 9th Annual Pacific
Northwest Software Quality Conference (pp. 264- Hamlet, D. (1993). Random testing (PSU TR 93-10).
280). Portland, OR : [The Conference]. Portland, OR: Portland State University Computer
Science Department.
Barlow, R.E., & Proschan, F. (1965). Mathematical theory
of reliability. New York: John Wiley & Sons. Hamlet, D., & Voas, J. (1993). Faults on its sleeve: Ampli-
fying software reliability testing. In Proceedings of
Binder, K., & Heermann, D.W. (1988). Monte Carlo sim- the International Symposium on Software Testing and
ulation in statistical physics: An introduction. New Analysis (pp. 89-98). Cambridge, MA: [The Confer-
York: Springer-Verlag. ence].
Birnbaum, Z.W. (1955). On a use of the Mann-Whitney Kamat, S.J., & Riley, M.W. (1975). Determination of reli-
statistic. Proceedings of the Third Berkeley Sympo- ability using event-based Monte Carlo simulation.
sium on Mathematical Statistics and Reliability (pp. IEEE Transactions on Reliability, R-24(1), pp. 73-75.
13-17). Berkeley and Los Angeles: University of Cal-
ifornia Press. Kaufmann, A., Grouchko, D., & Cruon, R. (1977). Mathe-
matical models for the study of the reliability of sys-
Birolini, A. (1985). On the use of stochastic processes in tems. New York: Academic Press.
modeling reliability problems. New York: Springer-
Verlag. Kumamoto, H. Tanaka, K., Inoue, K., & Henley, E.
(1980). State-transition Monte Carlo for evaluating
Blum, M., & Kannan, S. (1989). Designing programs that large, repairable systems. IEEE Transactions on Reli-
check their work. Proceedings of the 21st Annual ability, R-29(5), pp. 376-380.
ACM Symposium on Theory of Computing (pp. 86-
97). New York: Association for Computing Machin- Kleijnen, J.P.C. (1974). Statistical techniques in simula-
ery. tion (Part 2). New York: Marcel Dekker, Inc.
Blum, M., Luby, M., & Rubinfeld, R. (1990). Self-testing/ Levy, L.L, & Moore, A.H. (1967). A Monte Carlo tech-
correcting with applications to numerical problems. nique for obtaining system reliability confidence lim-
Proceedings of the 22nd Annual ACM Symposium on
its from component test data. Transactions on ods. In A.H-S. Ang, M. Shinozuka, & G.I. Schueller
Reliability, R-16(2), pp. 69-72. (Eds.), Structural Safety & Reliability: Proceedings of
ICOSSAR ‘89, the 5th International Conference on
Mann, N.R., Schafer, R.E., & Singpurwalla, N.D. (1974). Structural Safety and Reliability (pp. 895-901). New
Methods for statistical analysis of reliability and life York: American Society of Civil Engineers.
data. New York: John Wiley & Sons.
Walpole, R.E., & Myers, R.H. (1989). Probability and
Melchers, R.E. (1987). Structural reliability: Analysis and statistics for engineers and scientists (4th ed.). New
prediction. New York: John Wiley and Sons. York: Macmillan Publishing Company.
Miyakawa, M. (1984). On stochastic coherent systems. In Zaremba, S.K. (1968). The mathematical basis of Monte
M. Beckman & W. Krelle (Eds.), Stochastic models in Carlo and quasi-Monte Carlo methods. SIAM Review
reliability theory (pp. 1-11). New York: Springer-Ver- 10(3), pp. 303-314.
lag.
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: system_test
*
* AUTHOR: Brian Korver
* PURPOSE: Perform a Bernoulli trial, computing the state of the three-component system
* using the structure function.
*
* #2 #3
* /------\ /------\
* -----| 0.15 |----------| 0.05 |-----
* | \------/ #1 \------/ |
* | /------\ |
* ------------| 0.10 |------------
* \------/
*
* ARGUMENTS: -
* RETURN: 0 = FAILURE, 1 = SUCCESS
* INPUT: -
* OUTPUT: -
* EXIT CODE: -
* CALLS: drand48()
*/
int
system_test()
{
if ( (drand48() >= 0.90) && /* if component 1 fails and */
((drand48() >= 0.85) || /* either component 2 or */
(drand48() >= 0.95)) ) /* component 3 fails, */
return FAILURE; /* then the system fails */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: estimate_reliability
*
* AUTHOR: Brian Korver
* PURPOSE: Conduct a Binomial experiment of a number of independent Bernoulli trials.
* Count the number of system failures. Compute the failure intensity by
for ( trials_conducted = 0;
trials_conducted < number_of_trials;
++trials_conducted
) if (system_test() == FAILURE) ++failures;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: main (listing1)
*
* AUTHOR: Brian Korver
* PURPOSE: estimate the reliability of a simple system
* ARGUMENTS: argv[1] -- the number of system simulations to run
* RETURN: -
* INPUT: -
* OUTPUT: -
* EXIT CODE: -
* CALLS: atoi(), estimate_reliability()
*/
void
main(int argc, char *argv[])
{
if (argc == 2) estimate_reliability(atoi(argv[1]));
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: system_test
*
* AUTHOR: Brian Korver
* PURPOSE: Perform a Bernoulli trial, computing the state of the three-component system
* using the structure function.
*
* #2 #3
* /------\ /------\
* -----| 0.15 |----------| 0.05 |-----
* | \------/ #1 \------/ |
* | /------\ |
* ------------| 0.10 |------------
* \------/
*
* ARGUMENTS: -
* RETURN: 0 = FAILURE, 1 = SUCCESS
* INPUT: -
* OUTPUT: -
* EXIT CODE: -
* CALLS: drand48()
*/
int
system_test()
{
if ( (drand48() >= 0.90) && /* if component 1 fails and */
((drand48() >= 0.85) || /* either component 2 or */
(drand48() >= 0.95)) ) /* component 3 fails, */
return FAILURE; /* then the system fails */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: estimate_MTBF
*
* AUTHOR: Brian Korver
* PURPOSE: Conduct a number of Geometric experiments, which consist of conducting
* Bernoulli trials until the first system failure occurs. Compute the MTBF--
for ( experiments_conducted = 0;
experiments_conducted < number_of_experiments;
++experiments_conducted
) while (system_test() == SUCCESS) ++successful_iterations;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: main (listing2)
*
* AUTHOR: Brian Korver
* PURPOSE: estimate the MTBF of a system
* ARGUMENTS: argv[1] -- the number of system simulations to run
* RETURN: -
* INPUT: -
* OUTPUT: -
* EXIT CODE: -
* CALLS: atoi(), estimate_MTBF()
*/
void
main(int argc, char *argv[])
{
if (argc == 2) estimate_MTBF(atoi(argv[1]));
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Function prototypes for a matrix ADT, the code is not included in this listing
*
matrix *initmatrix(int rows, int cols);
void delmatrix(matrix *m);
matrix *dupmatrix(matrix *m);
int ncols(const matrix *m);
int nrows(const matrix *m);
element getel(const matrix *m, int row, int col);
void putel(element el, matrix *m, int row, int col);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: parallel
*
* AUTHOR: Brian Korver
* PURPOSE: to compute the failure intensity of two parallel components given the failure
* intensity of the two components. The parallel subsystem fails if both
* components fail.
* ARGUMENTS: c1, c2 -- the failure intensity of two components which are in parallel
* RETURN: the parallel failure intensity of the two components
* INPUT: -
* OUTPUT: -
* EXIT CODE: -
* CALLS: -
*/
float
parallel(float c1, float c2)
{
return (c1 * c2);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: serial
*
* AUTHOR: Brian Korver
* PURPOSE: to compute the failure intensity of two serial components given the failure
* intensity of the two components. The series subsystem fails when one of the
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: randomize
*
* PURPOSE: fill a matrix with random numbers
* ARGUMENTS: m -- a pointer to the matrix
* RETURN: -
* INPUT: -
* OUTPUT: -
* EXIT CODE: -
* CALLS: mrand48()
*/
void
randomize(matrix *m)
{
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: report_failure
*
* AUTHOR: Brian Korver
* PURPOSE: for “reporting” that a failure occured. Reports to the file pointer OUT
* which is defined globally.
* ARGUMENTS: component -- the number of the failured component
* RETURN: -
* INPUT: -
* OUTPUT: prints the component number (in ascii) to the file attached to the global file
* pointer OUT
* EXIT CODE: -
* CALLS: fprintf()
*/
void
report_failure(int component)
{
extern FILE *OUT;
fprintf(OUT,”%d\n”,component);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: seed
*
* PURPOSE: seed random number generator with system time times the process id
* ARGUMENTS: -
* RETURN: -
* INPUT: -
* OUTPUT: -
* EXIT CODE: -
* CALLS: lcong48(), seed48(), srand48(), ftime(), getpid()
*/
void
seed()
{
extern pid_t getppid();
extern ftime();
long s;
struct timeb tp;
(void) ftime(&tp);
s = (long) tp.millitm * getpid();
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: generate_system_of_equations
*
* AUTHOR: Brian Korver
* PURPOSE: generate a system of linear equations in a random n x n+1 matrix. The
* matrix size is being arbitrarily limited to 0 < n < n_max.
* ARGUMENTS: n_max -- the maximum value for n
* RETURN: a random matrix
* INPUT: -
* OUTPUT: -
* EXIT CODE: -
* CALLS: mrand48(), abs(), initmatrix(), randomize()
*/
matrix *
generate_system_of_equations(int n_max)
{
extern long int mrand48();
register int size;
register matrix *m;
m = initmatrix(size,size + 1);
randomize(m);
return(m);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: matrix_is_random
*
* AUTHOR: Brian Korver
* PURPOSE: check to see if the matrix being passed qualifies as a random matrix
* ARGUMENTS: m -- a pointer to a matrix
* RETURN: 1 if the matrix is random, 0 otherwise
* INPUT: -
* OUTPUT: -
* EXIT CODE: -
* CALLS: nrows(), ncols(), fabs(), getel()
*/
int
matrix_is_random(const matrix *m)
{
register int r, c; /* row, column loop index */
register long double mean, variance;
register int size;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: gaussian_elimination
*
* AUTHOR: Brian Korver
* PURPOSE: reduce a matrix to echelon form using gaussian elimination (see pp. 330-333
* of Burden, R.L., & Faires, J.D. (1993), _Numerical Analysis_ (5th Ed.).
* Boston: PWS Publishing Company or for a description of this algorithm )
* ARGUMENTS: orig -- a pointer to a n x n+1 matrix containing a system of linear equations
* RETURN: a pointer to the reduced echelon matrix, or 0 if no unique solution exists
* INPUT: -
* OUTPUT: -
* EXIT CODE: -
* CALLS: dupmatrix(), initmatrix(), ncols(), nrows(), getel(), putel(), fabs(),
* delmatrix()
*/
matrix *
gaussian_elimination(const matrix *orig)
{
register matrix *m, *A;
register int i, j, p, n, k;
int NROW[n];
register element NCOPY;
n = nrows(orig);
A = dupmatrix(orig);
m = initmatrix(nrows(A),ncols(A));
delmatrix(m);
return(0);
}
if (NROW[i] != NROW[p]) {
NCOPY = NROW[i];
NROW[i] = NROW[p];
NROW[p] = NCOPY;
}
delmatrix(A);
return(m);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: matrix_is_reduced
*
* AUTHOR: Brian Korver
* PURPOSE: check to determine if the passed matrix e is in echelon form
* ARGUMENTS: m -- a pointer to a matrix
n = 0;
for (r = 1; r <= nrows(e); ++r) { /* loop through rows & cols */
c = 1;
while ((c <= ncols(e)) && (fabs(getel(e,r,c)) < ZERO))
/* look for 1st non-0 in row */
++c;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: roots_from_backsubstitution
*
* AUTHOR: Brian Korver
* PURPOSE: get root from backsubstituting using an echelon matrix
* ARGUMENTS: A -- a pointer to a matrix in echelon form
* RETURN: a pointer to a n x 1 vector (matrix) containing the roots [x1,x2,...,xN]
* or a null pointer if the vector A is not valid
* INPUT: -
* OUTPUT: -
* EXIT CODE: -
* CALLS: nrows(), initmatrix(), getel(), putel()
*/
matrix *
if (A == 0) return (0);
n = nrows(A);
roots = initmatrix(nrows(A),1);
putel((getel(A,n,n+1) / getel(A,n,n)),roots,n,1);
return(roots);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: roots_are_solution
*
* AUTHOR: Brian Korver
* PURPOSE: substitute roots into a system of linear equations to see if they are
* actually the solution to the system [given the tolerance SOLUTION_THRESHOLD].
* ARGUMENTS: M -- a pointer to a system of linear equations
* R -- a pointer to a matrix containing the roots [x1,x2,...,xN]
* RETURN: 0 if any of the equations are off by more than 1.0E-9, otherwise 1 (success)
* INPUT: -
* OUTPUT: -
* EXIT CODE: -
* CALLS: nrows(), ncols(), getel(), fabs()
*/
int
roots_are_solution(const matrix *M, const matrix *R)
{
register int r, c;
register element sum;
register int rows, cols;
rows = nrows(M);
cols = ncols(M);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: solve_linear_system
*
* AUTHOR: Brian Korver
* PURPOSE: solve a system of linear equations
* ARGUMENTS: m -- a pointer to a n x n+1 matrix to treat as the system of linear equations
* RETURN: a pointer to a n x 1 vector (matrix) containing the roots [x1,x2,...,xN]
* or a null pointer if no solution is possible (for whatever reason)
* INPUT: -
* OUTPUT: -
* EXIT CODE: -
* CALLS: gaussian_elimination(), matrix_is_reduced(), report_failure(),
* roots_from_backsubstitution(), roots_are_solution()
*/
matrix *
solve_linear_system(const matrix *m)
{
matrix *echelon_matrix, *roots;
echelon_matrix = gaussian_elimination(m);
/* solution exists */
return ((matrix *) 0); /* successful termination */
}
return(roots);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: fgetd
*
* AUTHOR: Brian Korver
* PURPOSE: like return(atoi(fgets(...,iop))) except it breaks on any
* non-numeric (provided by isdigit())
* See K&R II p. 165 for the inspiration for this function
* ARGUMENTS: iop -- the file pointer to read from
* RETURN: the number if a number was read, otherwise EOF (from stdio.h)
* INPUT: reads from iop
* OUTPUT: -
* EXIT CODE: -
* CALLS: getc(), isdigit(), atoi()
*/
int
fgetd(FILE *iop)
{
register int c, n = (sizeof(int) * sizeof(int) + 2);
register char *cs;
char s[(sizeof(int) * sizeof(int) + 2)];
int r;
cs = s;
*cs = ‘\0’;
if (cs == s) {
r = EOF;
} else {
r = atoi(s);
return r;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: linear_system_software
*
* AUTHOR: Brian Korver
* PURPOSE: solve a randomly-generated system of linear equations while checking for
* software system failures
* ARGUMENTS: error_report -- a file (or pipe) to report where errors occured
* RETURN: -
* INPUT: -
* OUTPUT: -
* EXIT CODE: 0 (success) as long as both subsystems didn’t fail, otherwise 1 (failure)
* the error
* CALLS: seed(), generate_system_of_equations(), matrix_is_random(),
* solve_linear_system()
*/
void
linear_system_software()
{
matrix *random_matrix, *roots;
int generation_failure, solution_failure;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: estimate_software_reliability
*
* AUTHOR: Brian Korver
* PURPOSE: Conduct an experiment of a number of independent trials. Count the number of
* failures attributed to each component. Compute the system failure intensity by
* treating components related by USES() as serial components, and those not
* related by USES() as parallel components.
* ARGUMENTS: number_of_trials -- the number of independent trials to conduct
* RETURN: -
* INPUT: -
* OUTPUT: the number of failures attributed to each component, the number of trials
* conducted, and the computed system failure intensity.
* EXIT CODE: -
* CALLS: pipe(), fdopen(), fork(), fclose(), linear_system_software(),
* wait(), feof(), fgetd(), printf(), parallel(), serial()
*/
void
estimate_software_reliability(int number_of_trials)
{
register int failure = 0; /* Bernoulli trials that failed */
register int trials_conducted; /* for loop index */
register int component_number; /* failed component_number */
float system_failure_intensity; /* reliability estimate */
int component_failures[COMPONENTS + 1]; /* component failure counts */
float failure_intensity[COMPONENTS + 1]; /* component failure intensities */
int statusp; /* status of child process */
int fd[2]; /* pipe file descriptors */
for ( trials_conducted = 0;
trials_conducted < number_of_trials;
++trials_conducted ) {
system_failure_intensity =
parallel(failure_intensity[1],serial(failure_intensity[3],failure_intensity[5]));
system_failure_intensity = serial(system_failure_intensity,failure_intensity[0]);
/* include signal failures and */
/* failures in which exit() was used. */
/* Actually, these should be trapped */
/* and traced to their source. */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTION: main (listing3)
*
* AUTHOR: Brian Korver
* PURPOSE: estimate the reliability of a software system
* ARGUMENTS: argv[1] -- the number of system simulations to run
* RETURN: -
* INPUT: -
* OUTPUT: -
* EXIT CODE: -