예제 #1
0
        private void InitializeFromSerializedModel()
        {
            var modelWithFormula = LustreModelSerializer.DeserializeFromByteArray(SerializedModel);

            Model    = modelWithFormula.Item1;
            Faults   = Model.Faults.Values.OrderBy(fault => fault.Identifier).ToArray();
            Formulas = modelWithFormula.Item2;

            var atomarPropositionVisitor = new CollectAtomarPropositionFormulasVisitor();

            _atomarPropositionFormulas = atomarPropositionVisitor.AtomarPropositionFormulas.ToArray();
            foreach (var stateFormula in Formulas)
            {
                atomarPropositionVisitor.Visit(stateFormula);
            }

            StateConstraints = new Func <bool> [0];

            UpdateFaultSets();

            _deserialize    = LustreModelSerializer.CreateFastInPlaceDeserializer(Model);
            _serialize      = LustreModelSerializer.CreateFastInPlaceSerializer(Model);
            _restrictRanges = () => { };

            InitializeConstructionState();
            CheckConsistencyAfterInitialization();
        }
예제 #2
0
        /// <summary>
        ///   Generates a <see cref="MarkovDecisionProcess" /> for the model created by <paramref name="createModel" />.
        /// </summary>
        public NestedMarkovDecisionProcess GenerateMarkovDecisionProcess(Formula terminateEarlyCondition = null)
        {
            Requires.That(IntPtr.Size == 8, "Model checking is only supported in 64bit processes.");

            ProbabilityMatrixCreationStarted = true;

            CollectStateFormulasVisitor stateFormulaCollector;

            if (Configuration.UseAtomarPropositionsAsStateLabels)
            {
                stateFormulaCollector = new CollectAtomarPropositionFormulasVisitor();
            }
            else
            {
                stateFormulaCollector = new CollectMaximalCompilableFormulasVisitor();
            }

            foreach (var stateFormula in _formulasToCheck)
            {
                stateFormulaCollector.VisitNewTopLevelFormula(stateFormula);
            }
            if (terminateEarlyCondition)
            {
                stateFormulaCollector.VisitNewTopLevelFormula(terminateEarlyCondition);
            }
            var stateFormulas = stateFormulaCollector.CollectedStateFormulas.ToArray();

            ExecutedModel <TExecutableModel> model = null;
            var modelCreator = _runtimeModelCreator.CreateCoupledModelCreator(stateFormulas);
            Func <AnalysisModel <TExecutableModel> > createAnalysisModelFunc = () =>
                                                                               model = new LtmdpExecutedModel <TExecutableModel>(modelCreator, 0, Configuration.SuccessorCapacity);
            var createAnalysisModel = new AnalysisModelCreator <TExecutableModel>(createAnalysisModelFunc);

            return(GenerateMarkovDecisionProcess(createAnalysisModel, terminateEarlyCondition, stateFormulas));
        }
예제 #3
0
        private void AddStateFormulasToCheckInBaseModel()
        {
            CollectStateFormulasVisitor stateFormulaCollector;

            if (_configuration.UseAtomarPropositionsAsStateLabels)
            {
                stateFormulaCollector = new CollectAtomarPropositionFormulasVisitor();
            }
            else
            {
                stateFormulaCollector = new CollectMaximalCompilableFormulasVisitor();
            }

            foreach (var stateFormula in _formulasToCheck)
            {
                stateFormulaCollector.VisitNewTopLevelFormula(stateFormula);
            }
            var stateFormulas = stateFormulaCollector.CollectedStateFormulas;

            foreach (var formula in stateFormulas)
            {
                _stateFormulasToCheckInBaseModel.Add(formula);

                _finalStateFormulas.Add(formula);
                _labelsOfKnownFormulas.Add(formula.Label);
            }
        }