/// <summary>
        ///   Calculates the probability of formula.
        /// </summary>
        /// <param name="model">The model that should be checked.</param>
        /// <param name="formula">The state formula to be checked.</param>
        /// <param name="terminateEarlyFormula">When terminateEarlyFormula is satisfied stop building the state space.</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 CalculateProbabilityRangeOfFormulaBounded(ModelBase model, Formula formula, Formula terminateEarlyFormula, int bound)
        {
            ProbabilityRange probabilityRangeToReachState;

            var createModel = SafetySharpRuntimeModel.CreateExecutedModelFromFormulasCreator(model);

            var nmdpGenerator = new NmdpFromExecutableModelGenerator <SafetySharpRuntimeModel>(createModel)
            {
                Configuration = TraversalConfiguration
            };

            nmdpGenerator.AddFormulaToCheck(formula);
            var nmdp = nmdpGenerator.GenerateMarkovDecisionProcess(terminateEarlyFormula);


            if (_convertNmdpToMdp)
            {
                var nmdpToMpd = new NmdpToMdp(nmdp);
                var mdp       = nmdpToMpd.MarkovDecisionProcess;
                using (var modelChecker = new BuiltinMdpModelChecker(mdp, System.Console.Out))
                {
                    probabilityRangeToReachState = modelChecker.CalculateProbabilityRange(formula);
                }
            }
            else
            {
                using (var modelChecker = new BuiltinNmdpModelChecker(nmdp, System.Console.Out))
                {
                    probabilityRangeToReachState = modelChecker.CalculateProbabilityRange(formula);
                }
            }
            return(probabilityRangeToReachState);
        }
        public void MaximalProbabilityToReachIn50Steps_Label1(NestedMarkovDecisionProcessExample example)
        {
            var nmdp  = example.Nmdp;
            var steps = 50;

            var finallyLabel1 = new BoundedUnaryFormula(NestedMarkovDecisionProcessExample.Label1Formula, UnaryOperator.Finally, steps);

            using (var checker = new BuiltinNmdpModelChecker(nmdp, Output.TextWriterAdapter()))
            {
                var result = checker.CalculateMaximalProbability(finallyLabel1);
                result.Is(example.MaximalProbabilityFinallyLabel1, 0.0001).ShouldBe(true);
            }
        }
        /// <summary>
        ///   Calculates the probability to reach a state where <paramref name="stateFormula" /> holds.
        /// </summary>
        /// <param name="model">The model that should be checked.</param>
        /// <param name="stateFormula">The state formula which _must_ finally be true.</param>
        public static ProbabilityRange CalculateProbabilityRangeToReachState(ModelBase model, Formula stateFormula)
        {
            ProbabilityRange probabilityRangeToReachState;

            var probabilityToReachStateFormula = new UnaryFormula(stateFormula, UnaryOperator.Finally);

            var createModel = SafetySharpRuntimeModel.CreateExecutedModelFromFormulasCreator(model);

            var nmdpGenerator = new NmdpFromExecutableModelGenerator <SafetySharpRuntimeModel>(createModel)
            {
                Configuration = TraversalConfiguration
            };

            nmdpGenerator.AddFormulaToCheck(probabilityToReachStateFormula);
            nmdpGenerator.Configuration.SuccessorCapacity *= 8;
            var nmdp = nmdpGenerator.GenerateMarkovDecisionProcess(stateFormula);

            if (_convertNmdpToMdp)
            {
                var nmdpToMpd = new NmdpToMdp(nmdp);
                var mdp       = nmdpToMpd.MarkovDecisionProcess;
                using (var modelChecker = new BuiltinMdpModelChecker(mdp, System.Console.Out))
                {
                    probabilityRangeToReachState = modelChecker.CalculateProbabilityRange(probabilityToReachStateFormula);
                }
            }
            else
            {
                using (var modelChecker = new BuiltinNmdpModelChecker(nmdp, System.Console.Out))
                {
                    probabilityRangeToReachState = modelChecker.CalculateProbabilityRange(probabilityToReachStateFormula);
                }
            }

            return(probabilityRangeToReachState);
        }