private void Check(AnalysisConfiguration configuration)
        {
            var         m = new Model();
            Probability minProbabilityOfFinal2;
            Probability minProbabilityOfFinal3;
            Probability maxProbabilityOfFinal2;
            Probability maxProbabilityOfFinal3;

            var final2 = new UnaryFormula(new SimpleStateInRangeFormula(2), UnaryOperator.Finally);
            var final3 = new UnaryFormula(new SimpleStateInRangeFormula(3), UnaryOperator.Finally);

            var mdpGenerator = new SimpleMarkovDecisionProcessFromExecutableModelGenerator(m);

            mdpGenerator.Configuration = configuration;
            mdpGenerator.AddFormulaToCheck(final2);
            mdpGenerator.AddFormulaToCheck(final3);
            var mdp          = mdpGenerator.GenerateLabeledTransitionMarkovDecisionProcess();
            var modelChecker = new ConfigurationDependentLtmdpModelChecker(configuration, mdp, Output.TextWriterAdapter());

            using (modelChecker)
            {
                minProbabilityOfFinal2 = modelChecker.CalculateMinimalProbability(final2);
                minProbabilityOfFinal3 = modelChecker.CalculateMinimalProbability(final3);
                maxProbabilityOfFinal2 = modelChecker.CalculateMaximalProbability(final2);
                maxProbabilityOfFinal3 = modelChecker.CalculateMaximalProbability(final3);
            }

            minProbabilityOfFinal2.Is(0.3, tolerance: 0.0001).ShouldBe(true);
            minProbabilityOfFinal3.Is(0.6, tolerance: 0.0001).ShouldBe(true);
            maxProbabilityOfFinal2.Is(0.3, tolerance: 0.0001).ShouldBe(true);
            maxProbabilityOfFinal3.Is(0.6, tolerance: 0.0001).ShouldBe(true);
        }
