private void AddNodesOfContinuationId(long continuationId, long locationForContinuationGraphElement)
        {
            var choice = _ltmdp.GetContinuationGraphElement(continuationId);

            if (choice.IsChoiceTypeUnsplitOrFinal)
            {
                Assert.That(choice.To <= int.MaxValue, "choice.To must be smaller than int.MaxValue");

                var transitionTarget = _ltmdp.GetTransitionTarget((int)choice.To);
                var targetEntry      = new StateStorageEntry(transitionTarget.Formulas, transitionTarget.TargetState);
                var targetState      = _mapper[targetEntry];
                var probability      = transitionTarget.Probability;

                NestedMarkovDecisionProcess.AddContinuationGraphLeaf(locationForContinuationGraphElement, targetState, probability);
                return;
            }

            var offsetTo         = choice.To - choice.From;
            var numberOfChildren = offsetTo + 1;

            var placesForChildren = NestedMarkovDecisionProcess.GetPlaceForNewContinuationGraphElements(numberOfChildren);

            NestedMarkovDecisionProcess.AddContinuationGraphInnerNode(locationForContinuationGraphElement, choice.ChoiceType, placesForChildren, placesForChildren + offsetTo);

            for (var currentChildNo = 0; currentChildNo < numberOfChildren; currentChildNo++)
            {
                var originalContinuationId = choice.From + currentChildNo;
                var newLocation            = placesForChildren + currentChildNo;
                AddNodesOfContinuationId(originalContinuationId, newLocation);
            }
        }
Example #2
0
        public void ConvertInitialStates(LabeledTransitionMarkovChain ltmc)
        {
            MarkovChain.StartWithInitialDistribution();
            var enumerator = ltmc.GetInitialDistributionEnumerator();

            while (enumerator.MoveNext())
            {
                var targetEntry = new StateStorageEntry(enumerator.CurrentFormulas, enumerator.CurrentTargetState);
                var targetState = _mapper[targetEntry];
                MarkovChain.AddInitialTransition(targetState, enumerator.CurrentProbability);
            }
            MarkovChain.FinishInitialDistribution();
        }
Example #3
0
        private void CreateStates()
        {
            var enumerator = _ltmdp.GetTransitionTargetEnumerator();

            while (enumerator.MoveNext())
            {
                var entry = new StateStorageEntry(enumerator.CurrentFormulas, enumerator.CurrentTargetState);
                if (!_mapper.ContainsKey(entry))
                {
                    _mapper.Add(entry, MdpStates);
                    _backMapper[MdpStates] = entry;
                    MdpStates++;
                }
            }
        }
Example #4
0
        private void CreateStates(LabeledTransitionMarkovChain ltmc)
        {
            var enumerator = ltmc.GetTransitionChainEnumerator();

            while (enumerator.MoveNext())
            {
                var entry = new StateStorageEntry(enumerator.CurrentFormulas, enumerator.CurrentTargetState);
                if (!_mapper.ContainsKey(entry))
                {
                    _mapper.Add(entry, States);
                    _backMapper[States] = entry;
                    States++;
                }
            }
        }
Example #5
0
        public void ConvertTransitions(LabeledTransitionMarkovChain ltmc)
        {
            for (var i = 0; i < States; i++)
            {
                var sourceEntry = _backMapper[i];
                MarkovChain.StartWithNewDistribution(i);

                var enumerator = ltmc.GetTransitionEnumerator(sourceEntry.StateStorageState);
                while (enumerator.MoveNext())
                {
                    var targetEntry = new StateStorageEntry(enumerator.CurrentFormulas, enumerator.CurrentTargetState);
                    var targetState = _mapper[targetEntry];
                    MarkovChain.AddTransition(targetState, enumerator.CurrentProbability);
                }
                MarkovChain.FinishDistribution();
            }
        }
Example #6
0
        private void AddNodesOfContinuationId(long continuationId, long locationForContinuationGraphElement)
        {
            BufferCidMapping(continuationId, locationForContinuationGraphElement);

            var choice = _ltmdp.GetContinuationGraphElement(continuationId);

            if (choice.IsChoiceTypeUnsplitOrFinal)
            {
                var transitionTarget = _ltmdp.GetTransitionTarget(choice.To);
                var targetEntry      = new StateStorageEntry(transitionTarget.Formulas, transitionTarget.TargetState);
                var targetState      = _mapper[targetEntry];

                NestedMarkovDecisionProcess.AddContinuationGraphLeaf(locationForContinuationGraphElement, targetState, choice.Probability);
                return;
            }
            if (choice.IsChoiceTypeForward)
            {
                // no recursive descent here
                var bufferedTargetCid = GetBufferedNmdpCid(choice.To);
                NestedMarkovDecisionProcess.AddContinuationGraphInnerNode(locationForContinuationGraphElement, choice.ChoiceType, bufferedTargetCid, bufferedTargetCid, choice.Probability);
                return;
            }

            var offsetTo         = choice.To - choice.From;
            var numberOfChildren = offsetTo + 1;

            var placesForChildren = NestedMarkovDecisionProcess.GetPlaceForNewContinuationGraphElements(numberOfChildren);

            NestedMarkovDecisionProcess.AddContinuationGraphInnerNode(locationForContinuationGraphElement, choice.ChoiceType, placesForChildren, placesForChildren + offsetTo, choice.Probability);

            for (var currentChildNo = 0; currentChildNo < numberOfChildren; currentChildNo++)
            {
                var originalContinuationId = choice.From + currentChildNo;
                var newLocation            = placesForChildren + currentChildNo;
                AddNodesOfContinuationId(originalContinuationId, newLocation);
            }
        }
Example #7
0
 public bool Equals(StateStorageEntry other)
 {
     return(Formula.Equals(other.Formula) && StateStorageState == other.StateStorageState);
 }