Exemple #1
0
            public UnderlyingDigraph(NestedMarkovDecisionProcess mdp)
            {
                //Assumption "every node is reachable" is fulfilled due to the construction
                BaseGraph = new BidirectionalGraph();

                var currentState = 0;
                Action <ContinuationGraphElement> addTargetState = cge =>
                {
                    if (cge.IsChoiceTypeUnsplitOrFinal)
                    {
                        var cgl = cge.AsLeaf;
                        if (cgl.Probability > 0.0)
                        {
                            BaseGraph.AddVerticesAndEdge(new Edge(currentState, cgl.ToState));
                        }
                    }
                };

                for (currentState = 0; currentState < mdp.States; currentState++)
                {
                    var parentCid     = mdp.GetRootContinuationGraphLocationOfState(currentState);
                    var treeTraverser = mdp.GetTreeTraverser(parentCid);
                    treeTraverser.ApplyActionWithStackBasedAlgorithm(addTargetState);
                }
            }
Exemple #2
0
        public static void ExportToGv(this NestedMarkovDecisionProcess nmdp, TextWriter sb)
        {
            sb.WriteLine("digraph S {");
            //sb.WriteLine("size = \"8,5\"");
            sb.WriteLine("node [shape=box];");

            var initialStateName = "initialState";

            sb.WriteLine($" {initialStateName} [shape=point,width=0.0,height=0.0,label=\"\"];");
            var initialCid = nmdp.GetRootContinuationGraphLocationOfInitialState();

            ExportCid(nmdp, sb, initialStateName, false, initialCid);

            for (var state = 0; state < nmdp.States; state++)
            {
                sb.Write($" {state} [label=\"{state}\\n(");
                for (int i = 0; i < nmdp.StateFormulaLabels.Length; i++)
                {
                    if (i > 0)
                    {
                        sb.Write(",");
                    }
                    sb.Write(nmdp.StateLabeling[state][i]);
                }
                sb.WriteLine(")\"];");

                var cid      = nmdp.GetRootContinuationGraphLocationOfState(state);
                var fromNode = state.ToString();
                ExportCid(nmdp, sb, fromNode, false, cid);
            }
            sb.WriteLine("}");
        }
Exemple #3
0
        private void ConvertStateTransitions()
        {
            for (var state = 0; state < _nmdp.States; state++)
            {
                var cidOfStateRoot = _nmdp.GetRootContinuationGraphLocationOfState(state);
                Clear(cidOfStateRoot);
                _ltmdpContinuationDistributionMapper.AddInitialDistributionAndContinuation(cidOfStateRoot);

                UpdateContinuationDistributionMapperAndCollectLeafs(cidOfStateRoot);

                MarkovDecisionProcess.StartWithNewDistributions(state);

                var numberOfDistributions = _ltmdpContinuationDistributionMapper.GetNumbersOfDistributions();
                for (var distribution = 0; distribution < numberOfDistributions; distribution++)
                {
                    AddDistribution(distribution);
                }

                MarkovDecisionProcess.FinishDistributions();
            }
        }