Skip to content

A Python-based tool for analyzing Reliability Block Diagrams (RBD). This project parses structured text descriptions of systems, calculates Minimal Cut Sets (MCS) to identify failure points, and generates visual diagrams of the system architecture.

Notifications You must be signed in to change notification settings

Mbn64/RBD-Analyzer-Visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reliability Block Diagram (RBD) Analyzer & Visualizer

A Python-based tool for analyzing Reliability Block Diagrams (RBD). This project parses structured text descriptions of systems, calculates Minimal Cut Sets (MCS) to identify failure points, and generates visual diagrams of the system architecture.

Developed for the Fault Tolerant Systems course (Homework 3) at Sharif University of Technology.


🎯 Problem Description

In reliability engineering, understanding how component failures affect the entire system is crucial. The goal of this project is to:

  1. Parse a textual representation of a system's reliability logic (Block Diagram).
  2. Reconstruct the logical tree of dependencies.
  3. Identify which combinations of component failures lead to a total system failure.
  4. Extract Minimal Cut Sets (MCS): The smallest unique sets of components whose simultaneous failure causes the system to go down.
  5. Visualize the block diagram using a graphical interface.

The system supports complex structures including Series, Parallel, and k-out-of-n redundancies, allowing for nested configurations.


✨ Features

  • Custom Recursive Parser: robustly handles nested parentheses and complex expressions without relying on external logic parsers.
  • Minimal Cut Set Extraction: Automatically removes supersets to find the minimal failure combinations.
  • K-out-of-N Logic: Full support for majority voting or partial redundancy logic (e.g., "2 out of 3 components must work").
  • Automated Visualization: Uses matplotlib to draw the schematic of the RBD dynamically.
  • Comprehensive Test Suite: Includes a runner that validates logic against multiple test scenarios.

📝 Input Syntax (DSL)

The system accepts a Domain Specific Language (DSL) string.

Structure Syntax Description
Component Name Alphanumeric identifier (e.g., CPU, A1).
Series series(A, B, ...) If any component fails, the block fails.
Parallel parallel(A, B, ...) The block fails only if all components fail.
K-out-of-N kofn(k; A, B, ...) The block works if at least k components work. Conversely, it fails if more than n-k components fail.

Example Input:

series(
    PowerSupply,
    parallel(ServerA, ServerB),
    kofn(2; Disk1, Disk2, Disk3)
)


📂 File Structure & Logic

1. minimal_cut_set.py (The Core Engine)

This file contains the core logic for parsing and mathematical analysis.

  • Parsing: Implements a recursive descent parser (RBDParser) that tokenizes the input string and builds a tree of Node objects (SeriesNode, ParallelNode, KofNNode).

  • Cut Set Calculation:

  • Series: Performs a Union of children's cut sets.

  • Parallel: Performs a Cartesian Product of children's cut sets (all paths must be cut).

  • K-out-of-N: Generates combinations of failures required to break the redundancy threshold.

  • Minimization: The get_minimal_cut_sets function iterates through generated sets and removes any set that is a superset of another (e.g., if {A} is a cut set, {A, B} is discarded).

2. rbd_visualizer.py (The Visualization Layer)

Focuses on rendering the logical tree into a PNG image.

  • Preprocessing: Converts the DSL into Python objects suitable for drawing.
  • Drawing Engine: Uses matplotlib.patches.
  • Calculates the bounding box (width, height) of every node recursively to ensure components don't overlap.
  • Draws Series blocks horizontally.
  • Draws Parallel blocks vertically with branching connection lines.
  • Draws K-out-of-N blocks with a distinct dashed border and label.

3. runner.py (The Orchestrator)

The entry point for running tests.

  • Contains a dictionary of test_cases ranging from simple series to complex network topologies.
  • Bridge Function: Converts the string format used in minimal_cut_set.py to the format required by rbd_visualizer.py.
  • Executes both the analysis and drawing functions, saving the results to an outputs/ directory and generating a summary report.

🧮 Mathematical Logic

The program relies on Set Theory to determine system failure:

  1. Let be the collection of Cut Sets for a node.

  2. Series(A, B): System fails if A fails OR B fails.

  3. Parallel(A, B): System fails if A fails AND B fails.

  4. Minimal Cut Set: A cut set is minimal if there is no cut set .


⚙️ Prerequisites & Installation

You need Python 3.x and the Matplotlib library for visualization.

# Clone the repository
git clone https://github.com/Mbn64/RBD-Analyzer-Visualizer.git
cd RBD-Analyzer-Visualizer

# Install dependencies
pip install matplotlib 

🚀 Usage

Option 1: Run Full Test Suite

To generate reports and diagrams for all predefined test cases:

python3 runner.py

Results will be saved in the outputs/ directory.

Option 2: Analyze Specific RBD

To analyze a custom string, you can modify the main block in minimal_cut_set.py or run:

python3 minimal_cut_set.py

Option 3: Visualize Specific RBD

To generate a diagram for a custom string:

python3 rbd_visualizer.py

📊 Outputs

1. Text Analysis

The program outputs the logic tree and the identified Minimal Cut Sets:

Input: series(A, parallel(B, C))

Minimal Cut Sets:
1. {A}
2. {B, C}

Interpretation:
- {A} is a Single Point of Failure (SPOF).

2. Diagrams

Images are generated in the outputs/diagrams/ folder. Example of a generated diagram structure:

  • Series: Connected left-to-right.
  • Parallel: Stacked top-to-bottom with junction nodes.
  • K-out-of-N: Enclosed in a green dashed box indicating redundancy logic.

About

A Python-based tool for analyzing Reliability Block Diagrams (RBD). This project parses structured text descriptions of systems, calculates Minimal Cut Sets (MCS) to identify failure points, and generates visual diagrams of the system architecture.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages