Ejemplo n.º 1
0
 public McsRandomVariable(MinimalCriticalSet reference, ICollection <FaultRandomVariable> faultVariables, Probability[] probability, string name = null)
 {
     Reference      = reference;
     Probability    = probability;
     FaultVariables = new HashSet <FaultRandomVariable>(faultVariables);
     Name           = name ?? reference.ToString();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Executes a DCCA and returns a list of McsRandomVariables that represent the DCCA results limited by the given faults.
        /// A minimal critical set which contains faults that are not in the given list of faults will be ignored.
        /// An empty minimal critical set will not be created as a random variable because it would not make sense regarding the probability theory.
        /// </summary>
        public IList <McsRandomVariable> FromDccaLimitedByFaults(Func <bool> hazard, ICollection <FaultRandomVariable> faults)
        {
            var analysis = new SafetySharpSafetyAnalysis
            {
                Backend    = SafetyAnalysisBackend.FaultOptimizedOnTheFly,
                Heuristics = { new MaximalSafeSetHeuristic(_model.Faults) }
            };
            var result       = analysis.ComputeMinimalCriticalSets(_model, new ExecutableStateFormula(hazard));
            var mcsVariables = new List <McsRandomVariable>();

            // Create a random variable for every nonempty critical set
            foreach (var criticalSet in result.MinimalCriticalSets.Where(set => set.Count > 0))
            {
                var mcs            = new MinimalCriticalSet(criticalSet);
                var mcsName        = $"mcs_{string.Join("_", mcs.Faults.Select(fv => fv.Name))}";
                var faultVariables = faults.Where(fv => mcs.Faults.Contains(fv.Reference)).ToList();
                mcsVariables.Add(new McsRandomVariable(mcs, faultVariables, mcsName));
            }
            GC.Collect();

            return(mcsVariables.Where(
                       criticalSet => criticalSet.FaultVariables.Count == criticalSet.Reference.Faults.Count
                       ).ToList());
        }