🎓 Fault Tolerant System Design course assignment under the supervision of Dr. Zarandi at Amirkabir University of Technology
This repository contains a Monte Carlo simulation of a Triple Modular Redundancy (TMR) system implemented in Rust.
It compares two voting strategies:
- Classic majority voter (2-of-3 voting with tie-break)
- Reliability-aware MAP (Maximum A Posteriori) voter (probabilistic decision rule using module reliabilities)
The objective is to quantify how a reliability-aware voter improves correctness when module reliabilities are unequal and outputs are multi-valued.
- Three independent modules operate in parallel (TMR)
- The correct system output is fixed and equal to 27
- Each module produces an output in the range 0–63
For module i with reliability Ri:
- Probability of correct output (27): Ri
- Probability of an incorrect output (any value except 27): (1 − Ri) / 63
This reflecThis assumption states that, in the event of a module failure, the output is uniformly distributed over the 63 incorrect values in the integer range 0–63, excluding the correct value 27.
According to the problem specification, the module reliabilities depend on the last digit of the student ID.
Since the last digit of the student ID is 13, which is odd, the following reliability values are used:
- R1 = 0.9
- R2 = 0.5
- R3 = 0.2
Given module outputs (o1, o2, o3):
- If at least two outputs are equal, output that value.
- If all three outputs differ, apply a random tie-break and return one of the three values uniformly at random.
This models standard TMR voting behavior (2-out-of-3 agreement), extended to multi-valued outputs where a “no majority” situation can occur.
The MAP voter selects the candidate value that is most likely to be the true output given:
- the observed outputs, and
- the reliability parameters
{Ri}and the uniform fault model.
For a candidate value v, define the likelihood score:
- If
oi == v, the i-th module is treated as “correct” under hypothesisv, contributingRi. - If
oi != v, the i-th module is treated as “incorrect” under hypothesisv, contributing(1 − Ri)/63.
Thus, for candidate v:
Score(v) = product over i=1..3 of:
Riifoi == v(1 − Ri)/63ifoi != v
The MAP voter outputs the v that maximizes Score(v).
In the implementation, candidates are restricted to the observed outputs {o1, o2, o3}.
For each of N trials:
- Generate outputs from the three modules according to the probabilistic model.
- Compute the output of:
- Classic voter
- MAP voter
- Count a success when the voter output equals 27.
classic_ok: number of trials where the classic voter returned 27map_ok: number of trials where the MAP voter returned 27classic_rate = classic_ok / Nmap_rate = map_ok / N
The results of the evaluation are summarized in the following plot:
Monte Carlo methods rely on pseudo-random number generators (PRNGs).
A PRNG produces a deterministic sequence of numbers given an initial state. The seed defines that initial state.
Using a fixed seed is important for scientific and academic reproducibility:
- Ensures the experiment is repeatable
- Allows others (or the grader) to reproduce the exact same results
- Enables fair comparisons when changing parameters (e.g., switching voters or changing N)
If the PRNG is initialized from system entropy/time, each run uses a different random sequence. Results will vary slightly from run to run, which is normal for Monte Carlo experiments but less suitable for graded reports requiring consistent outputs.
In this project:
seed = 10is simply a chosen constant.- The key requirement is consistency, not the specific numeric value.
- Rust (edition 2021 or newer)
- Cargo
git clone https://github.com/salirezaeb/TMR.gitcd TMR
cargo run --release 1000 10This project presented a Monte Carlo evaluation of a Triple Modular Redundancy (TMR) system with multi-valued outputs.
Two voting strategies were analyzed: a classic majority voter and a reliability-aware MAP voter.
The results demonstrate that while the classic voter performs adequately when a majority exists, its performance degrades in cases where all module outputs differ. In contrast, the MAP voter explicitly incorporates module reliability information and the assumed uniform fault model, allowing it to make more informed decisions even in the absence of a majority.
The experimental results clearly show that, under asymmetric reliability conditions, the MAP voter achieves a significantly higher rate of correct decisions compared to the classic voter. This confirms the importance of probabilistic, reliability-aware voting schemes in fault-tolerant system design.
Overall, the study highlights how incorporating system knowledge into the voting mechanism can substantially improve the reliability of TMR-based systems.
