|
|
|
|
@ -93,19 +93,27 @@ def k_of_n_availability(availabilities: list[float], k: int) -> float:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_all_components(structure: Structure) -> set:
|
|
|
|
|
"""Extract all component names from a structure."""
|
|
|
|
|
def get_all_components(structure) -> set:
|
|
|
|
|
"""Extract all component/location_tag strings from a nested structure (series, parallel, k_of_n)."""
|
|
|
|
|
components = set()
|
|
|
|
|
|
|
|
|
|
def extract_components(substructure):
|
|
|
|
|
def extract(substructure):
|
|
|
|
|
if isinstance(substructure, str):
|
|
|
|
|
# Found a component or location tag
|
|
|
|
|
components.add(substructure)
|
|
|
|
|
elif isinstance(substructure, dict):
|
|
|
|
|
for component_list in substructure.values():
|
|
|
|
|
for component in component_list:
|
|
|
|
|
extract_components(component)
|
|
|
|
|
|
|
|
|
|
extract_components(structure)
|
|
|
|
|
# If it's k_of_n, check "components"
|
|
|
|
|
if "k_of_n" in substructure and "components" in substructure["k_of_n"]:
|
|
|
|
|
for comp in substructure["k_of_n"]["components"]:
|
|
|
|
|
extract(comp)
|
|
|
|
|
# If it's series/parallel or other nested structures
|
|
|
|
|
for value in substructure.values():
|
|
|
|
|
extract(value)
|
|
|
|
|
elif isinstance(substructure, list):
|
|
|
|
|
for item in substructure:
|
|
|
|
|
extract(item)
|
|
|
|
|
|
|
|
|
|
extract(structure)
|
|
|
|
|
return components
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -208,6 +216,7 @@ def compute_all_importance_measures(structure: Structure, availabilities: Dict[s
|
|
|
|
|
normalized_availabilities[comp] = 1.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Calculate system baseline availability
|
|
|
|
|
system_avail = system_availability(structure, normalized_availabilities)
|
|
|
|
|
|
|
|
|
|
@ -222,6 +231,7 @@ def compute_all_importance_measures(structure: Structure, availabilities: Dict[s
|
|
|
|
|
criticality = criticality_importance(structure, normalized_availabilities, component)
|
|
|
|
|
fv = fussell_vesely_importance(structure, normalized_availabilities, component)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
results[component] = {
|
|
|
|
|
'birnbaum_importance': birnbaum,
|
|
|
|
|
'criticality_importance': criticality,
|
|
|
|
|
|