示例#1
0
            private T ApplyFuncWithRecursionBasedAlgorithmInnerRecursion <T>(Func <ContinuationGraphElement, IEnumerable <T>, T> innerFunc, Func <ContinuationGraphElement, T> leafFunc, Dictionary <long, T> cachedElements, long currentCid)
            {
                if (cachedElements.ContainsKey(currentCid))
                {
                    return(cachedElements[currentCid]);
                }

                ContinuationGraphElement cge = Ltmdp.GetContinuationGraphElement(currentCid);

                if (cge.IsChoiceTypeUnsplitOrFinal)
                {
                    var result = leafFunc(cge);
                    cachedElements[currentCid] = result;
                    return(result);
                }
                else
                {
                    var results = new T[cge.To - cge.From + 1];
                    for (var i = cge.From; i <= cge.To; i++)
                    {
                        results[i - cge.From] = ApplyFuncWithRecursionBasedAlgorithmInnerRecursion(innerFunc, leafFunc, cachedElements, i);
                    }
                    var result = innerFunc(cge, results);
                    cachedElements[currentCid] = result;
                    return(result);
                }
            }
示例#2
0
        public void CreateStutteringState(int stutteringStateIndex)
        {
            // The stuttering state might not be reached at all.
            // Make sure, that all used algorithms to not require a connected state graph.
            var currentElementIndex = _stateStorageStateToRootOfContinuationGraphMemory[stutteringStateIndex];

            Assert.That(currentElementIndex == -1, "Stuttering state has already been created");

            var locationOfNewContinuationGraphElement = GetPlaceForNewContinuationGraphElements(1);
            var locationOfNewTransitionTargetElement  = GetPlaceForNewTransitionTargetElement();

            _continuationGraph[locationOfNewContinuationGraphElement] =
                new ContinuationGraphElement
            {
                ChoiceType  = LtmdpChoiceType.UnsplitOrFinal,
                To          = locationOfNewTransitionTargetElement,
                Probability = 1.0,
            };

            _transitionTarget[locationOfNewTransitionTargetElement] =
                new TransitionTargetElement
            {
                Formulas    = new StateFormulaSet(),
                TargetState = stutteringStateIndex
            };

            SourceStates.Add(stutteringStateIndex);
            _stateStorageStateToRootOfContinuationGraphMemory[stutteringStateIndex] = locationOfNewContinuationGraphElement;
        }
示例#3
0
            private void ApplyActionWithRecursionBasedAlgorithmInnerRecursion(Action <ContinuationGraphElement> action, long currentCid)
            {
                ContinuationGraphElement cge = Ltmdp.GetContinuationGraphElement(currentCid);

                action(cge);
                if (cge.IsChoiceTypeUnsplitOrFinal)
                {
                }
                else
                {
                    for (var i = cge.From; i <= cge.To; i++)
                    {
                        ApplyActionWithRecursionBasedAlgorithmInnerRecursion(action, i);
                    }
                }
            }
示例#4
0
 public DirectChildrenEnumerator(LabeledTransitionMarkovDecisionProcess ltmdp, long parentContinuationId)
 {
     ContinuationGraphElement   = ltmdp._continuationGraph[parentContinuationId];
     CurrentChildContinuationId = ContinuationGraphElement.From - 1;
     ParentContinuationId       = parentContinuationId;
 }