/// <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; }
/// <summary> /// Creates a counter example from the <paramref name="path" />. /// </summary> /// <param name="createModel">The factory function that can be used to create new instances of this model.</param> /// <param name="path"> /// The path the counter example should be generated from. A value of <c>null</c> indicates that no /// transitions could be generated for the model. /// </param> /// <param name="endsWithException">Indicates whether the counter example ends with an exception.</param> public CounterExample CreateCounterExample(CoupledExecutableModelCreator <TExecutableModel> createModel, byte[][] path, bool endsWithException) { Requires.NotNull(createModel, nameof(createModel)); // We have to create new model instances to generate and initialize the counter example, otherwise hidden // state variables might prevent us from doing so if they somehow influence the state var replayModel = createModel.Create(StateHeaderBytes); var choiceResolver = new NondeterministicChoiceResolver(true); replayModel.SetChoiceResolver(choiceResolver); CopyFaultActivationStates(replayModel); var faultActivations = Faults.Select(fault => fault.Activation).ToArray(); // Prepend the construction state to the path; if the path is null, at least one further state must be added // to enable counter example debugging. // Also, get the replay information, i.e., the nondeterministic choices that were made on the path; if the path is null, // we still have to get the choices that caused the problem. if (path == null) { path = new[] { new byte[StateVectorSize] } } ; path = new[] { ConstructionState }.Concat(path).ToArray(); var replayInfo = replayModel.GenerateReplayInformation(choiceResolver, path, endsWithException); return(new CounterExample(path, replayInfo, endsWithException, faultActivations)); }
/// <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="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; }