Exemple #1
0
        /// <summary>
        /// Takes boundary in standardized form and instead of trying to add all boundaries that can be transited to from this one,
        /// it immediately resolves them (It certainly will be one of the smallest possible.).
        /// If it finds the end of triarc it changes triarc state to found and starts the finishing backtracking of triarc.
        /// </summary>
        /// <param name="boundary">Boundary to transit from</param>
        /// <param name="orderOfHighestBitSet">Pre-proccesed information boundary</param>
        /// <param name="orderOfSecondHighestBitSet">Pre-procccesed information about boundary</param>
        void TransitAndAddOnlyTwoOnes(long boundary, int orderOfHighestBitSet, int orderOfSecondHighestBitSet)
        {
            int shorterSequenceOfNulls = orderOfHighestBitSet - orderOfSecondHighestBitSet - 1;
            int longerSequenceOfNulls  = orderOfSecondHighestBitSet;

            //defensive programming - control check
            if (orderOfHighestBitSet - orderOfSecondHighestBitSet - 1 > orderOfSecondHighestBitSet)
            {
                shorterSequenceOfNulls = orderOfSecondHighestBitSet;
                longerSequenceOfNulls  = orderOfHighestBitSet - orderOfSecondHighestBitSet - 1;
            }

            foreach (var face in FacesSizes)
            {
                //If  connecting first and second one by an edge causes that both new faces are in allowed, than solution has been found
                if (shorterSequenceOfNulls + 2 == face && FacesSizes.Contains(longerSequenceOfNulls + 2))
                {
                    long newBoundary = BoundaryLong.FaceToBoundary(face);
                    if (AddTransition(boundary, newBoundary))
                    {
                        Found = true;
                    }
                }

                if (shorterSequenceOfNulls + 2 + 1 < face) //needs to enlarge by two at least
                {                                          //ones are changed to nulls, new ones remains + number of nulls in secondSequence + 2
                    //jedničky se změní na nuly, zbydou nové jedničky + počet nul v delší sérii + 2
                    long newBoundary = 0;
                    for (int i = longerSequenceOfNulls + 2; i < longerSequenceOfNulls + face - shorterSequenceOfNulls; i++)
                    {
                        newBoundary |= SetBits[i];
                    }
                    if (IsValid(newBoundary) && AddTransition(boundary, newBoundary))
                    {
                        ResolveBoundary(newBoundary);
                    }
                }
                if (longerSequenceOfNulls + 2 + 1 < face) //needs to enlarge by two at least
                {                                         //jedničky se změní na nuly, zbydou nové jedničky + počet nul v delší sérii + 2
                    long newBoundary = 0;
                    for (int i = shorterSequenceOfNulls + 2; i < shorterSequenceOfNulls + face - longerSequenceOfNulls; i++)
                    {
                        newBoundary |= SetBits[i];
                    }

                    if (IsValid(newBoundary) && AddTransition(boundary, newBoundary))
                    {
                        ResolveBoundary(newBoundary);
                    }
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Constructor takes three counts which represent counts of vertices between main triarc vertices, that have degree 2 in triarc.
 /// FaceSizes must be those values that Eberhard-like theorems suggest.
 /// </summary>
 /// <param name="a">First number that determines triarc</param>
 /// <param name="b">Second number that determines triarc</param>
 /// <param name="c">Third number that determines triarc</param>
 /// <param name="facesSizes">List of values that satisfy neccesary conditions. Must has greatest value last, should be sorted. </param>
 /// <param name="taskCount">Best speed should be achieved by taskCount similar to number of proccesors.</param>
 public TriarcSolving(int a, int b, int c, int[] facesSizes)
 {
     this.TaskCount       = Global.TaskCount;
     this.TransitionLimit = Global.Limit;
     this.Name            = "(" + a + "," + b + "," + c + ")";
     this.FacesSizes      = facesSizes;
     StartingBoundary     = CreateOuterBoundaryOfTriarc(a, b, c);
     Faces = new long[facesSizes.Length];
     for (int i = 0; i < Faces.Length; i++)
     {
         Faces[i] = BoundaryLong.FaceToBoundary(FacesSizes[i]);
     }
 }
Exemple #3
0
 public TriarcSolving(long startingBoundary, int[] facesSizes)
 {
     this.TaskCount       = Global.TaskCount;
     this.TransitionLimit = Global.Limit;
     this.Name            = "(" + Convert.ToString(startingBoundary, 2) + ")";
     this.FacesSizes      = facesSizes;
     StartingBoundary     = startingBoundary;
     Faces = new long[facesSizes.Length];
     for (int i = 0; i < Faces.Length; i++)
     {
         Faces[i] = BoundaryLong.FaceToBoundary(FacesSizes[i]);
     }
 }