Exemple #1
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="createModel">Creates the model that should be checked.</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 ModelTraverser(AnalysisModelCreator createModel, AnalysisConfiguration configuration, int transitionSize, bool createStutteringState)
        {
            Requires.NotNull(createModel, nameof(createModel));
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            TransitionCollection.ValidateTransitionSizes();

            var tasks  = new Task[configuration.CpuCount];
            var stacks = new StateStack[configuration.CpuCount];

            _loadBalancer = new LoadBalancer(stacks);
            Context       = new TraversalContext(_loadBalancer, configuration);
            _workers      = new Worker[configuration.CpuCount];

            for (var i = 0; i < configuration.CpuCount; ++i)
            {
                var index = i;
                tasks[i] = Task.Factory.StartNew(() =>
                {
                    stacks[index]   = new StateStack(configuration.StackCapacity);
                    _workers[index] = new Worker(index, Context, stacks[index], createModel.Create());
                });
            }

            Task.WaitAll(tasks);

            var firstModel = _workers[0].Model;

            if (transitionSize == DeriveTransitionSizeFromModel)
            {
                transitionSize = firstModel.TransitionSize;
            }

            if (configuration.WriteStateVectorLayout)
            {
                firstModel.WriteStateVectorLayout(configuration.DefaultTraceOutput);
            }

            var modelCapacity = configuration.ModelCapacity.DeriveModelByteSize(firstModel.ModelStateVectorSize, transitionSize);

            Context.ModelCapacity = modelCapacity;
            if (configuration.UseCompactStateStorage)
            {
                _states = new CompactStateStorage(modelCapacity.SizeOfState, modelCapacity.NumberOfStates);
            }
            else
            {
                _states = new SparseStateStorage(modelCapacity.SizeOfState, modelCapacity.NumberOfStates);
            }
            Context.States = _states;
            if (createStutteringState)
            {
                Context.StutteringStateIndex = _states.ReserveStateIndex();
            }
            _initializationTime = stopwatch.Elapsed;
            stopwatch.Stop();
        }
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="loadBalancer">The load balancer that balances the work of multiple <see cref="Worker" /> instances.</param>
        /// <param name="configuration">The configuration values for the analysis.</param>
        /// <param name="modelCapacity">The necessary memory for the state space of a model.</param>
        public TraversalContext(LoadBalancer loadBalancer, AnalysisConfiguration configuration)
        {
            Requires.NotNull(loadBalancer, nameof(loadBalancer));

            LoadBalancer  = loadBalancer;
            Configuration = configuration;
            Output        = Configuration.DefaultTraceOutput;

            Reset();
        }
Exemple #3
0
        /// <summary>
        /// </summary>
        /// <param name="configuration">The analysis configuration that should be used.</param>
        public void Calculate(AnalysisConfiguration configuration)
        {
            Assert.That(!_finished, $"{nameof(Calculate)} may only be called once");
            _finished      = true;
            _configuration = configuration;

            AddStateFormulasToCheckInBaseModel();
            AddDeepestOnceFormulas();
            AddTerminateEarlyFormula();
        }
Exemple #4
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="loadBalancer">The load balancer that balances the work of multiple <see cref="Worker" /> instances.</param>
        /// <param name="configuration">The configuration values for the analysis.</param>
        /// <param name="output">The action that should be invoked when output is generated.</param>
        /// <param name="modelCapacity">The necessary memory for the state space of a model.</param>
        public TraversalContext(LoadBalancer loadBalancer, AnalysisConfiguration configuration, Action <string> output)
        {
            Requires.NotNull(loadBalancer, nameof(loadBalancer));
            Requires.NotNull(output, nameof(output));

            LoadBalancer  = loadBalancer;
            Configuration = configuration;
            Output        = output;

            Reset();
        }
Exemple #5
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="createModel">Creates the model that should be checked.</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 ModelTraverser(AnalysisModelCreator <TExecutableModel> createModel, Action <string> output, AnalysisConfiguration configuration, int transitionSize)
        {
            Requires.NotNull(createModel, nameof(createModel));
            Requires.NotNull(output, nameof(output));
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            TransitionCollection.ValidateTransitionSizes();

            var tasks  = new Task[configuration.CpuCount];
            var stacks = new StateStack[configuration.CpuCount];

            _loadBalancer = new LoadBalancer(stacks);
            Context       = new TraversalContext <TExecutableModel>(_loadBalancer, configuration, output);
            _workers      = new Worker <TExecutableModel> [configuration.CpuCount];

            for (var i = 0; i < configuration.CpuCount; ++i)
            {
                var index = i;
                tasks[i] = Task.Factory.StartNew(() =>
                {
                    stacks[index]   = new StateStack(configuration.StackCapacity);
                    _workers[index] = new Worker <TExecutableModel>(index, Context, stacks[index], createModel.Create());
                });
            }

            Task.WaitAll(tasks);

            var firstModel = _workers[0].Model;

            if (transitionSize == DeriveTransitionSizeFromModel)
            {
                transitionSize = firstModel.TransitionSize;
            }

            var modelCapacity = configuration.ModelCapacity.DeriveModelByteSize(firstModel.StateVectorSize, transitionSize);

            Context.ModelCapacity = modelCapacity;
            _states        = new StateStorage(modelCapacity.SizeOfState, modelCapacity.NumberOfStates);
            Context.States = _states;
            Context.StutteringStateIndex = _states.ReserveStateIndex();
            _initializationTime          = stopwatch.Elapsed;
            stopwatch.Stop();
        }