Exemple #2
0
        private void Check(AnalysisConfiguration configuration)
        {
            var         m = new Model();
            Probability probabilityOfFinal100;
            Probability probabilityOfFinal200;

            var final100Formula = new BoundedUnaryFormula(Model.StateIs100, UnaryOperator.Finally, 5);
            var final200Formula = new BoundedUnaryFormula(Model.StateIs200, UnaryOperator.Finally, 5);

            var mdpGenerator = new SimpleMarkovDecisionProcessFromExecutableModelGenerator(m);

            mdpGenerator.Configuration = configuration;
            mdpGenerator.AddFormulaToCheck(final100Formula);
            mdpGenerator.AddFormulaToCheck(final200Formula);
            var mdp          = mdpGenerator.GenerateLabeledTransitionMarkovDecisionProcess();
            var modelChecker = new ConfigurationDependentLtmdpModelChecker(configuration, mdp, Output.TextWriterAdapter());

            using (modelChecker)
            {
                probabilityOfFinal100 = modelChecker.CalculateMinimalProbability(final100Formula);
                probabilityOfFinal200 = modelChecker.CalculateMinimalProbability(final200Formula);
            }

            probabilityOfFinal100.Is(0.6 * 0.8, 0.000001).ShouldBe(true);
            probabilityOfFinal200.Is(0.4 + 0.6 * 0.2, 0.000001).ShouldBe(true);
        }
        private void CheckBounded(AnalysisConfiguration configuration)
        {
            var         m = new SharedModels.SimpleExample2a();
            Probability minProbabilityOfFinal0;
            Probability minProbabilityOfFinal0Lt;
            Probability minProbabilityOfFinal1;
            Probability minProbabilityOfFinal2;
            Probability maxProbabilityOfFinal0;
            Probability maxProbabilityOfFinal0Lt;
            Probability maxProbabilityOfFinal1;
            Probability maxProbabilityOfFinal2;

            var final0Formula   = new BoundedUnaryFormula(SharedModels.SimpleExample2a.StateIs0, UnaryOperator.Finally, 4);
            var final0LtFormula =
                new BoundedUnaryFormula(
                    new BinaryFormula(SharedModels.SimpleExample2a.StateIs0, BinaryOperator.And, SharedModels.SimpleExample2a.LocalVarIsTrue),
                    UnaryOperator.Finally, 4);
            var final1Formula = new BoundedUnaryFormula(SharedModels.SimpleExample2a.StateIs1, UnaryOperator.Finally, 4);
            var final2Formula = new BoundedUnaryFormula(SharedModels.SimpleExample2a.StateIs2, UnaryOperator.Finally, 4);

            var mdpGenerator = new SimpleMarkovDecisionProcessFromExecutableModelGenerator(m);

            mdpGenerator.Configuration = configuration;
            mdpGenerator.AddFormulaToCheck(final0Formula);
            mdpGenerator.AddFormulaToCheck(final0LtFormula);
            mdpGenerator.AddFormulaToCheck(final1Formula);
            mdpGenerator.AddFormulaToCheck(final2Formula);
            var mdp          = mdpGenerator.GenerateLabeledTransitionMarkovDecisionProcess();
            var modelChecker = new ConfigurationDependentLtmdpModelChecker(configuration, mdp, Output.TextWriterAdapter());

            using (modelChecker)
            {
                minProbabilityOfFinal0   = modelChecker.CalculateMinimalProbability(final0Formula);
                minProbabilityOfFinal0Lt = modelChecker.CalculateMinimalProbability(final0LtFormula);
                minProbabilityOfFinal1   = modelChecker.CalculateMinimalProbability(final1Formula);
                minProbabilityOfFinal2   = modelChecker.CalculateMinimalProbability(final2Formula);
                maxProbabilityOfFinal0   = modelChecker.CalculateMaximalProbability(final0Formula);
                maxProbabilityOfFinal0Lt = modelChecker.CalculateMaximalProbability(final0LtFormula);
                maxProbabilityOfFinal1   = modelChecker.CalculateMaximalProbability(final1Formula);
                maxProbabilityOfFinal2   = modelChecker.CalculateMaximalProbability(final2Formula);
            }

            minProbabilityOfFinal0.Is(1.0, 0.000001).ShouldBe(true);
            minProbabilityOfFinal0Lt.Is(0.0, 0.000001).ShouldBe(true);
            minProbabilityOfFinal1.Is(0.0, 0.000001).ShouldBe(true);
            minProbabilityOfFinal2.Is(0.0, 0.000001).ShouldBe(true);
            maxProbabilityOfFinal0.Is(1.0, 0.000001).ShouldBe(true);
            maxProbabilityOfFinal0Lt.Is(1.0, 0.000001).ShouldBe(true);
            var maxProbabilityOf1And2Calculated = 1.0 - Math.Pow(0.6, 4);

            maxProbabilityOfFinal1.Is(maxProbabilityOf1And2Calculated, 0.000001).ShouldBe(true);
            maxProbabilityOfFinal2.Is(maxProbabilityOf1And2Calculated, 0.000001).ShouldBe(true);
        }
Exemple #4
0
        private void CheckSmallerEqualTwo(AnalysisConfiguration configuration)
        {
            var         m = new Model();
            Probability minProbabilityOfFinalSmallerEqual2;
            Probability maxProbabilityOfFinalSmallerEqual2;

            var finalSmallerEqual2Formula = new BoundedUnaryFormula(new SimpleStateInRangeFormula(0, 2), UnaryOperator.Finally, 5);

            var mdpGenerator = new SimpleMarkovDecisionProcessFromExecutableModelGenerator(m);

            mdpGenerator.Configuration = configuration;
            mdpGenerator.AddFormulaToCheck(finalSmallerEqual2Formula);
            var mdp          = mdpGenerator.GenerateLabeledTransitionMarkovDecisionProcess();
            var modelChecker = new ConfigurationDependentLtmdpModelChecker(configuration, mdp, Output.TextWriterAdapter());

            using (modelChecker)
            {
                minProbabilityOfFinalSmallerEqual2 = modelChecker.CalculateMinimalProbability(finalSmallerEqual2Formula);
                maxProbabilityOfFinalSmallerEqual2 = modelChecker.CalculateMaximalProbability(finalSmallerEqual2Formula);
            }
        }