예제 #1
0
파일: Model2.cs 프로젝트: gobo7793/ssharp
        public void Simulate()
        {
            var model = new ExampleModelBase();

            var tc = SafetySharpModelChecker.TraversalConfiguration;

            tc.AllowFaultsOnInitialTransitions              = false;
            tc.UseOptionProbabilitiesInSimulation           = false;
            SafetySharpProbabilisticSimulator.Configuration = tc;

            var is3Formula            = new ExecutableStateFormula(() => model.ModelComponent.Value == 3);
            var f1Formula             = new FaultFormula(model.ModelComponent.F1);
            var loopRequestBugFormula = new ExecutableStateFormula(() => model.ModelComponent.LoopRequestBug);

            SafetySharpProbabilisticSimulator simulator = new SafetySharpProbabilisticSimulator(model, is3Formula, f1Formula, loopRequestBugFormula);

            for (var i = 0; i < 100; i++)
            {
                simulator.SimulateSteps(5);
                var noIs3 = simulator.GetCountOfSatisfiedOnTrace(is3Formula);
                var noF1  = simulator.GetCountOfSatisfiedOnTrace(f1Formula);
                var probabilityOfTrace = simulator.TraceProbability;
                Console.WriteLine($"No of Is3: {noIs3}");
                Console.WriteLine($"No of f1 {noF1}: {noF1}");
                Console.WriteLine($"Probability of trace: {probabilityOfTrace}");
                Console.WriteLine();
            }
        }
예제 #2
0
        public void CalculateProbability()
        {
            var model = new ExampleModelBase();

            var result = SafetySharpModelChecker.CalculateProbabilityToReachStateBounded(model, model.ModelComponent.Value == 3, 50);

            Console.Write($"Probability of hazard: {result}");
        }
예제 #3
0
        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.ModelComponent.Value == 3);
            //result.SaveCounterExamples("counter examples/height control/dcca/collision/original");

            var orderResult = SafetySharpOrderAnalysis.ComputeOrderRelationships(result);

            Console.WriteLine(orderResult);
        }
예제 #4
0
        public void CalculateProbability()
        {
            var model = new ExampleModelBase();

            var tc = SafetySharpModelChecker.TraversalConfiguration;

            tc.WriteGraphvizModels                         = true;
            tc.AllowFaultsOnInitialTransitions             = false;
            tc.UseAtomarPropositionsAsStateLabels          = true;
            tc.UseCompactStateStorage                      = true;
            SafetySharpModelChecker.TraversalConfiguration = tc;

            var result = SafetySharpModelChecker.CalculateProbabilityToReachStateBounded(model, model.ModelComponent.Value == 3, 50);

            Console.Write($"Probability of hazard: {result}");

            var is3Formula                 = new ExecutableStateFormula(() => model.ModelComponent.Value == 3);
            var loopRequestBug             = new ExecutableStateFormula(() => model.ModelComponent.LoopRequestBug);
            var formula2OnceLoopRequestBug = new BinaryFormula(is3Formula, BinaryOperator.And, new UnaryFormula(loopRequestBug, UnaryOperator.Once));
            var result2 = SafetySharpModelChecker.CalculateProbabilityToReachStateBounded(model, formula2OnceLoopRequestBug, 50);

            Console.WriteLine($"Probability of {formula2OnceLoopRequestBug}: {result2}");
        }