A lightweight, efficient Python library for computing minimal cutsets from fault trees using the legendary MOCUS algorithm.
Perfect for reliability engineers, safety analysts, and system architects working with fault tree analysis!
- Fast & Efficient: Implements the proven MOCUS algorithm for minimal cutset computation
- Flexible Input: Load fault trees from CSV files or define them programmatically
- Easy Integration: Simple, intuitive API with zero external dependencies
- Well-Tested: Validated with real-world aerospace examples
- MIT Licensed: Use freely in your projects
Install directly from PyPI:
pip install cutsets
import cutsets # Define a simple fault tree ft = [ ("TOP", "Or", ["E1", "E2"]), ("E1", "Or", ["a", "b"]), ("E2", "And", ["c", "d"]) ] # Compute minimal cutsets mcs = cutsets.mocus(ft) print(mcs) # Output: [['a'], ['b'], ['d', 'c']]
Create a CSV file with your fault tree structure:
TOP,And,B1 B2 B1,Or,C1 C2 C3 C4 B2,Or,C5 C6 C7 C1,And,D1 D2 C2,And,D1 E2 E2,Or,D3 D4 C3,And,D5 E3 E3,Or,D2 D6 C4,And,D1 D7 C5,And,D5 E5 E5,Or,D2 D6 C6,And,D8 E6 E6,Or,D2 D4 D6 C7,And,D8 E7 E7,Or,D4 D9
Then load and analyze:
import cutsets # Load fault tree from CSV ft = cutsets.get_ft('aircraft.csv') # Compute minimal cutsets mcs = cutsets.mocus(ft) print(mcs) # Output: [['C2', 'B2'], ['B2', 'C3'], ['C4', 'B2'], ['D1', 'B2', 'D2']]
Loads a fault tree from a CSV file.
Parameters:
filename(str): Path to CSV file with format:gate_name,gate_type,inputsgate_type: Either"And"or"Or"(case-sensitive)inputs: Space-separated list of child gate/event names
Returns: List of tuples representing the fault tree structure
Computes minimal cutsets using the MOCUS algorithm.
Parameters:
fault_tree(list): Fault tree as list of tuples or fromget_ft()
Returns: List of minimal cutsets (each cutset is a list of basic events)
Define fault trees as a list of tuples:
[
(gate_name, gate_type, [child1, child2, ...]),
...
]gate_name: Unique identifier (e.g., "TOP", "E1", "B1")gate_type: Either"And"or"Or"- Children: List of child gate/event names
Important: The root gate must be named "TOP"
Check the examples directory for more detailed demonstrations, including the classic aircraft fault tree analysis.
The MOCUS (Method of Obtaining Cut Sets) algorithm:
- Starts from the TOP event
- Recursively expands gates according to Boolean logic
- Identifies minimal cutsets (smallest combinations of events that cause failure)
- Removes redundant supersets
This is particularly useful in safety-critical systems analysis where you need to understand the minimal combinations of failures that lead to system failure.
- [1] N. Limnios and R. Ziani, "An Algorithm for Reducing Cut Sets in Fault-Tree Analysis," IEEE Transactions on Reliability, vol. 35, no. 5, pp. 559-562, Dec. 1986. doi: 10.1109/TR.1986.4335545
- [2] J. B. Fussell and W. E. Vesely, "A New Methodology for Obtaining Cut Sets for Fault Trees," Trans. Am. Nucl. Soc., vol. 15, pp. 262-263, June 1972.
MIT License - See LICENSE file for details
Umair Siddique
- GitHub: @iamumairs
- Repository: fault-tree-mcs
Contributions are welcome! Feel free to open issues or submit pull requests to improve the library.
Made with ❤️ for the reliability engineering community