Beispiel #1
0
        //returns an array of randomnly selected k DISTINCT docIds
        protected Cluster[] GetInitialClusters(short[] docIds, int number)
        {
            Cluster[] clusters = GetEmptyClusters(number);
            Hashtable selected = new Hashtable();
            int       cursor   = 0;

            for (int i = 0; i < number; i++)
            {
                int position = GetRandomGenerator.Next(docIds.Length);
                while (selected.Contains(position))
                {
                    if (++position == docIds.Length)
                    {
                        position = 0;                                                  //circular search: if pos > max allowed, make it 0
                    }
                }
                selected.Add(position, true);
                clusters[cursor++].AddDoc(docIds[position]);
            }
            return(clusters);
        }
Beispiel #2
0
 public Human CreateRandomHuman() => GetRandomGenerator(_generators)();