public void StepwiseProbablityOfNotLabel1UntilLabel2ForExample4()
        {
            var example = new Example4();
            var ltmc    = example.Ltmc;

            var results = new List <Probability>();

            using (var prismChecker = new BuiltinLtmcModelChecker(ltmc, Output.TextWriterAdapter()))
            {
                for (var i = 0; i <= 10; i++)
                {
                    var boundedStepi       = new BoundedBinaryFormula(new UnaryFormula(LabeledTransitionMarkovChainExample.Label1Formula, UnaryOperator.Not), BinaryOperator.Until, LabeledTransitionMarkovChainExample.Label2Formula, i);
                    var resultBoundedStepi = prismChecker.CalculateProbability(boundedStepi);
                    Output.Log($"Result {i}:\t{resultBoundedStepi}");
                    results.Add(resultBoundedStepi);
                }

                var boundedStep200       = new BoundedBinaryFormula(new UnaryFormula(LabeledTransitionMarkovChainExample.Label1Formula, UnaryOperator.Not), BinaryOperator.Until, LabeledTransitionMarkovChainExample.Label2Formula, 200);
                var resultBoundedStep200 = prismChecker.CalculateProbability(boundedStep200);
                Output.Log($"Result {200}:\t{resultBoundedStep200}");

                /*
                 * var inf = new BinaryFormula(new UnaryFormula(LabeledTransitionMarkovChainExample.Label1Formula, UnaryOperator.Not), BinaryOperator.Until, LabeledTransitionMarkovChainExample.Label2Formula);
                 * var resultInf = prismChecker.CalculateProbability(inf);
                 * Output.Log($"Result inf:\t{resultInf}");
                 */
            }
        }
예제 #2
0
        public void TankRupture()
        {
            Formula invariant = new LustrePressureBelowThreshold();
            Formula hazard    = new UnaryFormula(invariant, UnaryOperator.Not);

            LustrePressureBelowThreshold.threshold = 60;
            var faults = new List <Fault>
            {
                new TransientFault()
                {
                    Name = "fault_switch", Identifier = 0, ProbabilityOfOccurrence = new Probability(3.0E-6)
                },
                new PermanentFault()
                {
                    Name = "fault_k1", Identifier = 1, ProbabilityOfOccurrence = new Probability(3.0E-6)
                },
                new PermanentFault()
                {
                    Name = "fault_k2", Identifier = 2, ProbabilityOfOccurrence = new Probability(3.0E-6)
                },
                new PermanentFault()
                {
                    Name = "fault_timer", Identifier = 3, ProbabilityOfOccurrence = new Probability(1.0E-5)
                },
                new PermanentFault()
                {
                    Name = "fault_sensor", Identifier = 4, ProbabilityOfOccurrence = new Probability(1.0E-5)
                }
            };
            var modelChecker = new LustreMarkovChainFromExecutableModelGenerator(Path.Combine(AssemblyDirectory, "pressureTank.lus"), "TANK", faults);

            modelChecker.AddFormulaToCheck(hazard);
            modelChecker.Configuration.UseCompactStateStorage = true;
            var lmc = modelChecker.GenerateLabeledMarkovChain();

            var ltmcModelChecker = new BuiltinLtmcModelChecker(lmc, Console.Out);
            var finallyHazard    = new BoundedUnaryFormula(hazard, UnaryOperator.Finally, 200);
            var result           = ltmcModelChecker.CalculateProbability(finallyHazard);

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