/// <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="probability">The probability of the transition.</param>
        public void Add(ExecutableModel <TExecutableModel> model, double probability)
        {
            if (_count >= _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 = _targetStateMemory + _stateVectorSize * _count;

            model.Serialize(successorState);

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

            _transitions[_count] = new LtmcTransition
            {
                TargetStatePointer = successorState,
                Formulas           = new StateFormulaSet(_formulas),
                ActivatedFaults    = activatedFaults,
                Flags       = TransitionFlags.IsValidFlag,
                Probability = probability
            };
            ++_count;
        }
Exemplo n.º 2
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>
        /// <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 = _targetStateMemory + _stateVectorSize * _transitionsWithContinuationIdCount;

            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);
        }
Exemplo n.º 3
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>
        /// <param name="probability">The probability of the transition.</param>
        public void Add(ExecutableModel <TExecutableModel> model, double probability)
        {
            _totalCount++;

            // 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 temporaryState = _temporalStateStorage.ZeroedSpecialAddress1();

            model.Serialize(temporaryState);

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

            AddTransition(temporaryState, new StateFormulaSet(_formulas), activatedFaults, probability);
        }
Exemplo n.º 4
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  = _targetStateMemory + _stateVectorSize * _count;
            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;
        }