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); } }
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(); }
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++; } } }
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++; } } }
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(); } }
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); } }
public bool Equals(StateStorageEntry other) { return(Formula.Equals(other.Formula) && StateStorageState == other.StateStorageState); }