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);
        }
Exemple #2
0
        internal static MarkovDecisionProcess Create()
        {
            // A MDP which was designed to test prob1e
            //   0⟶0.5⟼1⟲    0.5⇢0
            //       0.5⟼3⟶4➞0.5⟲
            //             ↘2⟲
            var mdp = new MarkovDecisionProcess(ModelCapacityByMemorySize.Tiny);

            mdp.StateFormulaLabels         = new string[] { Label1Formula.Label, Label2Formula.Label };
            mdp.StateRewardRetrieverLabels = new string[] { };
            mdp.StartWithInitialDistributions();
            mdp.StartWithNewDistribution();
            mdp.AddTransition(0, 1.0);
            mdp.FinishDistribution();
            mdp.FinishInitialDistributions();

            mdp.SetStateLabeling(0, new StateFormulaSet(new[] { false, false }));
            mdp.StartWithNewDistributions(0);
            mdp.StartWithNewDistribution();
            mdp.AddTransition(1, 0.5);
            mdp.AddTransition(3, 0.5);
            mdp.FinishDistribution();
            mdp.FinishDistributions();

            mdp.SetStateLabeling(1, new StateFormulaSet(new[] { false, false }));
            mdp.StartWithNewDistributions(1);
            mdp.StartWithNewDistribution();
            mdp.AddTransition(1, 1.0);
            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, false }));
            mdp.StartWithNewDistributions(3);
            mdp.StartWithNewDistribution();
            mdp.AddTransition(2, 1.0);
            mdp.FinishDistribution();
            mdp.StartWithNewDistribution();
            mdp.AddTransition(4, 1.0);
            mdp.FinishDistribution();
            mdp.FinishDistributions();

            mdp.SetStateLabeling(4, new StateFormulaSet(new[] { false, false }));
            mdp.StartWithNewDistributions(4);
            mdp.StartWithNewDistribution();
            mdp.AddTransition(0, 0.5);
            mdp.AddTransition(4, 0.5);
            mdp.FinishDistribution();
            mdp.FinishDistributions();
            return(mdp);
        }
Exemple #3
0
        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();
                }
            }
        }
Exemple #4
0
        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.StartWithNewDistribution();
            mdp.AddTransition(0, 1.0);
            mdp.FinishDistribution();
            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);
        }
        private void AddDistribution(int distribution)
        {
            if (_ltmdpContinuationDistributionMapper.IsDistributionEmpty(distribution))
            {
                return;
            }
            MarkovDecisionProcess.StartWithNewDistribution();

            var enumerator = _ltmdpContinuationDistributionMapper.GetContinuationsOfDistributionEnumerator(distribution);

            while (enumerator.MoveNext())
            {
                var leaf        = GetLeafOfCid(enumerator.CurrentContinuationId);
                var probability = GetProbabilityOfCid(enumerator.CurrentContinuationId);
                MarkovDecisionProcess.AddTransition(leaf.ToState, probability);
            }

            MarkovDecisionProcess.FinishDistribution();
        }
Exemple #6
0
        private void AddPaddedTransition(int mdpState, double probability, int requiredPadding)
        {
            var firstStateBeforePadding = CreateNewArtificialPaddingStatesBackward(mdpState, requiredPadding);

            MarkovDecisionProcess.AddTransition(firstStateBeforePadding, probability);
        }