Beispiel #1
0
        private int CountTargetStatesOfCid(LabeledTransitionMarkovDecisionProcess ltmdp, long cid)
        {
            var targetStatesCount = 0;
            Action <LabeledTransitionMarkovDecisionProcess.ContinuationGraphElement> counter = cge =>
            {
                if (cge.IsChoiceTypeUnsplitOrFinal)
                {
                    targetStatesCount++;
                }
            };
            var traverser = ltmdp.GetTreeTraverser(cid);

            traverser.ApplyActionWithStackBasedAlgorithm(counter);

            return(targetStatesCount);
        }
Beispiel #2
0
        private double SumProbabilitiesOfCid(LabeledTransitionMarkovDecisionProcess ltmdp, long cid)
        {
            var probabilties = 0.0;
            Action <LabeledTransitionMarkovDecisionProcess.ContinuationGraphElement> counter = cge =>
            {
                if (cge.IsChoiceTypeUnsplitOrFinal)
                {
                    var probability = ltmdp.GetTransitionTarget((int)cge.To).Probability;
                    probabilties += probability;
                }
            };
            var traverser = ltmdp.GetTreeTraverser(cid);

            traverser.ApplyActionWithStackBasedAlgorithm(counter);

            return(probabilties);
        }
Beispiel #3
0
        private double SumProbabilitiesOfCid(LabeledTransitionMarkovDecisionProcess ltmdp, long cid)
        {
            Func <LabeledTransitionMarkovDecisionProcess.ContinuationGraphElement, double> leafCounter = (cge) =>
            {
                var myProbability = cge.Probability;
                return(myProbability);
            };
            Func <LabeledTransitionMarkovDecisionProcess.ContinuationGraphElement, IEnumerable <double>, double> innerCounter = (cge, childProbabilities) =>
            {
                var myProbability    = cge.Probability;
                var childProbability = 0.0;
                foreach (var p in childProbabilities)
                {
                    childProbability += p;
                }
                return(myProbability * childProbability);
            };
            var traverser    = ltmdp.GetTreeTraverser(cid);
            var probabilties = traverser.ApplyFuncWithRecursionBasedAlgorithm(innerCounter, leafCounter);

            return(probabilties);
        }