public void StepwiseProbablityOfNotLabel1UntilLabel2ForExample4()
        {
            var example = new Example4();
            var dtmc    = example.MarkovChain;

            var results = new List <Probability>();

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

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

                /*
                 * var inf = new BinaryFormula(new UnaryFormula(MarkovChainExample.Label1Formula, UnaryOperator.Not), BinaryOperator.Until, MarkovChainExample.Label2Formula);
                 * var resultInf = prismChecker.CalculateProbability(inf);
                 * Output.Log($"Result inf:\t{resultInf}");
                 */
            }
        }
        public void ProbabilityIn10Steps_Label1UntilLabel2(MarkovChainExample example)
        {
            var dtmc = example.MarkovChain;

            var label1UntilLabel2 = new BoundedBinaryFormula(MarkovChainExample.Label1Formula, BinaryOperator.Until, MarkovChainExample.Label2Formula, 10);

            using (var prismChecker = new BuiltinDtmcModelChecker(dtmc, Output.TextWriterAdapter()))
            {
                var result = prismChecker.CalculateProbability(label1UntilLabel2);
                result.Is(example.ProbabilityLabel1UntilLabel2, 0.0001).ShouldBe(true);
            }
        }
Exemple #3
0
        protected override void Check()
        {
            var         c = new C();
            Probability probabilityOfFinal1;

            var final1Formula = new BoundedBinaryFormula(c.IsPhi(), BinaryOperator.Until, c.IsPsi(), 10);

            var markovChainGenerator = new SafetySharpMarkovChainFromExecutableModelGenerator(TestModel.InitializeModel(c));

            markovChainGenerator.Configuration.ModelCapacity    = ModelCapacityByMemorySize.Small;
            markovChainGenerator.Configuration.LtmcModelChecker = (ISSE.SafetyChecking.LtmcModelChecker)Arguments[0];
            markovChainGenerator.AddFormulaToCheck(final1Formula);
            var ltmc         = markovChainGenerator.GenerateLabeledMarkovChain();
            var modelChecker = new ConfigurationDependentLtmcModelChecker(markovChainGenerator.Configuration, ltmc, Output.TextWriterAdapter());

            using (modelChecker)
            {
                probabilityOfFinal1 = modelChecker.CalculateProbability(final1Formula);
            }

            probabilityOfFinal1.Is(0.2, 0.000001).ShouldBe(true);
        }
Exemple #4
0
        protected override void Check()
        {
            var         c = new C();
            Probability probabilityOfFinal1;

            var final1Formula = new BoundedBinaryFormula(c.IsPhi(), BinaryOperator.Until, c.IsPsi(), 10);

            var markovChainGenerator = new SafetySharpDtmcFromExecutableModelGenerator(TestModel.InitializeModel(c));

            markovChainGenerator.Configuration.ModelCapacity = ModelCapacityByMemorySize.Small;
            markovChainGenerator.AddFormulaToCheck(final1Formula);
            var dtmc = markovChainGenerator.GenerateMarkovChain();
            var typeOfModelChecker = (Type)Arguments[0];
            var modelChecker       = (DtmcModelChecker)Activator.CreateInstance(typeOfModelChecker, dtmc, Output.TextWriterAdapter());

            using (modelChecker)
            {
                probabilityOfFinal1 = modelChecker.CalculateProbability(final1Formula);
            }

            probabilityOfFinal1.Is(0.2, 0.000001).ShouldBe(true);
        }
Exemple #5
0
 /// <summary>
 ///   Visits the <paramref name="formula." />
 /// </summary>
 public abstract void VisitBoundedBinaryFormula(BoundedBinaryFormula formula);
 /// <summary>
 ///   Visits the <paramref name="formula." />
 /// </summary>
 public override void VisitBoundedBinaryFormula(BoundedBinaryFormula formula)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        ///   Calculates the probability to reach a state where <paramref name="stateFormula" /> holds and on its way
        ///   invariantFormula holds in every state, or more formally Pr[invariantFormula U stateFormula].
        /// </summary>
        /// <param name="model">The model that should be checked.</param>
        /// <param name="stateFormula">The state formula which _must_ finally be true.</param>
        /// <param name="invariantFormula">The state formulas which must hold until stateFormula is satisfied.</param>
        /// <param name="bound">The maximal number of steps. If stateFormula is satisfied the first time any step later than bound, this probability does not count into the end result.</param>
        public static ProbabilityRange CalculateProbabilityRangeToReachStateBounded(string ocFileName, string mainNode, IEnumerable <Fault> faults, Formula stateFormula, Formula invariantFormula, int bound)
        {
            var formula = new BoundedBinaryFormula(invariantFormula, BinaryOperator.Until, stateFormula, bound);

            return(CalculateProbabilityRangeOfFormula(ocFileName, mainNode, faults, formula));
        }
Exemple #8
0
 /// <summary>
 ///   Visits the <paramref name="formula." />
 /// </summary>
 public override void VisitBoundedBinaryFormula(BoundedBinaryFormula formula)
 {
     _containsInvalidOperators = true;
 }
        /// <summary>
        ///   Calculates the probability to reach a state where <paramref name="stateFormula" /> holds and on its way
        ///   invariantFormula holds in every state, or more formally Pr[invariantFormula U stateFormula].
        /// </summary>
        /// <param name="model">The model that should be checked.</param>
        /// <param name="stateFormula">The state formula which _must_ finally be true.</param>
        /// <param name="invariantFormula">The state formulas which must hold until stateFormula is satisfied.</param>
        /// <param name="bound">The maximal number of steps. If stateFormula is satisfied the first time any step later than bound, this probability does not count into the end result.</param>
        public static ProbabilityRange CalculateProbabilityRangeToReachStateBounded(ModelBase model, Formula stateFormula, Formula invariantFormula, int bound)
        {
            var formula = new BoundedBinaryFormula(invariantFormula, BinaryOperator.Until, stateFormula, bound);

            return(CalculateProbabilityRangeOfFormulaBounded(model, formula, stateFormula, bound));
        }