Exemplo n.º 1
0
        void CalculateNode(string path, int round, IClusterNode parentNode, Bucket parentBucket)
        {
            if (round == 4)
            {
                return;
            }

            if (IsVerbose)
            {
                Console.WriteLine("Start node: {0}.", path);
            }

            McHand[] hands = null;
            hands = CreateMcHands(round, parentBucket);
            Bucket[] buckets = Clusterizer.BucketizeHands(round, hands, parentNode);

            for (int i = 0; i < parentNode.ChildrenCount; ++i)
            {
                CalculateNode(path + "," + i.ToString(), round + 1, parentNode.GetChild(i), buckets[i]);
            }

            if (IsVerbose)
            {
                Console.WriteLine("Finish node: {0}.", path);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Method to access children for standard tree algorithms.
 /// </summary>
 public static bool TreeGetChild(ClusterTree tree, IClusterNode n, ref int i, out IClusterNode child)
 {
     if (i >= n.ChildrenCount)
     {
         child = null;
         return(false);
     }
     child = n.GetChild(i++);
     return(true);
 }
Exemplo n.º 3
0
        private void CalculateStatistics(IClusterNode n, int round, double [] minClusters, double [] maxClusters)
        {
            if (round == 4)
            {
                return;
            }
            int clustersCount = n.ChildrenCount;

            minClusters[round] = Math.Min(minClusters[round], clustersCount);
            maxClusters[round] = Math.Max(maxClusters[round], clustersCount);
            for (int c = 0; c < n.ChildrenCount; ++c)
            {
                CalculateStatistics(n.GetChild(c), round + 1, minClusters, maxClusters);
            }
        }
Exemplo n.º 4
0
        public IClusterNode Generate()
        {
            _rng            = new MersenneTwister(RngSeed);
            _totalMcSamples = 0;

            Clusterizer.IsVerbose = IsVerbose;

            IClusterNode root = Clusterizer.OnGenerateBegin();

            Bucket [] buckets = CreatePreflopBuckets(root.ChildrenCount);
            for (int i = 0; i < root.ChildrenCount; ++i)
            {
                CalculateNode(i.ToString(), 1, root.GetChild(i), buckets[i]);
            }
            if (IsVerbose)
            {
                double []  minClusters = new double[4].Fill(i => double.MaxValue);
                double  [] maxClusters = new double[4].Fill(i => double.MinValue);

                CalculateStatistics(root, 0, minClusters, maxClusters);
                Console.Write("Min clusters count:");
                for (int r = 0; r < minClusters.Length; ++r)
                {
                    Console.Write("{0,3} ", minClusters[r]);
                }
                Console.WriteLine();
                Console.Write("Max clusters count:");
                for (int r = 0; r < maxClusters.Length; ++r)
                {
                    Console.Write("{0,3} ", maxClusters[r]);
                }
                Console.WriteLine();

                Console.WriteLine("Samples: {0:#,#}", _totalMcSamples);
            }
            Clusterizer.OnGenerateEnd(root);
            return(root);
        }