/// <summary> /// Generates a <see cref="LabeledTransitionMarkovDecisionProcess" /> for the model created by <paramref name="createModel" />. /// </summary> /// <param name="createModel">Creates the model that should be checked.</param> internal LabeledTransitionMarkovDecisionProcess GenerateLtmdp(AnalysisModelCreator createModel) { using (var modelTraverser = new ModelTraverser(createModel, Configuration, LabeledTransitionMarkovDecisionProcess.TransitionSize, FormulaManager.NeedsStutteringState)) { _mdp = new LabeledTransitionMarkovDecisionProcess(modelTraverser.Context.ModelCapacity.NumberOfStates, modelTraverser.Context.ModelCapacity.NumberOfTransitions); _mdp.StateFormulaLabels = FormulaManager.FinalStateFormulaLabels.ToArray(); if (FormulaManager.NeedsStutteringState) { _mdp.CreateStutteringState(modelTraverser.Context.StutteringStateIndex); } modelTraverser.Context.TraversalParameters.TransitionModifiers.AddRange(FormulaManager.TransitionModifierGenerators); modelTraverser.Context.TraversalParameters.BatchedTransitionActions.Add(() => new LabeledTransitionMarkovDecisionProcess.LtmdpBuilderDuringTraversal(_mdp)); modelTraverser.Context.Output.WriteLine("Generating labeled transition markov decision process."); modelTraverser.TraverseModelAndReport(); // StateStorage must be freed manually. Reason is that invariant checker does not free up the // space, because it might be necessary for other usages of the ModelTraversers (e.g. StateGraphGenerator // which keeps the States for the StateGraph) modelTraverser.Context.States.SafeDispose(); } if (Configuration.WriteGraphvizModels) { FormulaManager.PrintStateFormulas(FormulaManager.FinalStateFormulas, Configuration.DefaultTraceOutput); Configuration.DefaultTraceOutput.WriteLine("Ltmdp Model"); _mdp.ExportToGv(Configuration.DefaultTraceOutput); } return(_mdp); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="createModel">Creates the model that should be checked.</param> /// <param name="configuration">The analysis configuration that should be used.</param> /// <param name="stateFormula">The analyzed stateFormula.</param> internal InvariantChecker(AnalysisModelCreator createModel, AnalysisConfiguration configuration, Formula stateFormula) { ModelTraverser = new ModelTraverser(createModel, configuration, 0, false); var formulasToCheck = ModelTraverser.AnalyzedModels.First().Formulas; ModelTraverser.Context.TraversalParameters.TransitionActions.Add(() => new InvariantViolationAction(formulasToCheck, stateFormula)); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="createModel">Creates the model that should be checked.</param> /// <param name="configuration">The analysis configuration that should be used.</param> internal StateGraphGenerator(AnalysisModelCreator createModel, AnalysisConfiguration configuration) { _modelTraverser = new ModelTraverser(createModel, configuration, ModelTraverser.DeriveTransitionSizeFromModel, false); var analyzedModel = _modelTraverser.AnalyzedModels.OfType <ExecutedModel <TExecutableModel> >().First(); _stateGraph = new StateGraph <TExecutableModel>( _modelTraverser.Context, analyzedModel.TransitionSize, analyzedModel.RuntimeModel, analyzedModel.RuntimeModelCreator); _modelTraverser.Context.TraversalParameters.BatchedTransitionActions.Add(() => new StateGraphBuilder <TExecutableModel>(_stateGraph)); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="createModel">Creates the model that should be checked.</param> /// <param name="configuration">The analysis configuration that should be used.</param> /// <param name="formulaIndex">The zero-based index of the analyzed formula.</param> internal InvariantChecker(AnalysisModelCreator createModel, AnalysisConfiguration configuration, int formulaIndex) { ModelTraverser = new ModelTraverser(createModel, configuration, 0, false); ModelTraverser.Context.TraversalParameters.TransitionActions.Add(() => new InvariantViolationByIndexAction(formulaIndex)); }