/// <summary> /// Initializes a new instance. /// </summary> /// <param name="model">The model the successors are computed for.</param> /// <param name="capacity">The maximum number of successors that can be cached.</param> /// <param name="formulas">The formulas that should be checked for all successor states.</param> public TransitionSet(RuntimeModel model, int capacity, params Func <bool>[] formulas) { Requires.NotNull(model, nameof(model)); Requires.NotNull(formulas, nameof(formulas)); Requires.That(formulas.Length < 32, "At most 32 formulas are supported."); Requires.That(capacity <= (1 << 30), nameof(capacity), $"Maximum supported capacity is {1 << 30}."); _stateVectorSize = model.StateVectorSize; _formulas = formulas; _transitionBuffer.Resize(capacity * sizeof(Transition), zeroMemory: false); _transitions = (Transition *)_transitionBuffer.Pointer; _targetStateBuffer.Resize(capacity * model.StateVectorSize, zeroMemory: true); _targetStateMemory = _targetStateBuffer.Pointer; _lookupBuffer.Resize(capacity * sizeof(int), zeroMemory: false); _faultsBuffer.Resize(capacity * sizeof(FaultSet), zeroMemory: false); _hashedStateBuffer.Resize(capacity * _stateVectorSize, zeroMemory: true); _successors = new List <uint>(capacity); _capacity = capacity; _lookup = (int *)_lookupBuffer.Pointer; _faults = (FaultSetInfo *)_faultsBuffer.Pointer; _hashedStateMemory = _hashedStateBuffer.Pointer; for (var i = 0; i < capacity; ++i) { _lookup[i] = -1; } }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="transitions">The transition instances stored in a contiguous array.</param> /// <param name="count">The number of transitions contained in the set; not all of these transitions are valid.</param> /// <param name="totalCount">The total number of all originally computed transitions.</param> /// <param name="transitionSize">The size of a single transition in bytes.</param> public TransitionCollection(Transition* transitions, int count, int totalCount, int transitionSize) { _transitions = transitions; _transitionSize = transitionSize; Count = count; TotalCount = totalCount; }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="transitions">The transition instances stored in a contiguous array.</param> /// <param name="count">The number of transitions contained in the set; not all of these transitions are valid.</param> /// <param name="transitionSize">The size of a single transition in bytes.</param> public TransitionEnumerator(Transition *transitions, int count, int transitionSize) : this() { _transitions = (byte *)transitions; _count = count; _transitionSize = transitionSize; _current = -1; }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="transitions">The transition instances stored in a contiguous array.</param> /// <param name="count">The number of transitions contained in the set; not all of these transitions are valid.</param> /// <param name="totalCount">The total number of all originally computed transitions.</param> /// <param name="transitionSize">The size of a single transition in bytes.</param> /// <param name="structuralInformation">Structural information about the transitions (needed for some but not all formalisms).</param> /// public TransitionCollection(Transition *transitions, int count, int totalCount, int transitionSize, object structuralInformation) { _transitions = transitions; _transitionSize = transitionSize; Count = count; TotalCount = totalCount; StructuralInformation = structuralInformation; }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="transitions">The transition instances stored in a contiguous array.</param> /// <param name="count">The number of transitions contained in the set; not all of these transitions are valid.</param> /// <param name="totalCount">The total number of all originally computed transitions.</param> /// <param name="transitionSize">The size of a single transition in bytes.</param> public TransitionCollection(Transition *transitions, int count, int totalCount, int transitionSize) : this(transitions, count, totalCount, transitionSize, null) { }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="transitions">The transition instances stored in a contiguous array.</param> /// <param name="count">The number of transitions contained in the set; not all of these transitions are valid.</param> /// <param name="transitionSize">The size of a single transition in bytes.</param> public TransitionCollection(Transition *transitions, int count, int transitionSize) : this(transitions, count, count, transitionSize) { }
/// <summary> /// Processes the new <paramref name="transition" /> discovered by the <paramref name="worker " /> within the traversal /// <paramref name="context" />. /// </summary> /// <param name="context">The context of the model traversal.</param> /// <param name="worker">The worker that found the transition.</param> /// <param name="transition">The new transition that should be processed.</param> /// <param name="isInitialTransition"> /// Indicates whether the transition is an initial transition not starting in any valid source state. /// </param> public unsafe void ProcessTransition(TraversalContext <TExecutableModel> context, Worker <TExecutableModel> worker, Transition *transition, bool isInitialTransition) { if (transition->Formulas[_formulaIndex]) { return; } context.FormulaIsValid = false; context.LoadBalancer.Terminate(); worker.CreateCounterExample(endsWithException: false, addAdditionalState: false); }
/// <summary> /// Processes the new <paramref name="transition" /> discovered by the <paramref name="worker " /> within the traversal /// <paramref name="context" />. /// </summary> /// <param name="context">The context of the model traversal.</param> /// <param name="worker">The worker that found the transition.</param> /// <param name="transition">The new transition that should be processed.</param> /// <param name="isInitialTransition"> /// Indicates whether the transition is an initial transition not starting in any valid source state. /// </param> public unsafe void ProcessTransition(TraversalContext context, Worker worker, Transition *transition, bool isInitialTransition) { if (_evaluator(transition->Formulas)) { return; } context.FormulaIsValid = false; context.LoadBalancer.Terminate(); worker.CreateCounterExample(endsWithException: false, addAdditionalState: false); }