Beispiel #1
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="createModel">A factory function that creates the model instance that should be executed.</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 ExecutedModel(CoupledExecutableModelCreator <TExecutableModel> createModel, int stateHeaderBytes)
        {
            Requires.NotNull(createModel, nameof(createModel));

            RuntimeModelCreator = createModel;
            RuntimeModel        = createModel.Create(stateHeaderBytes);
        }
 public static ExecutableCounterExample <TExecutableModel> ExecutableCounterExample <TExecutableModel>(this InvariantAnalysisResult result, CoupledExecutableModelCreator <TExecutableModel> modelCreator) where TExecutableModel : ExecutableModel <TExecutableModel>
 {
     if (result.CounterExample != null)
     {
         return(new ExecutableCounterExample <TExecutableModel>(modelCreator.Create(0), result.CounterExample));
     }
     return(null);
 }
Beispiel #3
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="createModel">A factory function that creates the model instance that should be executed.</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 ExecutedModel(CoupledExecutableModelCreator <TExecutableModel> createModel, int stateHeaderBytes, AnalysisConfiguration configuration)
        {
            Requires.NotNull(createModel, nameof(createModel));

            RuntimeModelCreator   = createModel;
            RuntimeModel          = createModel.Create(stateHeaderBytes);
            TemporaryStateStorage = new TemporaryStateStorage(ModelStateVectorSize, configuration.SuccessorCapacity);
        }
Beispiel #4
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="counterExample">The counter example that should be simulated.</param>
        public Simulator(CoupledExecutableModelCreator <TExecutableModel> modelCreator, CounterExample counterExample)
        {
            Requires.NotNull(counterExample, nameof(counterExample));

            RuntimeModel    = modelCreator.Create(0);
            _counterExample = new ExecutableCounterExample <TExecutableModel>(RuntimeModel, counterExample);

            Reset();
        }
Beispiel #5
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="createModel">A factory function that creates the model instance that should be executed.</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 ExecutedModel(CoupledExecutableModelCreator <TExecutableModel> createModel, int stateHeaderBytes, AnalysisConfiguration configuration)
        {
            Requires.NotNull(createModel, nameof(createModel));

            RuntimeModelCreator = createModel;
            var runtimeModel = createModel.Create(stateHeaderBytes);

            RuntimeModel = runtimeModel;

            TemporaryStateStorage = new TemporaryStateStorage(ModelStateVectorSize, configuration.SuccessorCapacity);
            SavedActivations      = runtimeModel.NondeterministicFaults.Select(fault => fault.Activation).ToArray();
        }
        public static SafetySharpInvariantAnalysisResult FromInvariantAnalysisResult(InvariantAnalysisResult result, CoupledExecutableModelCreator <SafetySharpRuntimeModel> modelCreator)
        {
            var executableModel          = modelCreator?.Create(0);
            var executableCounterExample = executableModel != null && result.CounterExample != null
                                ? new ExecutableCounterExample <SafetySharpRuntimeModel>(executableModel, result.CounterExample)
                                : null;
            var enhancedResult = new SafetySharpInvariantAnalysisResult
            {
                CounterExample           = result.CounterExample,
                ExecutableCounterExample = executableCounterExample,
                FormulaHolds             = result.FormulaHolds,
                StateCount              = result.StateCount,
                TransitionCount         = result.TransitionCount,
                ComputedTransitionCount = result.TransitionCount,
                LevelCount              = result.LevelCount,
            };

            return(enhancedResult);
        }