/// <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
        private void AddTransitionConsolidate(byte *stateToAdd, StateFormulaSet formulas, FaultSet activatedFaults, double probability)
        {
            // Try to find a matching transition. If not found, then add a new one
            var successorState = AddStateConsolidate(stateToAdd);

            for (var i = 0; i < _count; i++)
            {
                var candidateTransition = _transitions[i];
                if (candidateTransition.TargetStatePointer == successorState &&
                    candidateTransition.Formulas == formulas                     //&&
                    //candidateTransition.ActivatedFaults == activatedFaults
                    )
                {
                    candidateTransition.Probability += probability;
                    _transitions[i] = candidateTransition;
                    return;
                }
            }

            if (_count >= _capacity)
            {
                throw new OutOfMemoryException("Unable to store an additional transition. Try increasing the successor state capacity.");
            }

            _transitions[_count] = new LtmcTransition
            {
                TargetStatePointer = successorState,
                Formulas           = formulas,
                //ActivatedFaults = activatedFaults,
                Flags       = TransitionFlags.IsValidFlag,
                Probability = probability
            };
            ++_count;
        }
Exemplo n.º 3
0
        public void AddTransition(int targetState, double probability, StateFormulaSet formulas)
        {
            // Try to find a matching transition. If not found, then add a new one
            var state = AddState(targetState);

            for (var i = 0; i < _transitionCount; i++)
            {
                var candidateTransition = _transitions[i];
                if (candidateTransition.TargetStatePointer == state &&
                    candidateTransition.Formulas == formulas)
                {
                    candidateTransition.Probability += probability;
                    _transitions[i] = candidateTransition;
                    return;
                }
            }

            Requires.That(_transitionCount < _capacity, "more space needed");

            _transitions[_transitionCount] = new LtmcTransition
            {
                TargetStatePointer = state,
                Formulas           = formulas,
                ActivatedFaults    = new FaultSet(),
                Flags       = TransitionFlags.IsValidFlag,
                Probability = probability
            };
            ++_transitionCount;
        }
Exemplo n.º 4
0
        private void AddTransition(byte *stateToAdd, StateFormulaSet formulas, FaultSet activatedFaults, double probability)
        {
            if (_consolidateOnTheFly)
            {
                AddTransitionConsolidate(stateToAdd, formulas, activatedFaults, probability);
            }
            else
            {
                if (_count >= _capacity)
                {
                    throw new OutOfMemoryException("Unable to store an additional transition. Try increasing the successor state capacity.");
                }

                var successorState = _temporalStateStorage.GetFreeTemporalSpaceAddress();
                MemoryBuffer.Copy(stateToAdd, successorState, _temporalStateStorage.StateVectorSize);
                _transitions[_count] = new LtmcTransition
                {
                    TargetStatePointer = successorState,
                    Formulas           = formulas,
                    //ActivatedFaults = activatedFaults,
                    Flags       = TransitionFlags.IsValidFlag,
                    Probability = probability
                };
                ++_count;
            }
        }
Exemplo n.º 5
0
 private void AddTransition(byte *stateToAdd, StateFormulaSet formulas, FaultSet activatedFaults, double probability)
 {
     if (_consolidateOnTheFly)
     {
         AddTransitionConsolidate(stateToAdd, formulas, activatedFaults, probability);
     }
     else
     {
         var successorState = _temporalStateStorage.GetFreeTemporalSpaceAddress();
         MemoryBuffer.Copy(stateToAdd, successorState, _temporalStateStorage.StateVectorSize);
         _transitions[_count] = new LtmcTransition
         {
             TargetStatePointer = successorState,
             Formulas           = formulas,
             //ActivatedFaults = activatedFaults,
             Flags       = TransitionFlags.IsValidFlag,
             Probability = probability
         };
         ++_count;
     }
 }