예제 #1
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="runtimeModelCreator">A factory function that creates the model instance that should be executed.</param>
        /// <param name="formulas">The formulas that should be evaluated for each state.</param>
        /// <param name="configuration">The analysis configuration that should be used.</param>
        /// <param name="stateHeaderBytes">
        ///   The number of bytes that should be reserved at the beginning of each state vector for the model checker tool.
        /// </param>
        internal ActivationMinimalExecutedModel(CoupledExecutableModelCreator <TExecutableModel> runtimeModelCreator, int stateHeaderBytes, Func <bool>[] formulas, AnalysisConfiguration configuration)
            : base(runtimeModelCreator, stateHeaderBytes, configuration)
        {
            formulas = formulas ?? RuntimeModel.Formulas.Select(formula => FormulaCompilationVisitor <TExecutableModel> .Compile(RuntimeModel, formula)).ToArray();

            _transitions      = new ActivationMinimalTransitionSetBuilder <TExecutableModel>(TemporaryStateStorage, configuration.SuccessorCapacity, formulas);
            _stateConstraints = RuntimeModel.StateConstraints;

            bool useForwardOptimization;

            switch (configuration.MomentOfIndependentFaultActivation)
            {
            case MomentOfIndependentFaultActivation.AtStepBeginning:
            case MomentOfIndependentFaultActivation.OnFirstMethodWithoutUndo:
                useForwardOptimization = false;
                break;

            case MomentOfIndependentFaultActivation.OnFirstMethodWithUndo:
                useForwardOptimization = true;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            ChoiceResolver = new NondeterministicChoiceResolver(useForwardOptimization);
            FaultSet.CheckFaultCount(RuntimeModel.Faults.Length);

            RuntimeModel.SetChoiceResolver(ChoiceResolver);

            _allowFaultsOnInitialTransitions = configuration.AllowFaultsOnInitialTransitions;
        }
예제 #2
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="runtimeModelCreator">A factory function that creates the model instance that should be executed.</param>
        /// <param name="configuration">The analysis configuration that should be used.</param>
        ///   The number of bytes that should be reserved at the beginning of each state vector for the model checker tool.
        /// </param>
        internal LtmdpExecutedModel(CoupledExecutableModelCreator <TExecutableModel> runtimeModelCreator, AnalysisConfiguration configuration)
            : base(runtimeModelCreator, 0, configuration)
        {
            var formulas = RuntimeModel.Formulas.Select(formula => FormulaCompilationVisitor <TExecutableModel> .Compile(RuntimeModel, formula)).ToArray();

            _stepGraph = new LtmdpStepGraph();

            _cachedLabeledStates = new LtmdpCachedLabeledStates <TExecutableModel>(TemporaryStateStorage, configuration.SuccessorCapacity, _stepGraph, formulas);

            bool useForwardOptimization;

            switch (configuration.MomentOfIndependentFaultActivation)
            {
            case MomentOfIndependentFaultActivation.AtStepBeginning:
            case MomentOfIndependentFaultActivation.OnFirstMethodWithoutUndo:
                useForwardOptimization = false;
                break;

            case MomentOfIndependentFaultActivation.OnFirstMethodWithUndo:
                useForwardOptimization = true;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            _ltmdpChoiceResolver = new LtmdpChoiceResolver(_stepGraph, useForwardOptimization);
            ChoiceResolver       = _ltmdpChoiceResolver;
            RuntimeModel.SetChoiceResolver(ChoiceResolver);

            _allowFaultsOnInitialTransitions = configuration.AllowFaultsOnInitialTransitions;

            _activateIndependentFaultsAtStepBeginning =
                configuration.MomentOfIndependentFaultActivation == MomentOfIndependentFaultActivation.AtStepBeginning;
        }
예제 #3
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="runtimeModelCreator">A factory function that creates the model instance that should be executed.</param>
        /// <param name="successorStateCapacity">The maximum number of successor states supported per state.</param>
        /// <param name="stateHeaderBytes">
        ///   The number of bytes that should be reserved at the beginning of each state vector for the model checker tool.
        /// </param>
        internal LtmcExecutedModel(CoupledExecutableModelCreator <TExecutableModel> runtimeModelCreator, int stateHeaderBytes, long successorStateCapacity)
            : base(runtimeModelCreator, stateHeaderBytes)
        {
            var formulas = RuntimeModel.Formulas.Select(formula => FormulaCompilationVisitor <TExecutableModel> .Compile(RuntimeModel, formula)).ToArray();

            _transitions = new LtmcTransitionSetBuilder <TExecutableModel>(RuntimeModel, successorStateCapacity, formulas);

            _ltmcChoiceResolver = new LtmcChoiceResolver();
            ChoiceResolver      = _ltmcChoiceResolver;
            RuntimeModel.SetChoiceResolver(ChoiceResolver);
        }
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="runtimeModelCreator">A factory function that creates the model instance that should be executed.</param>
        /// <param name="formulas">The formulas that should be evaluated for each state.</param>
        /// <param name="successorStateCapacity">The maximum number of successor states supported per state.</param>
        /// <param name="stateHeaderBytes">
        ///   The number of bytes that should be reserved at the beginning of each state vector for the model checker tool.
        /// </param>
        internal ActivationMinimalExecutedModel(CoupledExecutableModelCreator <TExecutableModel> runtimeModelCreator, int stateHeaderBytes, Func <bool>[] formulas, long successorStateCapacity)
            : base(runtimeModelCreator, stateHeaderBytes)
        {
            formulas = formulas ?? RuntimeModel.Formulas.Select(formula => FormulaCompilationVisitor <TExecutableModel> .Compile(RuntimeModel, formula)).ToArray();

            _transitions      = new ActivationMinimalTransitionSetBuilder <TExecutableModel>(RuntimeModel, successorStateCapacity, formulas);
            _stateConstraints = RuntimeModel.StateConstraints;

            ChoiceResolver = new NondeterministicChoiceResolver();

            RuntimeModel.SetChoiceResolver(ChoiceResolver);
        }
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="runtimeModelCreator">A factory function that creates the model instance that should be executed.</param>
        /// <param name="successorStateCapacity">The maximum number of successor states supported per state.</param>
        /// <param name="stateHeaderBytes">
        ///   The number of bytes that should be reserved at the beginning of each state vector for the model checker tool.
        /// </param>
        internal LtmdpExecutedModel(CoupledExecutableModelCreator <TExecutableModel> runtimeModelCreator, int stateHeaderBytes, long successorStateCapacity)
            : base(runtimeModelCreator, stateHeaderBytes)
        {
            var formulas = RuntimeModel.Formulas.Select(formula => FormulaCompilationVisitor <TExecutableModel> .Compile(RuntimeModel, formula)).ToArray();

            _stepGraph = new LtmdpStepGraph();

            _cachedLabeledStates = new LtmdpCachedLabeledStates <TExecutableModel>(RuntimeModel, successorStateCapacity, _stepGraph, formulas);

            _ltmdpChoiceResolver = new LtmdpChoiceResolver(_stepGraph);
            ChoiceResolver       = _ltmdpChoiceResolver;
            RuntimeModel.SetChoiceResolver(ChoiceResolver);
        }
예제 #6
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="runtimeModelCreator">A factory function that creates the model instance that should be executed.</param>
        /// <param name="configuration">The analysis configuration that should be used.</param>
        internal LtmcExecutedModel(CoupledExecutableModelCreator <TExecutableModel> runtimeModelCreator, AnalysisConfiguration configuration)
            : base(runtimeModelCreator, 0, configuration)
        {
            var formulas = RuntimeModel.Formulas.Select(formula => FormulaCompilationVisitor <TExecutableModel> .Compile(RuntimeModel, formula)).ToArray();

            _transitions = new LtmcTransitionSetBuilder <TExecutableModel>(TemporaryStateStorage, configuration.SuccessorCapacity, formulas);

            var useForwardOptimization = configuration.EnableStaticPruningOptimization;

            _ltmcChoiceResolver = new LtmcChoiceResolver(useForwardOptimization);
            ChoiceResolver      = _ltmcChoiceResolver;
            RuntimeModel.SetChoiceResolver(ChoiceResolver);

            _allowFaultsOnInitialTransitions = configuration.AllowFaultsOnInitialTransitions;
        }
예제 #7
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="runtimeModelCreator">A factory function that creates the model instance that should be executed.</param>
        /// <param name="formulas">The formulas that should be evaluated for each state.</param>
        /// <param name="configuration">The analysis configuration that should be used.</param>
        /// <param name="stateHeaderBytes">
        ///   The number of bytes that should be reserved at the beginning of each state vector for the model checker tool.
        /// </param>
        internal ActivationMinimalExecutedModel(CoupledExecutableModelCreator <TExecutableModel> runtimeModelCreator, int stateHeaderBytes, Func <bool>[] formulas, AnalysisConfiguration configuration)
            : base(runtimeModelCreator, stateHeaderBytes, configuration)
        {
            formulas = formulas ?? RuntimeModel.Formulas.Select(formula => FormulaCompilationVisitor <TExecutableModel> .Compile(RuntimeModel, formula)).ToArray();

            _transitions      = new ActivationMinimalTransitionSetBuilder <TExecutableModel>(TemporaryStateStorage, configuration.SuccessorCapacity, formulas);
            _stateConstraints = RuntimeModel.StateConstraints;

            var useForwardOptimization = configuration.EnableStaticPruningOptimization;

            ChoiceResolver = new NondeterministicChoiceResolver(useForwardOptimization);
            FaultSet.CheckFaultCount(RuntimeModel.Faults.Length);

            RuntimeModel.SetChoiceResolver(ChoiceResolver);

            _allowFaultsOnInitialTransitions = configuration.AllowFaultsOnInitialTransitions;
        }
예제 #8
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        public ProbabilisticSimulator(ExecutableModelCreator <TExecutableModel> modelCreator, IEnumerable <Formula> formulas, AnalysisConfiguration configuration)
        {
            // TODO: Set Mode WithCustomSeed (each thread must have its own seed) or RealRandom
            Requires.NotNull(modelCreator, nameof(modelCreator));

            RuntimeModel = modelCreator.CreateCoupledModelCreator(formulas.ToArray()).Create(0);

            NormalizedFormulas                 = RuntimeModel.Formulas.ToArray();
            NormalizedFormulaLabels            = NormalizedFormulas.Select(stateFormula => stateFormula.Label).ToArray();
            NormalizedFormulaSatisfactionCount = new int[NormalizedFormulas.Length];
            _compiledNormalizedFormulas        = NormalizedFormulas.Select(formula => FormulaCompilationVisitor <TExecutableModel> .Compile(RuntimeModel, formula)).ToArray();

            _allowFaultsOnInitialTransitions = configuration.AllowFaultsOnInitialTransitions;

            _activateIndependentFaultsAtStepBeginning =
                configuration.MomentOfIndependentFaultActivation == MomentOfIndependentFaultActivation.AtStepBeginning;

            _choiceResolver = new ProbabilisticSimulatorChoiceResolver(configuration.UseOptionProbabilitiesInSimulation, (int)DateTime.Now.Ticks);

            RuntimeModel.SetChoiceResolver(_choiceResolver);
        }