public void CalculateHazardProbabilityWhenF1NeverOccurs() { var model = new ExampleModelBase(); model.System.SignalDetector1.F1.ProbabilityOfOccurrence = new Probability(0.0); var result = SafetySharpModelChecker.CalculateProbabilityToReachStateBounded(model, model.System.HazardActive, 50); Console.Write($"Probability of hazard: {result}"); }
public void CalculateDcca() { var model = new ExampleModelBase(); var analysis = new SafetySharpSafetyAnalysis { Backend = SafetyAnalysisBackend.FaultOptimizedOnTheFly, Heuristics = { new MaximalSafeSetHeuristic(model.Faults) } }; var result = analysis.ComputeMinimalCriticalSets(model, model.System.HazardActive); //result.SaveCounterExamples("counter examples/height control/dcca/collision/original"); var orderResult = SafetySharpOrderAnalysis.ComputeOrderRelationships(result); Console.WriteLine(orderResult); }
public void CalculateHazardProbabilityGraph() { var model = new ExampleModelBase(); var minValue = 0.0; var maxValue = 1.0; var steps = 250; var stepSize = (maxValue - minValue) / (steps - 1); var sourceValues = new double[steps]; var resultValues = new double[steps]; for (var i = 0; i < steps; i++) { var currentValue = i * stepSize; sourceValues[i] = currentValue; model.System.SignalDetector1.F1.ProbabilityOfOccurrence = new Probability(currentValue); var currentResult = SafetySharpModelChecker.CalculateProbabilityToReachStateBounded(model, model.System.HazardActive, 50); GC.Collect(); resultValues[i] = currentResult.Value; } var fileWriter = new StreamWriter("Model3/graph.csv", append: false); var csvWriter = new CsvWriter(fileWriter); csvWriter.AddEntry("Step"); for (var i = 0; i < steps; i++) { csvWriter.AddEntry(i); } csvWriter.NewLine(); csvWriter.AddEntry("Pr(F1)"); for (var i = 0; i < steps; i++) { csvWriter.AddEntry(sourceValues[i]); } csvWriter.NewLine(); csvWriter.AddEntry("Pr(Hazard)"); for (var i = 0; i < steps; i++) { csvWriter.AddEntry(resultValues[i]); } csvWriter.NewLine(); fileWriter.Close(); }