Robin_PHD/component_failure_modes_definition/unitary_state.bc

46 lines
884 B
Plaintext

# NOT FINISHED YET !!!!
# define a factorial function
# gives 1 for negative values as well
define f(x) {
if (x>1) {
return (x * f (x-1))
}
return (1)
}
# determine how many combinations would be dis-allowed
# from a cardinality constrained powerset
# given unitary state failure mode conditions
define uc(c,k,x) {
aa = 0;
#for(i=2; i<=c; i++) aa += k * f(k)/(f(i)*f(k-i));
if ( c>2 ) {
return aa + uc(c-1,k,x);
}
return aa;
}
# cardinality constrained powerset
# how many combinations of cardinality k
# can we have from c number of components
# with x number of failure modes
define ccps(c,k,x) {
return f(k*x)/(f(c)*f(k*x-c))
}
define us(c,k,x) {
a=0;
for(i=1;i<=c;i++) a += ccps(i,c,x);
# a now holds all combinations
# we must now subtract those combinations
# dis-allowed under unitary state conditions.
a -= uc(cc,c,x);
return a;
}
us(2,3,3);