Esempio n. 1
0
        public void AddTerminateEarlyFormula()
        {
            if (!_configuration.EnableEarlyTermination)
            {
                return;
            }

            if (_formulasToCheck.Count != 1)
            {
                return;
            }

            var terminateEarlyFormula = ExtractTerminateEarlyFromFormula(_formulasToCheck.First());

            if (terminateEarlyFormula == null)
            {
                return;
            }

            NeedsStutteringState = true;

            // This method also succeeds with Once formulas, when those Once formulas have been normalized (i.e. a observeFormulasModifier exists)
            var terminateEarlyFunc = StateFormulaSetEvaluatorCompilationVisitor.Compile(FinalStateFormulaLabels.ToArray(), terminateEarlyFormula);

            _transitionModifierGenerators.Add(() => new EarlyTerminationModifier(terminateEarlyFunc));
        }
Esempio n. 2
0
        public Func <int, bool> CreateFormulaEvaluator(Formula formula)
        {
            var stateFormulaEvaluator  = StateFormulaSetEvaluatorCompilationVisitor.Compile(StateFormulaLabels, formula);
            Func <int, bool> evaluator = transitionTarget =>
            {
                var stateFormulaSet = _transitionTarget[transitionTarget].Formulas;
                return(stateFormulaEvaluator(stateFormulaSet));
            };

            return(evaluator);
        }
Esempio n. 3
0
        public Func <long, bool> CreateFormulaEvaluator(Formula formula)
        {
            var stateFormulaEvaluator   = StateFormulaSetEvaluatorCompilationVisitor.Compile(StateFormulaLabels, formula);
            Func <long, bool> evaluator = transitionTarget =>
            {
                Assert.That(transitionTarget < int.MaxValue, "need to exchange int by long");
                var stateFormulaSet = StateLabeling[(int)transitionTarget];
                return(stateFormulaEvaluator(stateFormulaSet));
            };

            return(evaluator);
        }
        public Func <long, bool> CreateFormulaEvaluator(Formula formula)
        {
            var stateFormulaEvaluator   = StateFormulaSetEvaluatorCompilationVisitor.Compile(StateFormulaLabels, formula);
            Func <long, bool> evaluator = transitionTarget =>
            {
                Requires.That(transitionTarget <= int.MaxValue, "MDP currently cannot handle more than int.MaxValue states");
                var stateFormulaSet = StateLabeling[(int)transitionTarget];
                return(stateFormulaEvaluator(stateFormulaSet));
            };

            return(evaluator);
        }
Esempio n. 5
0
        private Func <StateFormulaSet, bool> CreateEnrichmentEvaluator(Formula formulaToObserve, int indexOfFormulaToObserve)
        {
            var isCurrentlySatisfiedEvaluator =
                StateFormulaSetEvaluatorCompilationVisitor.Compile(_previousFormulaLabels, formulaToObserve);

            Func <StateFormulaSet, bool> enrichmentEvaluator =
                (oldStateFormulaSet) =>
            {
                var setNewBit = isCurrentlySatisfiedEvaluator(oldStateFormulaSet);
                return(setNewBit);
            };

            return(enrichmentEvaluator);
        }
Esempio n. 6
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="createModel">Creates the model that should be checked.</param>
        /// <param name="executableStateFormulas">The state formulas that can be evaluated over the generated state graph.</param>
        /// <param name="output">The callback that should be used to output messages.</param>
        /// <param name="configuration">The analysis configuration that should be used.</param>
        internal LtmdpGenerator(AnalysisModelCreator <TExecutableModel> createModel, Formula terminateEarlyCondition, Formula[] executableStateFormulas,
                                Action <string> output, AnalysisConfiguration configuration)
            : base(createModel, output, configuration, LabeledTransitionMarkovDecisionProcess.TransitionSize)
        {
            _mdp = new LabeledTransitionMarkovDecisionProcess(Context.ModelCapacity.NumberOfStates, Context.ModelCapacity.NumberOfTransitions);
            _mdp.StateFormulaLabels = executableStateFormulas.Select(stateFormula => stateFormula.Label).ToArray();

            Context.TraversalParameters.BatchedTransitionActions.Add(() => new LabeledTransitionMarkovDecisionProcess.LtmdpBuilderDuringTraversal <TExecutableModel>(_mdp, configuration));
            if (terminateEarlyCondition != null)
            {
                _mdp.CreateStutteringState(Context.StutteringStateIndex);
                var terminalteEarlyFunc = StateFormulaSetEvaluatorCompilationVisitor.Compile(_mdp.StateFormulaLabels, terminateEarlyCondition);
                Context.TraversalParameters.TransitionModifiers.Add(() => new EarlyTerminationModifier <TExecutableModel>(terminalteEarlyFunc));
            }
        }
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="formulasToCheck">Formulas which appear in the resulting state labeling.</param>
        /// <param name="formulaToCheck">The analyzed formula.</param>
        public InvariantViolationAction(Formula[] formulasToCheck, Formula formulaToCheck)
        {
            var formulaLabels = formulasToCheck.Select(formula => formula.Label).ToArray();

            _evaluator = StateFormulaSetEvaluatorCompilationVisitor.Compile(formulaLabels, formulaToCheck);
        }
Esempio n. 8
0
 private Func <StateFormulaSet, bool> CreateFormulaEvaluator(Formula formula)
 {
     return(StateFormulaSetEvaluatorCompilationVisitor.Compile(LabeledTransitionMarkovChain.StateFormulaLabels, formula));
 }