private byte *AddStateConsolidate(byte *stateToFind)
        {
            // Try to find a matching state. If not found, then add a new one
            byte *targetState;

            if (_temporalStateStorage.TryToFindState(stateToFind, out targetState))
            {
                return(targetState);
            }

            targetState = _temporalStateStorage.GetFreeTemporalSpaceAddress();
            MemoryBuffer.Copy(stateToFind, targetState, _temporalStateStorage.StateVectorSize);

            return(targetState);
        }
        /// <summary>
        ///   Adds a transition to the <paramref name="model" />'s current state.
        /// </summary>
        /// <param name="model">The model the transition should be added for.</param>
        /// <param name="continuationId">The id of the transition.</param>
        public void Add(ExecutableModel <TExecutableModel> model, int continuationId)
        {
            if (_transitionsWithContinuationIdCount >= _capacity)
            {
                throw new OutOfMemoryException("Unable to store an additional transition. Try increasing the successor state capacity.");
            }

            // 1. Notify all fault activations, so that the correct activation is set in the run time model
            //    (Needed to persist persistent faults)
            model.NotifyFaultActivations();

            // 2. Serialize the model's computed state; that is the successor state of the transition's source state
            //    _including_ any changes resulting from notifications of fault activations
            var successorState = _temporalStateStorage.GetFreeTemporalSpaceAddress();

            model.Serialize(successorState);

            // 3. Store the transition
            var activatedFaults      = FaultSet.FromActivatedFaults(model.NondeterministicFaults);
            var positionOfTransition = _transitionsWithContinuationIdCount;

            _transitionsWithContinuationIdMemory[positionOfTransition] = new LtmdpTransition
            {
                TargetStatePointer = successorState,
                Formulas           = new StateFormulaSet(_formulas),
                ActivatedFaults    = activatedFaults,
                Flags = TransitionFlags.IsValidFlag,
                Index = positionOfTransition
            };
            ++_transitionsWithContinuationIdCount;
            LtmdpStepGraph.SetTargetOfFinalOrUnsplitChoice(continuationId, positionOfTransition);
        }
Example #3
0
        public byte *CreateState(int stateContent)
        {
            var position      = TemporaryStateStorage.GetFreeTemporalSpaceAddress();
            var positionAsInt = (int *)position;

            *positionAsInt = stateContent;
            return(position);
        }
        private byte *AddState(int originalState)
        {
            // Try to find a matching state. If not found, then add a new one
            byte *targetState;

            int *stateToFind = stackalloc int[1];

            stateToFind[0] = originalState;

            if (_temporalStateStorage.TryToFindState((byte *)stateToFind, out targetState))
            {
                return(targetState);
            }

            targetState = _temporalStateStorage.GetFreeTemporalSpaceAddress();
            var targetStateAsInt = (int *)targetState;

            // create new state
            targetStateAsInt[0] = originalState;
            return(targetState);
        }
Example #5
0
        /// <summary>
        ///   Adds a transition to the <paramref name="model" />'s current state.
        /// </summary>
        /// <param name="model">The model the transition should be added for.</param>
        public void Add(ExecutableModel <TExecutableModel> model)
        {
            if (_count >= _capacity)
            {
                throw new OutOfMemoryException("Unable to store an additional transition. Try increasing the successor state capacity.");
            }

            ++_computedCount;

            // 1. Serialize the model's computed state; that is the successor state of the transition's source state
            //    modulo any changes resulting from notifications of fault activations
            var successorState  = _temporalStateStorage.GetFreeTemporalSpaceAddress();
            var activatedFaults = FaultSet.FromActivatedFaults(model.NondeterministicFaults);

            model.Serialize(successorState);

            // 2. Make sure the transition we're about to add is activation-minimal
            if (!Add(successorState, activatedFaults))
            {
                return;
            }

            // 3. Execute fault activation notifications and serialize the updated state if necessary
            if (model.NotifyFaultActivations())
            {
                model.Serialize(successorState);
            }

            // 4. Store the transition
            _transitions[_count] = new CandidateTransition
            {
                TargetStatePointer = successorState,
                Formulas           = new StateFormulaSet(_formulas),
                ActivatedFaults    = activatedFaults,
                Flags = TransitionFlags.IsValidFlag,
            };
            ++_count;
        }