working on an approximate recursive fiunctiopn to calculate state
explosion
This commit is contained in:
parent
9040ad08d8
commit
83e4c4e579
54
fmmd_concept/System_safety_2011/state_exp.c
Normal file
54
fmmd_concept/System_safety_2011/state_exp.c
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int rcalc ( int n, int fgn, int cfn , int level)
|
||||
{
|
||||
int retval = 0,i;
|
||||
|
||||
|
||||
printf("level: %d n %d fgn %d cfn %d \n", level, n,fgn, cfn);
|
||||
|
||||
|
||||
level ++;
|
||||
|
||||
if ( n/fgn < fgn )
|
||||
retval = n%fgn * cfn;
|
||||
else
|
||||
retval += rcalc(n/fgn, fgn, cfn, level);
|
||||
|
||||
retval += n + (fgn-1) * fgn * cfn;
|
||||
|
||||
// now calculate how many to do on this level
|
||||
//
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
main () {
|
||||
|
||||
int r, n, fgn, cfn;
|
||||
|
||||
printf(" \n State explosion FMMD approximation \n");
|
||||
printf(" Enter number of base components: ");
|
||||
fflush(stdout);
|
||||
scanf("%d",&n);
|
||||
|
||||
printf(" Enter number of components in functional group: ");
|
||||
fflush(stdout);
|
||||
scanf("%d",&fgn);
|
||||
|
||||
printf(" Enter number of failure modes for each component:");
|
||||
fflush(stdout);
|
||||
scanf("%d",&cfn);
|
||||
|
||||
r = rcalc ( n, fgn, cfn, 0 );
|
||||
printf(" for single failures FMMD=%d components cross prod failure modes %d\n",r,n*(n-1)*cfn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user