Ejemplo n.º 1
0
        private void ChangePosition(CRFGraph graph, int time)
        {
            //jedes proposal gleich wahrscheinlich
            var p      = (double)graph.Nodes.Count() / (graph.Data.NumberCategories + 2 * graph.Nodes.Count());
            var random = Random.NextDouble();

            if (random <= p)
            {
                CountTransitionNodeProposal++;
                ChangePositionNode(graph, time);
            }
            else if (random > p && random <= p * 2)
            {
                CountTransitionNeighborhoodProposal++;
                ChangePositionNeighborhood(graph, time);
            }
            else
            {
                CountTransitionCategoryProposal++;
                ChangePositionCategory(graph, time);
            }


            //out of perRun , collect sample for tests
            if (time > 0)
            {
                //get list of samples for current graph
                var samples = TestSamples[Chains.IndexOf(graph)];

                int[] sample = new int[graph.Nodes.Count()];
                foreach (var node in graph.Nodes)
                {
                    sample[node.GraphId] = node.Data.TempAssign;
                }

                samples.Add(sample);
            }
        }