###########################################################
# #
# Construct a BDD for a given 8-out-of-12 #
# system and evaluate its reliability #
# #
###########################################################
from c_bdd import BDDSystem
from c_threshold import BDDThreshold
# Component reliabilities
p = 0.5
# Component weights
a = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
# Threshold
b = 8
# Number of components
n = len(a)
# Sum of weights
wsum = 0
for wg in a:
wsum += wg
sys = BDDSystem(BDDThreshold(a, wsum, b))
result = sys.calculateReliability0(p)
sys.printSystem()
print("")
print("System unreliability = ", result[0])
print("System reliability = ", result[1])