Example #1
0
 public FCNode(CoordNode baseCordNode, int dimension, int index,
               bool promoted = false, int previousAugmentedListIndex = -1)
 {
     BaseCoordNode = baseCordNode;
     Index         = index;
     Dimension     = dimension;
     Promoted      = promoted;
     PreviousAugmentedListIndex = previousAugmentedListIndex;
 }
Example #2
0
        private void SetFCTransformationMatrix(int unitFracDen, bool print = false)
        {
            /**
             * Copy coordNode matrix into FCNode matrix, perform fractional cascading
             * transformation
             *
             * Parameter:
             *  unitFracDen: denominator of the unit fraction indicating the size of the
             *               subset of promoted list (d-1)' into list d'   */

            NodeMatrixPrime = new FCNode[k][];

            // Convert coordNodes -> FCNodes
            if (print)
            {
                Console.WriteLine(
                    "Instantiating (not-yet-promoted) FCNodes from coordNode data.");
            }
            for (int i = 0; i < k; i++)
            {
                NodeMatrixPrime[i] = new FCNode[n];
                for (int j = 0; j < n; j++)
                {
                    CoordNode thisCoordNode = InputCoordMatrix[i][j];
                    FCNode    thisFCNode    = new FCNode(thisCoordNode, (i + 1), j);
                    NodeMatrixPrime[i][j] = thisFCNode;
                }
            }

            // Begin Fractional Cascading Transformation
            if (print)
            {
                Console.WriteLine(
                    "Performing Fractional Cascading transformation on FCNode matrix.");
            }

            // Perform transformation on all lists in reverse order
            // Re. i = (k-2): as nodes are always promoted from higher dimensions into
            //                lower ones, for (highest dim) k, list(k) = list(k')
            for (int i = k - 2; i >= 0; i--)
            {
                NodeMatrixPrime[i] = BuildListPrime(NodeMatrixPrime[i],
                                                    NodeMatrixPrime[i + 1],
                                                    unitFracDen);
            }
        }
Example #3
0
 public FCNode(CoordNode baseCoordNode, bool prime = false)
 {
     BaseCoordNode = baseCoordNode;
     Prime         = prime;
 }
Example #4
0
        public static CoordNode[] GetCoordNodeList(int n, int insertData = -1,
                                                   bool sort           = true, int sortAttrCode = 0,
                                                   int dimensions      = 1, int randomSeed      = -1,
                                                   int dataRangeMin    = 0,
                                                   int dataRangeMax    = 10000000,
                                                   int locRangeMin     = 0,
                                                   int locRangeMax     = 10000000,
                                                   bool randomizeOrder = true)
        {
            /**
             * Return a list of coordNodes with random x, y, and z values ranging locRangeMin
             * to locRangeMax and data values ranging from dataRangeMin to dataRangeMax
             * (inclusive min, exclusive max).
             *
             * Parameters:
             *  n: the length of the list of nodes to return
             *  sort: if true, sort return list ordered by coordNode.getAttr(sortAttrCode)
             *  dimensions: between one and three
             *  dataRangeMin, dataRangeMax: randomized range of node data values
             *  locRangeMin, locRangeMax: randomized range of xyz values
             *  randomSeed: random seed used dataList generation, system default if -1
             *  insertData: if not -1, replace the data attribute of the node at a
             *              random index in the return list  */

            CoordNode[] nodeList = new CoordNode[n];

            // Populate location and data values
            int[] xList;                HashSet <int> xSet;
            int[] yList = new int[0];   HashSet <int> ySet = new HashSet <int> {
                0
            };
            int[] zList = new int[0];   HashSet <int> zSet = new HashSet <int> {
                0
            };

            (int[] dataList, HashSet <int> dataSet) = // We will always need data
                                                      RandUniqueInts(n, locRangeMin, dataRangeMax, randomSeed, randomizeOrder);

            // We will always have at least one dimension
            (xList, xSet) = RandUniqueInts(n, locRangeMin, locRangeMax, randomSeed,
                                           randomizeOrder);

            // Check for further dimensionality before constructing random lists
            if (dimensions >= 2)
            {
                (int[] yL, HashSet <int> yS) = RandUniqueInts(n, locRangeMin, locRangeMax,
                                                              randomSeed, randomizeOrder);
                yList = yL; ySet = yS;
            }
            if (dimensions == 3)
            {
                (int[] zL, HashSet <int> zS) = RandUniqueInts(n, locRangeMin, locRangeMax,
                                                              randomSeed, randomizeOrder);
                zList = zL; zSet = zS;
            }
            if (dimensions > 3 || dimensions < 1)
            {
                string errMsg =
                    "Invalid dimensions parameter value when calling getCoordNodeList";
                throw new Exception(errMsg);
            }

            for (int i = 0; i < n; i++)    // Build nodes using newly generated lists/sets
            {
                if (dimensions == 1)
                {
                    nodeList[i] = new CoordNode(dataList[i], xList[i]);
                }
                else if (dimensions == 2)
                {
                    nodeList[i] = new CoordNode(dataList[i], xList[i], yList[i]);
                }
                else if (dimensions == 3)
                {
                    nodeList[i] =
                        new CoordNode(dataList[i], xList[i], yList[i], zList[i]);
                }
            }

            // Insert expected search value
            if (insertData >= 0)    // note: n/2 index in nodeList is arbitrary
            {
                if (!(dataSet.Contains(insertData)))
                {
                    nodeList[n / 2].SetData(insertData);
                }
            }

            // Sort randomly generated attributes on sortAttrCode
            if (sort)
            {
                new MergeSortNodes().Sort(nodeList, sortAttrCode);
            }

            return(nodeList);
        }