コード例 #1
0
ファイル: CoreOperations.cs プロジェクト: whoaitsjoe/Research
        public static Point2 LiftSigmaD(Point2 startPoint)
        {
            int[] intArray = new int[startPoint.GetDimension()];

            int sigma_dMinus1 = (int)Math.Pow(2, startPoint.GetDimension() - 1);

            for (int i = 0; i < intArray.Length; i++)
            {
                intArray[i] = sigma_dMinus1 - startPoint.Coordinates[i];
            }

            Point2 temp = new Point2(intArray);

            temp.IncreaseDimensionality(0, 0);
            return(temp);
        }
コード例 #2
0
ファイル: Run.cs プロジェクト: whoaitsjoe/Research
        //returns true if candidate vertex can be decomposed in multiple ways from set of possible edges.
        private bool DoubleDecompositionHeuristic(Point2 candidateVertex, List <Point2> possibleEdges)
        {
            return(DoubleDecompositionBruteForce(candidateVertex, possibleEdges));

            //possibleEdges may not be required.

            var numberOfNonZeroCoordinates = candidateVertex.GetDimension();

            List <Point2> usedVectors = new List <Point2>();

            //create data structure to store (2) decompositions of candidate vertices.

            //make a copy of candidateVertex that will be modified (i.e. subtracting vectors).

            while (true)     //need to determine termination condition for loop
            {
                //find first nonzero coordinate of current vector
                var           firstNonZeroIndex = candidateVertex.FirstNonZeroIndex();
                List <Point2> splitVectors      = new List <Point2>();

                //generate corresponding unit vector
                Point2 unitVector = Point2.GenerateOnesVector(candidateVertex.GetDimension(), firstNonZeroIndex);

                //ensure unit vector is not in usedVector list, if vector is used, perform split. Check to make sure split vectors are not used before.
                if (usedVectors.Contains(unitVector))
                {
                    splitVectors = Point2.SplitVectors(unitVector, usedVectors);
                }

                if (splitVectors.Count == 0)
                {
                    //Cannot split the current vector, hence no decomposition possible
                }

                //subtract unit vector from current vector

                //add unit vector to usedVeectorList
            }
            return(DoubleDecompositionBruteForce(candidateVertex, possibleEdges));
        }
コード例 #3
0
        public static List <Point2> GenerateV(Point2 u)
        {
            var result        = new List <Point2>();
            var candidateV    = new Point2();
            var vCoordinates  = new int[u.GetDimension()];
            var g0            = new int[Globals.d];
            var terminateFlag = false;

            //set first v candidate
            for (int i = 0; i < u.GetDimension(); i++)
            {
                vCoordinates[i] = Globals.k - u.Coordinates[i] - Globals.gap;
            }

            while (!terminateFlag)
            {
                candidateV = new Point2(vCoordinates);

                //same point check
                if (u.Equals(candidateV))
                {
                    if (Globals.ShowMessages)
                    {
                        Console.WriteLine(candidateV.ToString() + ": Eliminated. Same point as u.");
                    }
                }
                //inverse check
                else if (CheckInverse(u, candidateV))
                {
                    if (Globals.ShowMessages)
                    {
                        Console.WriteLine(candidateV.ToString() + ": Eliminated. Inverse already checked.");
                    }
                }
                else
                {
                    var uRedundant = false;
                    var vRedundant = false;

                    //generate gi
                    for (int i = 0; i < Globals.d; i++)
                    {
                        g0[i] = Globals.gap + u.Coordinates[i] + vCoordinates[i] - Globals.k;
                    }

                    //check vStar, given gap i, check that both u and v exist within the vertex set of the corresponding facets.
                    if (!CheckVertexSet(u, candidateV, g0, Globals.d - 1, Globals.k))
                    {
                        if (Globals.ShowMessages)
                        {
                            Console.WriteLine(candidateV.ToString() + ": Eliminated.  Point does not belong to vertex set.");
                        }
                    }
                    //check convex core
                    else if (CheckConvexCore(u, candidateV, g0, out uRedundant, out vRedundant))
                    {
                        result.Add(candidateV);

                        if (Globals.ShowMessages)
                        {
                            Console.WriteLine("u: " + u + ". v: " + candidateV);
                        }
                    }
                    else
                    {
                        if (Globals.ShowMessages)
                        {
                            Console.Write("u: " + u + ". v: ");
                            foreach (int i in vCoordinates)
                            {
                                Console.Write(i + " ");
                            }

                            Console.WriteLine(" eliminated, " + (uRedundant && vRedundant ? "u and v are not vertices " :
                                                                 (uRedundant ? "u is not a vertex " : "v is not a vertex ")) +
                                              "of the convex core.");
                        }
                    }

                    result.Add(candidateV);

                    if (Globals.ShowMessages)
                    {
                        Console.WriteLine("u: " + u + ". v: " + candidateV);
                    }
                }

                //increment candidate and check termination condition
                while (symmetryCheck(u.Coordinates, vCoordinates))
                {
                    IncrementCandidatePoint(u.Coordinates, vCoordinates, out terminateFlag);
                }
            }
            return(result);
        }