[question]Simulating the Reliability of a Component-Based System

Acknowledgement

This part of the lab is based on Question 19 in Chapter 4 of Etter's "Engineering Problem Solving with C"

Problem

In this part of the lab you will write a program to simulate the reliability of the following component-based system:

http://pic.ourplus.com/yourpic/2005/...7061770b15.gif

Note that the reliability of such a system is measured as the probability that the system succeeds (i.e. does not fail). The system succeeds if there is a path from A to B through components that do not fail. So, for example, if Component 1 does not fail, the whole system succeeds because you can get from A to B through Component 1. However, if both Component 1 and Component 2 fail, the only way the system can succeed is if neither Component 3 nor Component 4 fails.

Your program must:

prompt the user for the reliability of each of the four components (as a number between 0.0 and 1.0 inclusive that represents the probability that the component will not fail)

prompt the user for the number of simulations to perform

compute the average reliability of the system

report the average reliability of the system to the user as a number between 0.0 and 1.0 representing the probability that the system will not fail

For each simulation, use the rand_float function developed in Chapter 4 of your textbook to randomly determine if each component succeeds or fails. The entire system will succeed if:

( Comp 1 succeeds ) OR ( Comp 2 succeeds ) OR ( Comp 3 AND Comp 4 succeed )

By counting the number of simulations for which the system succeeds, you can estimate the reliability of the system as:

( number of times system succeeds ) / ( number of simulations )

Note: Section 4.5 of Etter provides more details on how to use the rand_float function to simulate the success or failure of each component.

Developing a test suite

Before you write your program, develop a test suite that can be used to test your program once it is written. Refer to the notes in earlier labs on how to choose appropriate test values.

Having chosen your test values, compute by hand the expected output. After you have written your program, you can then test your program with each of your test values and check that your program produces the expected value. If it doesn't, you probably have one or more logic errors in your code.

Note: the theoretical reliability of this system (i.e., the probability that it does not fail) is given by:

R = r1 + r2 - r1r2 + r3r4 ( 1 - r1 - r2 + r1r2 )

where rn is the reliability of component n in the system (i.e. a number between 0.0 and 1.0 that represents the probability that the component will not fail).

Algorithm development

Sketch out, in point form, an algorithm for solving the problem.

Coding

Create a new project in Dev-C++ and implement your algorithm in C. Remember to first implement your functions as stubs and to compile your code before attempting to implement any of the functions. Remove any syntax errors before proceeding further. Implement your functions one at a time. Compile your code after implementing each function and remove any syntax errors as you go. Read the Guide to Dev-C++ for instructions on how to create a new project, edit your source code, and compile and run your program.

Testing

Once your code has successfully compiled, verify that it produces correct results using the test suite that you developed earlier. If any of your tests fails, you must look for logic errors in your algorithm (which will, of course, have resulted in logic errors in your code!)

Debugging

Now that the programs that you are writing are becoming a little more complex, you might find it useful to use the debugger that is integrated into the Dev-C++ environment. Read the Guide to debugging with Dev-C++ for instructions on how to use the debugger.