internal static MarkovDecisionProcess Create() { // Just a simple MDP with simple nondeterministic choices // ⟳0⟶1⟲ var mdp = new MarkovDecisionProcess(ModelCapacityByMemorySize.Tiny); mdp.StateFormulaLabels = new string[] { Label1Formula.Label, Label2Formula.Label }; mdp.StateRewardRetrieverLabels = new string[] { }; mdp.StartWithInitialDistributions(); mdp.StartWithNewInitialDistribution(); mdp.AddTransitionToInitialDistribution(0, 1.0); mdp.FinishInitialDistribution(); mdp.FinishInitialDistributions(); mdp.SetStateLabeling(1, new StateFormulaSet(new[] { true, false })); mdp.StartWithNewDistributions(1); mdp.StartWithNewDistribution(); mdp.AddTransition(1, 1.0); mdp.FinishDistribution(); mdp.FinishDistributions(); mdp.SetStateLabeling(0, new StateFormulaSet(new[] { false, true })); mdp.StartWithNewDistributions(0); mdp.StartWithNewDistribution(); mdp.AddTransition(1, 1.0); mdp.FinishDistribution(); mdp.StartWithNewDistribution(); mdp.AddTransition(0, 1.0); mdp.FinishDistribution(); mdp.FinishDistributions(); return(mdp); }
private void AddPaddingStatesInMdp() { foreach (var paddingState in _paddingStates) { if (paddingState.Key.IsInitial) { MarkovDecisionProcess.StartWithInitialDistributions(); } else { MarkovDecisionProcess.StartWithNewDistributions(paddingState.Key.State); } MarkovDecisionProcess.StartWithNewDistribution(); MarkovDecisionProcess.AddTransition(paddingState.Value, 1.0); MarkovDecisionProcess.FinishDistribution(); if (paddingState.Key.IsInitial) { MarkovDecisionProcess.FinishInitialDistributions(); } else { MarkovDecisionProcess.FinishDistributions(); } } }
internal static MarkovDecisionProcess Create() { // A MDP which was designed to test prob0e // 4 // ⇅ // 0⟼1↘ // ↘2⟼3⟲ var mdp = new MarkovDecisionProcess(ModelCapacityByMemorySize.Tiny); mdp.StateFormulaLabels = new string[] { Label1Formula.Label, Label2Formula.Label }; mdp.StateRewardRetrieverLabels = new string[] { }; mdp.StartWithInitialDistributions(); mdp.StartWithNewInitialDistribution(); mdp.AddTransitionToInitialDistribution(0, 1.0); mdp.FinishInitialDistribution(); mdp.FinishInitialDistributions(); mdp.SetStateLabeling(0, new StateFormulaSet(new[] { false, false })); mdp.StartWithNewDistributions(0); mdp.StartWithNewDistribution(); mdp.AddTransition(1, 1.0); mdp.FinishDistribution(); mdp.StartWithNewDistribution(); mdp.AddTransition(2, 1.0); mdp.FinishDistribution(); mdp.StartWithNewDistribution(); mdp.AddTransition(4, 1.0); mdp.FinishDistribution(); mdp.FinishDistributions(); mdp.SetStateLabeling(1, new StateFormulaSet(new[] { false, false })); mdp.StartWithNewDistributions(1); mdp.StartWithNewDistribution(); mdp.AddTransition(3, 1.0); mdp.FinishDistribution(); mdp.FinishDistributions(); mdp.SetStateLabeling(2, new StateFormulaSet(new[] { false, false })); mdp.StartWithNewDistributions(2); mdp.StartWithNewDistribution(); mdp.AddTransition(3, 1.0); mdp.FinishDistribution(); mdp.FinishDistributions(); mdp.SetStateLabeling(3, new StateFormulaSet(new[] { true, false })); mdp.StartWithNewDistributions(3); mdp.StartWithNewDistribution(); mdp.AddTransition(3, 1.0); mdp.FinishDistribution(); mdp.FinishDistributions(); mdp.SetStateLabeling(4, new StateFormulaSet(new[] { false, false })); mdp.StartWithNewDistributions(4); mdp.StartWithNewDistribution(); mdp.AddTransition(0, 1.0); mdp.FinishDistribution(); mdp.FinishDistributions(); return(mdp); }
private void FinishDistributions(int?stateToStartFrom) { if (stateToStartFrom.HasValue) { MarkovDecisionProcess.FinishDistributions(); } else { MarkovDecisionProcess.FinishInitialDistributions(); } }
internal static MarkovDecisionProcess Create() { // MDP of [Parker02, page 36] // 0 // ⇅ // 1➞0.6⟼2⟲ // 0.4⟼3⟲ var mdp = new MarkovDecisionProcess(ModelCapacityByMemorySize.Tiny); mdp.StateFormulaLabels = new string[] { Label1Formula.Label, Label2Formula.Label }; mdp.StateRewardRetrieverLabels = new string[] { }; mdp.StartWithInitialDistributions(); mdp.StartWithNewInitialDistribution(); mdp.AddTransitionToInitialDistribution(0, 1.0); mdp.FinishInitialDistribution(); mdp.FinishInitialDistributions(); mdp.SetStateLabeling(0, new StateFormulaSet(new[] { false, false })); mdp.StartWithNewDistributions(0); mdp.StartWithNewDistribution(); mdp.AddTransition(1, 1.0); mdp.FinishDistribution(); mdp.FinishDistributions(); mdp.SetStateLabeling(1, new StateFormulaSet(new[] { false, false })); mdp.StartWithNewDistributions(1); mdp.StartWithNewDistribution(); mdp.AddTransition(0, 1.0); mdp.FinishDistribution(); mdp.StartWithNewDistribution(); mdp.AddTransition(2, 0.6); mdp.AddTransition(3, 0.4); mdp.FinishDistribution(); mdp.FinishDistributions(); mdp.SetStateLabeling(2, new StateFormulaSet(new[] { true, false })); mdp.StartWithNewDistributions(2); mdp.StartWithNewDistribution(); mdp.AddTransition(2, 1.0); mdp.FinishDistribution(); mdp.FinishDistributions(); mdp.SetStateLabeling(3, new StateFormulaSet(new[] { false, true })); mdp.StartWithNewDistributions(3); mdp.StartWithNewDistribution(); mdp.AddTransition(3, 1.0); mdp.FinishDistribution(); mdp.FinishDistributions(); return(mdp); }
public void ConvertInitialTransitions() { var cidOfStateRoot = _nmdp.GetRootContinuationGraphLocationOfInitialState(); Clear(cidOfStateRoot); _ltmdpContinuationDistributionMapper.AddInitialDistributionAndContinuation(cidOfStateRoot); UpdateContinuationDistributionMapperAndCollectLeafs(cidOfStateRoot); MarkovDecisionProcess.StartWithInitialDistributions(); var numberOfDistributions = _ltmdpContinuationDistributionMapper.GetNumbersOfDistributions(); for (var distribution = 0; distribution < numberOfDistributions; distribution++) { AddInitialDistribution(distribution); } MarkovDecisionProcess.FinishInitialDistributions(); }