public double SystemRepair(RepairAction repairAction) { double sysRepair = 0; if (m_diagnoses == null || repairAction == null || repairAction.Count == 0) { return(sysRepair); } if (m_diagnoses.Count == 0) { return(1); //system is repaired } foreach (Diagnosis diag in m_diagnoses.Diagnoses) { if (diag.Comps == null || diag.Comps.Count == 0 || diag.Comps.Count > repairAction.Count) { continue; } //double p = diag.Probability; double p = diag.Probability / m_diagnoses.SetProbability; //changes foreach (Comp g in diag.Comps) { if (!repairAction.Contains(g)) { p = 0; break; } } sysRepair += p; } return(sysRepair); }
private DiagnosisSet computeNextState(RepairAction action) //the resulted diagnoses could be not subset minimal! { if (m_diagnoses == null || m_diagnoses.Count == 0 || action == null || action.Count == 0) { return(null); } DiagnosisSet ans = new DiagnosisSet(); foreach (Diagnosis diag in m_diagnoses.Diagnoses) { Diagnosis toAdd = new Diagnosis(); foreach (Comp g in diag.Comps) { if (!action.Contains(g)) { toAdd.AddCompToDiagnosis(g); } } if (toAdd.Comps.Count != 0) { ans.AddDiagnosis(toAdd); } } return(ans); }
//this function computes all the list of all the diagnoses which are not a subset of repairAction private List <Diagnosis> computeDiagNotSubV(SystemState state) { List <Diagnosis> ans = new List <Diagnosis>(); foreach (Diagnosis diag in state.Diagnoses.Diagnoses) { foreach (Comp c in diag.Comps) { if (!Action.Contains(c)) { ans.Add(diag); break; } } } return(ans); }
private double calcFNCostWorstCase(RepairAction repairAction, List <Comp> components) { double ans = 0; if (components == null || components.Count == 0) { return(ans); } foreach (Comp c in components) { if (!repairAction.Contains(c)) { ans += Overhead; } } return(ans); }
private double calcFNCostRegular(RepairAction repairAction, HealthStateVector HealthState) { double FN = 0; double FFP = 0; if (HealthState == null || HealthState.Count == 0) { return(0); } for (int i = 0; i < HealthState.Count; i++) { Comp c = HealthState.Components[i]; double h = HealthState.CurrentHealthState[i]; if (h == 0) { continue; } if (!repairAction.Contains(c)) { FN += (h * Overhead); if (ffpType == FFPType.FFP) { FFP += ((1 - h) * (c.Cost)); } else if (ffpType == FFPType.FFPplusOverhead) { FFP += ((1 - h) * (c.Cost + Overhead)); } } } if (ffpType != FFPType.noFFP) { return(FN + FFP); } return(FN); }