public void CreateReversePCP(out PCPInstance reversedPCP) { reversedPCP = new PCPInstance(); reversedPCP.Init(); // copy member attributions reversedPCP.size = size; reversedPCP.width = width; reversedPCP.up_offset = up_offset; reversedPCP.down_offset = down_offset; reversedPCP.offset = offset; reversedPCP.gcd = gcd; int i = 0; foreach (Pair p in arrPair) { reversedPCP.arrPair[i] = p; Pair newPair = reversedPCP.arrPair[i]; newPair.down = Reverse(newPair.down); newPair.up = Reverse(newPair.up); i++; } reversedPCP.CountOffset(); }
// return value: // 1 -- solved, find solution // -1 -- solved, no solution // 0 -- unsolved public static int SolvePCPInstance(PCPInstance instance, int iterative) { instance.CountOffset(); int ret = 0; //PCPInstance ReversePCP; //// create the inverse instance //instance.CreateReversePCP(out ReversePCP); //Console.WriteLine("After reversal PCP Instance Is:"); //instance.Print(); //Mask.FindMask(instance, ReversePCP); //if (Convert.ToBoolean(instance.upmask) && Convert.ToBoolean(instance.downmask) || // Convert.ToBoolean(ReversePCP.upmask) && Convert.ToBoolean(ReversePCP.downmask)) // return -1; int solved_flag = 0; // try original direction int original_visit_nodenum; node_num = 0; ret = SearchSolution(instance); if (solution_count >= 1) solved_flag = 1; else if (ret == -1) solved_flag = -1; original_visit_nodenum = node_num; ////TODO IMPLEMENT HASH TABLE ////ClearHashTable(); //// try reverse direction //int reverse_visit_nodenum; //node_num = 0; //ret = SearchSolution(ReversePCP); //if (solution_count >= 1) solved_flag = 1; //else if (ret == -1) solved_flag = -1; //reverse_visit_nodenum = node_num; ////TODO: CONVERT TO C# HASHMAP ////ClearHashTable(); if (solved_flag == 1) { Console.WriteLine("SOLUTION FOUND OR FALSE POSITIVE:"); Console.WriteLine(PCPSolver.arrSelection); } return 0; }
// return value: // 1 -- solved, find solution // -1 -- solved, no solution // 0 -- unsolved static public int SolvePCPInstance(PCPInstance instance, int iterative) { instance.CountOffset(); int ret = 0; //PCPInstance ReversePCP; //// create the inverse instance //instance.CreateReversePCP(out ReversePCP); //Console.WriteLine("After reversal PCP Instance Is:"); //instance.Print(); //Mask.FindMask(instance, ReversePCP); //if (Convert.ToBoolean(instance.upmask) && Convert.ToBoolean(instance.downmask) || // Convert.ToBoolean(ReversePCP.upmask) && Convert.ToBoolean(ReversePCP.downmask)) // return -1; int solved_flag = 0; // try original direction int original_visit_nodenum; node_num = 0; ret = SearchSolution(instance); if (solution_count >= 1) { solved_flag = 1; } else if (ret == -1) { solved_flag = -1; } original_visit_nodenum = node_num; ////TODO IMPLEMENT HASH TABLE ////ClearHashTable(); //// try reverse direction //int reverse_visit_nodenum; //node_num = 0; //ret = SearchSolution(ReversePCP); //if (solution_count >= 1) solved_flag = 1; //else if (ret == -1) solved_flag = -1; //reverse_visit_nodenum = node_num; ////TODO: CONVERT TO C# HASHMAP ////ClearHashTable(); if (solved_flag == 1) { Console.WriteLine("SOLUTION FOUND OR FALSE POSITIVE:"); Console.WriteLine(PCPSolver.arrSelection); } return(0); }