public Mid_4_3(ref RawData r, ref Mid_4_1 md41, ref Mid_4_2 m42) { rd = r; md42 = m42; mid4_3 = new int[rd.Cols]; Array.Clear(mid4_3, 0, mid4_3.Length); sw = new StreamWriter(Common.debugpath + "\\" + "MID4_3.txt"); // test ++++++++++++++++++++++++++++++++++++++++++++++++ // md42.digit[0] = 1; // md42.digit[1] = 1; // make SPN Combination FROM Mid_4_2 // make that each array in md41.rlist has multiple elements of digit[i]. R1pnList rFrom, rTo; rFrom = md41.rlist.Clone(); for (int i = 0; i < md42.digit.Length; i++) { if (md42.digit[i] <= 1) { continue; } rFrom.rList[i].MakeMultiple(md42.digit[i]); } // make SPN Combination R1pnList rTarget = new R1pnList(); rTo = new R1pnList(); for (int i = 0; i < md42.digit.Length; i++) //for (int i = md42.digit.Length-1; i>=0 ; i--) { if (md42.digit[i] <= 0) { continue; } rTarget = new R1pnList(); for (int j = 0; j < rFrom.rList[i].cp / md42.digit[i]; j++) { R1pnList rToTo = rTo.Clone(); rToTo.AddAllList(rFrom.rList[i].r1pn, j * md42.digit[i], md42.digit[i]); rTarget.MergeList(rToTo); rToTo = null; } rTo = rTarget; GC.Collect(); } rTo = null; rTarget.print(ref sw); // count each pn how many times it comes in the SPN Combination table. rTarget.getCountEachPN(ref mid4_3); Common.printArray("MID4_3 :MID4_3", mid4_3, ref sw); }
public Mid_3_2(ref RawData rawdata) { rd = rawdata; t = new Mid_3_2_Table(rd.Rows, rd.tpsn); mid3_2 = new int[rd.Cols]; Array.Clear(mid3_2, 0, mid3_2.Length); sw = new StreamWriter(Common.debugpath + "\\" + "MID3_2.txt"); // make Mid3-2-table int cindex = 0; for (int r = 0; r < rd.Rows; r++) { cindex = 0; for (int c = 0; c < rd.Cols; c++) { if (rd.rawdata[r, c] > 0) { t.Set(r, cindex, rd.PerSP[c]); cindex++; if (cindex == rd.tpsn) { break; } } } } // make AVERAGE t.makeAVERAGE(); t.printTable(ref sw); // make mid3-2 intmin = ((int)(t.maxavg / Common.GpspInterval)) * Common.GpspInterval; intmax = intmin + Common.GpspInterval; Array.Clear(mid3_2, 0, mid3_2.Length); for (int c = 0; c < rd.Cols; c++) { if (rd.PerSP[c] >= intmin && rd.PerSP[c] < intmax) { mid3_2[c] = 1; } } sw.WriteLine("MID3_2_Table: interval lower : " + intmin.ToString()); sw.WriteLine("MID3_2_Table: interval upper : " + intmax.ToString()); Common.printArray("MID3_2 Array: ", mid3_2, ref sw); }
private void printSPC() { sw.WriteLine("Mid_1(RawData.SPC) Print ------------------------------------"); Common.printArray("MID1 :(SPC, sum of 1's ) ", rd.spc, ref sw); sw.WriteLine("Mid_1(Max SPC value) : " + maxSPC); sw.WriteLine("Mid_1(sum of SPC) : " + sumofSPC); sw.Write("Mid_1(Max PN's) : "); for (int i = 0; i < rd.spc.Length; i++) { if (rd.spc[i] >= maxSPC) { sw.Write((i + 1).ToString() + " "); } } sw.WriteLine(); sw.WriteLine("Mid_1(RawData %SPC) Print ------------------------------------"); Common.printArray("MID1 :(%SP) ", rd.PerSP, ref sw); sw.WriteLine("MID1 :(A%SP):{0,10}", rd.APerSP.ToString("######0.00")); sw.WriteLine(); Common.printRankArray("MID1 : Rank ", rd.spc, ref sw); sw.WriteLine(); }
public ResultDB(Form1 f) { form = f; sw = new StreamWriter(Common.debugpath + "\\" + "ResultDB.txt"); Cols = f.rd.Cols; rdb = new int[20, Cols]; for (int i = 0; i < 20; i++) { for (int j = 0; j < f.rd.Cols; j++) { rdb[i, j] = 0; } } Rows = 0; for (int j = 0; j < Cols; j++) { rdb[Rows, j] = f.md1.mid1[j]; } Rows++; for (int j = 0; j < Cols; j++) { rdb[Rows, j] = f.md2.mid2[j]; } Rows++; for (int k = 0; k < f.md3_1.mid3_1_Count; k++) { for (int j = 0; j < Cols; j++) { rdb[Rows, j] = f.md3_1.mid3_1[k, j]; } Rows++; } for (int j = 0; j < Cols; j++) { rdb[Rows, j] = f.md3_2.mid3_2[j]; } Rows++; for (int j = 0; j < Cols; j++) { rdb[Rows, j] = f.md3_4.mid3_4[j]; } Rows++; for (int j = 0; j < Cols; j++) { rdb[Rows, j] = f.md4_1.mid4_1[j]; } Rows++; for (int j = 0; j < Cols; j++) { rdb[Rows, j] = (f.md4_3.mid4_3[j] > 0)?1:0; } Rows++; // sum int sum; rsum = new int[Cols]; int [] temp = new int[Cols]; for (int i = 0; i < Cols; i++) { sum = 0; for (int j = 0; j < Rows; j++) { if (rdb[j, i] > 0) { sum++; } } rdb[Rows, i] = sum; rsum[i] = sum; temp[i] = sum; } Rows++; Common.printArray("MID-1 ", form.md1.mid1, ref sw); Common.printArray("MID-2 ", form.md2.mid2, ref sw); int[] temp2 = new int[Cols]; for (int k = 0; k < f.md3_1.mid3_1_Count; k++) { for (int i = 0; i < Cols; i++) { temp2[i] = form.md3_1.mid3_1[k, i]; } if (f.md3_1.mid3_1_Count == 1) { Common.printArray("MID3-1 ", temp2, ref sw); } else { Common.printArray("MID3-1-" + (k + 1).ToString(), temp2, ref sw); } } Common.printArray("MID3-2 ", form.md3_2.mid3_2, ref sw); Common.printArray("MID3-4 ", form.md3_4.mid3_4, ref sw); Common.printArray("MID4-1 ", form.md4_1.mid4_1, ref sw); Common.printArray("MID4-3 ", form.md4_3.mid4_3, ref sw); sw.WriteLine(""); Common.printArray("ResultDB: SUM ", rsum, ref sw); // choose tspn + 2 PN's IComparer myComparer = new myReverserClass(); Array.Sort(temp, myComparer); //Common.printArray("temp ", temp, ref sw); ThreshVal = temp[f.rd.tpsn - 1 + 2]; sw.WriteLine(""); sw.WriteLine((f.rd.tpsn + 2).ToString() + "th biggist value is " + ThreshVal.ToString()); sw.WriteLine(""); printTable(ref sw); }
public void Run() { Array.Clear(mid3_4, 0, mid3_4.Length); for (Step = 0; Step < MaxStep; Step++) { rnext = null; rnext = new R1pnList(); R1pnList rsubset = new R1pnList(); sw.WriteLine(""); sw.WriteLine("NEW R1PN Start: step:" + Step + " 's R1pn List "); // make subset of the R1PN_X step. int indexofbaseR1pn = 0; foreach (R1pn r1 in rlist.rList) { r1.printPercent(ref sw); MakeSubsetofR1pn(ref rsubset, indexofbaseR1pn, r1); indexofbaseR1pn++; } sw.WriteLine(""); sw.WriteLine("rsubset's List "); rsubset.printPercent(ref sw); // process each subset. foreach (R1pn r1 in rsubset.rList) { Find_Next_R1pn_Set(r1); } sw.WriteLine(""); sw.WriteLine("rnext's List "); rnext.printPercent(ref sw); if (rnext.Count == 0) { sw.WriteLine("rnext's List is empty "); sw.WriteLine("exit this stage and go to final processing "); rnext = null; rsubset = null; GC.Collect(); break; } // Remove Current R1pn_X List // Set Next R1pn_X1 List rlist.rList = null; rlist.rList = rnext.rList; //Common.printArray("MID3_4 :(" + Step.ToString() + ") ", mid2, ref sw); rnext = null; rsubset = null; GC.Collect(); } // count each pn how many times it comes in all of rlist temp = new int[m33.Cols]; rlist.FinalProcessing_PNS(ref temp); // then, sort the count by pn // choose highest pn count as much as tspn number. int[] temp2 = new int[m33.Cols]; Array.Copy(temp, temp2, temp.Length); Array.Sort(temp2); Common.printArrayPercent("MID3-4 : %SP values (this means how many times does each %SP appear in the List)", temp, ref sw); //Common.printArrayPercent("Temp2 :(temp2) ", temp2, ref sw); #if false int[] perTemp = new int[m33.Cols]; Array.Clear(perTemp, 0, perTemp.Length); int val = 0, flag = 0, count = 0; for (int i = temp2.Length - 1; i >= 0; i--) { if (flag == 1 || temp2[i] == 0) { break; } if (temp2[i] != val) { val = temp2[i]; } else { continue; } for (int j = 0; j < temp.Length; j++) { if (temp[j] == val) { perTemp[j] = 1; count++; } if (count == rd.tpsn + 2) { flag = 1; break; } } } #else perTemp = new int[m33.Cols]; Array.Clear(perTemp, 0, perTemp.Length); for (int i = 0; i < temp.Length; i++) { if (temp[i] == temp2[temp2.Length - 1]) { perTemp[i] = 1; } } maxSpcCount = temp2[temp2.Length - 1]; #endif sw.WriteLine(); sw.WriteLine("max %SP value : " + maxSpcCount.ToString()); sw.WriteLine(); Common.printArrayPercent("MID3-4 :(Choose %SPs' that have max %SP value) ", perTemp, ref sw); // make mid3_4 sw.WriteLine(); //Common.printArray("RawData %SP: ", rd.PerSP, ref sw); //sw.WriteLine(); cplistcount = 0; Array.Clear(mid3_4, 0, mid3_4.Length); for (int i = 0; i < perTemp.Length; i++) { if (perTemp[i] > 0) { // get interval double intmin, intmax; intmax = (i + 1) * Common.GpspInterval; intmin = intmax - Common.GpspInterval; string pns = ""; pns = "Interval(%SP): " + (intmin).ToString("###0.0") + "% ~ " + intmax.ToString("###0.0") + "% , "; pns += " PN's : "; cpnlist[cplistcount] = new Cpnlist(rd.Cols); // get PNs between intmax and intmin for (int j = 0; j < rd.Cols; j++) { double persp = rd.PerSP[j]; if (persp > intmin && persp <= intmax) { //mid3_4[j] = 1; cpnlist[cplistcount].Add(j); pns += ((j + 1).ToString() + " "); } } cplistcount++; sw.WriteLine(pns); } } sw.WriteLine(); // find max list in cpnlist[] int index = cpnlist.Length, cmax = 0; for (int i = 0; i < cplistcount; i++) { if (cpnlist[i] == null) { continue; } if (cpnlist[i].count > cmax) { cmax = cpnlist[i].count; index = i; } } if (index < cpnlist.Length) { for (int i = 0; i < cpnlist[index].count; i++) { mid3_4[cpnlist[index].pns[i]] = 1; } } Common.printArray("MID3_4 :(LAST) ", mid3_4, ref sw); //Common.printIndex("MID3_4 INDEX Print :(LAST) ", mid3_4, ref sw); // make rank // temp: %sp values that is already counted // temp2 : sorted array of temp as an order of ascent Common.printArray("MID3_4 :(temp) ", temp, ref sw); Common.printArray("MID3_4 :(temp2) ", temp2, ref sw); rank3_4 = new int[rd.Cols]; Array.Clear(rank3_4, 0, rank3_4.Length); int rank = 1, prank = 1; int idx = 0, val; while (temp2[temp2.Length - 1 - idx] > 0) { val = temp2[temp2.Length - 1 - idx]; if (idx > 0 && temp2[temp2.Length - 1 - idx] == temp2[temp2.Length - 1 - (idx - 1)]) { idx++; continue; } prank = rank; for (int i = 0; i < temp.Length; i++) { if (temp[i] == val) { // i: index of %sp , double intmin, intmax; intmax = (i + 1) * Common.GpspInterval; intmin = intmax - Common.GpspInterval; for (int k = 0; k < rd.Cols; k++) { if (rd.PerSP[k] > intmin && rd.PerSP[k] <= intmax) { rank3_4[k] = prank; rank++; } } } } idx++; } Common.printArray("MID3_4 :(RANK) ", rank3_4, ref sw); }
public Mid_3_1(ref RawData r) { rd = r; rlist = new R1pnList(); mid3_1 = new int[max_mid31_Count, rd.Cols]; mid3_1_Count = 0; for (int i = 0; i < max_mid31_Count; i++) { for (int j = 0; j < rd.Cols; j++) { mid3_1[i, j] = 0; } } sw = new StreamWriter(Common.debugpath + "\\" + "MID3_1.txt"); int count = (int)(100 / Common.GpspInterval); for (int i = 0; i < count; i++) { R1pn r1 = new R1pn(5); rlist.Add(r1); } // make G%SP table int index; for (Int16 i = 0; i < r.Cols; i++) { index = (int)(r.PerSP[i] / Common.GpspInterval); rlist.rList[index].Add(i); } // test code // rlist.rList[3].Add(5); // rlist.rList[3].Add(9); // rlist.rList[3].Add(28); // rlist.rList[3].Add(45); // rlist.rList[3].Add(34); //Get Max index of a R1pn count = rlist.GetMaxCount(); index = 0; for (int i = 0; i < rlist.rList.Count; i++) { if (rlist.rList[i].cp == count) { for (int j = 0; j < rlist.rList[i].cp; j++) { mid3_1[index, rlist.rList[i].r1pn[j]] = 1; } index++; } } mid3_1_Count = index; rlist.print(ref sw, 10); int[] temp = new int[rd.Cols]; if (mid3_1_Count == 1) { for (int i = 0; i < rd.Cols; i++) { temp[i] = mid3_1[0, i]; } Common.printArray("Mid-3-1: Result: ", temp, ref sw); } else { for (int k = 0; k < mid3_1_Count; k++) { for (int i = 0; i < rd.Cols; i++) { temp[i] = mid3_1[k, i]; } Common.printArray("Mid-3-1-" + (k + 1).ToString() + ": Result: ", temp, ref sw); } } rank = new int[rd.Cols]; rlist.makeRankArray(ref rank); }
public Mid_4_1(ref RawData r) { rd = r; mid4_1 = new int[rd.Cols]; mx_mn = new double[rd.Cols]; rlist = new R1pnList(); Array.Clear(mid4_1, 0, mid4_1.Length); sw = new StreamWriter(Common.debugpath + "\\" + "MID4_1.txt"); Common.printArray("MID4_1 :Rawdata %SP ", rd.PerSP, ref sw); sw.WriteLine("MID4_1: Average %SP : " + rd.APerSP.ToString("#####0.00")); // make mx_mn array for (int i = 0; i < rd.Cols; i++) { mx_mn[i] = rd.APerSP - rd.PerSP[i]; } // get the most number out of + values. int index = Common.MaxIndex(ref mx_mn); double val = mx_mn[index]; R1pn r1 = new R1pn(10); for (Int16 i = 0; i < rd.Cols; i++) { if (mx_mn[i] == val) { mid4_1[i] = 1; r1.Add(i); } } rlist.Add(r1); Common.printArray("MID4_1 :first", mid4_1, ref sw); // get the least number out of - values; index = Common.MinIndex(ref mx_mn); val = mx_mn[index]; r1 = new R1pn(10); for (Int16 i = 0; i < rd.Cols; i++) { if (mx_mn[i] == val) { mid4_1[i] = 1; r1.Add(i); } } rlist.Add(r1); Common.printArray("MID4_1 :second", mid4_1, ref sw); // get the least number out of + values; index = Common.MinIndexOutofPlus(ref mx_mn); val = mx_mn[index]; r1 = new R1pn(10); for (Int16 i = 0; i < rd.Cols; i++) { if (mx_mn[i] == val) { mid4_1[i] = 1; r1.Add(i); } } rlist.Add(r1); Common.printArray("MID4_1 :third", mid4_1, ref sw); // get the most number out of - values; index = Common.MaxIndexOutofMinus(ref mx_mn); val = mx_mn[index]; r1 = new R1pn(10); for (Int16 i = 0; i < rd.Cols; i++) { if (mx_mn[i] == val) { mid4_1[i] = 1; r1.Add(i); } } rlist.Add(r1); Common.printArray("MID4_1 :MX/MN", mx_mn, ref sw); Common.printArray("MID4_1 :MID4_1", mid4_1, ref sw); rlist.print(ref sw); }
public void printMid1() { sw.WriteLine("Mid_1 Print ------------------------------------"); Common.printArray("MID1 :(Mid_1) ", mid1, ref sw); sw.WriteLine(); }
public Mid_4_3_new1(ref RawData r, ref Mid_4_1 md41, ref Mid_4_2 m42) { rd = r; md42 = m42; mid4_3 = new int[rd.Cols]; Array.Clear(mid4_3, 0, mid4_3.Length); sw = new StreamWriter(Common.debugpath + "\\" + "MID4_3.txt"); MXPlus = new double[rd.Cols]; MXMinus = new double[rd.Cols]; MXPlusPN = new int[rd.Cols]; MXMinusPN = new int[rd.Cols]; MXPlusCount = 0; MXMinusCount = 0; MXavg = 0; MNAvg = 0; for (int i = 0; i < md41.mx_mn.Length; i++) { if (md41.mx_mn[i] > 0) { MXPlusPN[MXPlusCount] = i; MXPlus[MXPlusCount++] = md41.mx_mn[i]; MXavg += md41.mx_mn[i]; } else if (md41.mx_mn[i] < 0) { MXMinusPN[MXMinusCount] = i; MXMinus[MXMinusCount++] = Math.Abs(md41.mx_mn[i]); MNAvg += Math.Abs(md41.mx_mn[i]); } } MXavg = MXavg / MXPlusCount; MNAvg = MNAvg / MXMinusCount; MXselectCount = 0; MNselectCount = 0; MXselectPN = new int[MXPlusCount]; MNselectPN = new int[MXMinusCount]; MXPlusDiff = new double[MXPlusCount]; MXMinusDiff = new double[MXMinusCount]; for (int i = 0; i < MXPlusCount; i++) { MXPlusDiff[i] = Math.Abs(MXPlus[i] - MXavg); } for (int i = 0; i < MXMinusCount; i++) { MXMinusDiff[i] = Math.Abs(MXMinus[i] - MNAvg); } double min1 = Double.MaxValue, min2 = Double.MaxValue; for (int i = 0; i < MXPlusCount; i++) { if (MXPlusDiff[i] < min1) { min1 = MXPlusDiff[i]; } } for (int i = 0; i < MXMinusCount; i++) { if (MXMinusDiff[i] < min2) { min2 = MXMinusDiff[i]; } } for (int i = 0; i < MXPlusCount; i++) { if (MXPlusDiff[i] == min1) { MXselectPN[MXselectCount] = MXPlusPN[i]; MXselectCount++; mid4_3[MXPlusPN[i]] = 1; } } for (int i = 0; i < MXMinusCount; i++) { if (MXMinusDiff[i] == min2) { MNselectPN[MNselectCount] = MXMinusPN[i]; MNselectCount++; mid4_3[MXMinusPN[i]] = 1; } } /* * // MX%SP * lower1 = MXavg * (1 - variation); * upper1 = MXavg * (1 + variation); * for (int i = 0; i < MXPlusCount; i++) * { * if (MXPlus[i] >= lower1 && MXPlus[i] <= upper1) * { * MXselectPN[MXselectCount] = MXPlusPN[i]; MXselectCount++; * mid4_3[MXPlusPN[i]] = 1; * } * } * // MN%SP * lower2 = MNAvg * (1 - variation); * upper2 = MNAvg * (1 + variation); * for (int i = 0; i < MXMinusCount; i++) * { * if (MXMinus[i] >= lower2 && MXMinus[i] <= upper2) * { * MNselectPN[MNselectCount] = MXMinusPN[i]; MNselectCount++; * mid4_3[MXMinusPN[i]] = 1; * } * } */ // Print Data // MX List string one = ""; sw.WriteLine("MX PN List : (PN, %SP) , Count: " + MXPlusCount.ToString()); for (int i = 0; i < MXPlusCount; i++) { one = one + "(" + (MXPlusPN[i] + 1).ToString() + ":" + MXPlus[i].ToString("#####0.00") + ") "; if (i > 0 && i % 5 == 0) { sw.WriteLine(one); one = ""; } } if (one != "") { sw.WriteLine(one); } // MN List sw.WriteLine(); one = ""; sw.WriteLine("MN PN List : (PN, %SP), Count: " + MXMinusCount.ToString()); for (int i = 0; i < MXMinusCount; i++) { one = one + "(" + (MXMinusPN[i] + 1).ToString() + ":" + (MXMinus[i] * -1).ToString("#####0.00") + ") "; if (i > 0 && i % 5 == 0) { sw.WriteLine(one); one = ""; } } if (one != "") { sw.WriteLine(one); } sw.WriteLine(); // average //sw.WriteLine("AveMX%SP =" + MXavg.ToString("#######0.00") + " Range:+/-" + (variation*100).ToString() + "% (" + lower1.ToString("######0.00") + "~" + upper1.ToString("######0.00") + ")"); //sw.WriteLine("AveMN%SP =" + (MNAvg * -1).ToString("#######0.00") + " Range:+/-" + (variation * 100).ToString() + "% (" + (lower2*-1).ToString("######0.00") + "~" + (upper2*-1).ToString("######0.00") + ")"); sw.WriteLine("AveMX%SP =" + MXavg.ToString("#######0.00")); sw.WriteLine("AveMN%SP =" + (MNAvg * -1).ToString("#######0.00")); sw.WriteLine(); // Difference table one = ""; sw.WriteLine("MX PN List : Difference Table , Count: " + MXPlusCount.ToString()); for (int i = 0; i < MXPlusCount; i++) { one = one + "(" + (MXPlusPN[i] + 1).ToString() + ":" + (MXPlus[i] - MXavg).ToString("#####0.00") + ") "; if (Math.Abs(MXPlus[i] - MXavg) == min1) { one = one + "** "; } if (i > 0 && i % 5 == 0) { sw.WriteLine(one); one = ""; } } if (one != "") { sw.WriteLine(one); } // MN List sw.WriteLine(); one = ""; sw.WriteLine("MN PN List : Difference Table , Count: " + MXMinusCount.ToString()); for (int i = 0; i < MXMinusCount; i++) { one = one + "(" + (MXMinusPN[i] + 1).ToString() + ":" + (MXMinus[i] - MNAvg).ToString("#####0.00") + ") "; if (Math.Abs(MXMinus[i] - MNAvg) == min2) { one = one + "** "; } if (i > 0 && i % 5 == 0) { sw.WriteLine(one); one = ""; } } if (one != "") { sw.WriteLine(one); } sw.WriteLine(); // pn list sw.WriteLine(); sw.Write("MX%SP Selected PNs' List : "); one = ""; for (int i = 0; i < MXselectCount; i++) { one = one + (MXselectPN[i] + 1).ToString() + " "; } sw.WriteLine(one); sw.Write("MN%SP Selected PNs' List : "); one = ""; for (int i = 0; i < MNselectCount; i++) { one = one + (MNselectPN[i] + 1).ToString() + " "; } sw.WriteLine(one); sw.WriteLine(); Common.printArray("MID4_3 :MID4_3", mid4_3, ref sw); }
public void Run() { Array.Clear(mid2, 0, mid2.Length); for (Step = 0; Step < MaxStep; Step++) { Console.WriteLine("maxstep: {0}, current step:{1}", MaxStep, Step); rnext = null; rnext = new R1pnList(); R1pnList rsubset = new R1pnList(); sw.WriteLine(""); sw.WriteLine("NEW R1PN Start: step:" + Step + " 's R1pn List "); // make subset of the R1PN_X step. int indexofbaseR1pn = 0; foreach (R1pn r1 in rlist.rList) { r1.print(ref sw); MakeSubsetofR1pn(ref rsubset, indexofbaseR1pn, r1); indexofbaseR1pn++; } GC.Collect(); //sw.WriteLine(""); //sw.WriteLine("rsubset's List "); //rsubset.print(ref sw); // process each subset. int ccc = 0; foreach (R1pn r1 in rsubset.rList) { Find_Next_R1pn_Set(r1); ccc++; if (ccc < 0) { ccc = 0; } if (ccc % 100000 == 0) { Console.WriteLine("ccc: {0}", ccc); GC.Collect(); } } //sw.WriteLine(""); //sw.WriteLine("rnext's List "); //rnext.print(ref sw); // Remove Current R1pn_X List // Set Next R1pn_X1 List rlist.rList = null; rlist.rList = rnext.rList; //Common.printArray("MID2 :("+Step.ToString()+") ", mid2, ref sw); rnext = null; rsubset = null; GC.Collect(); } // count each pn how many times it comes in all of rlist temp = new int[mid2.Length]; rlist.FinalProcessing_PNS(ref temp); Common.printArray2("Temp :(temp,PN's count that is appeared in the List.) ", temp, ref sw); // then, sort the count by pn // choose highest pn count as much as tspn number. int[] temp2 = new int[mid2.Length]; Array.Copy(temp, temp2, temp.Length); Array.Sort(temp2); // Common.printArray2("Temp2 :(temp2, sort) ", temp2, ref sw); Array.Clear(mid2, 0, mid2.Length); int val = 0, flag = 0, count = 0; for (int i = temp2.Length - 1; i >= 0; i--) { if (flag == 1 || temp2[i] == 0) { break; } if (temp2[i] != val) { val = temp2[i]; } else { continue; } for (int j = 0; j < temp.Length; j++) { if (temp[j] == val) { mid2[j] = 1; count++; } if (count == rd.tpsn + 2) { flag = 1; break; } } } sw.WriteLine("Choose " + (rd.tpsn + 2).ToString("######0") + " PN's"); sw.WriteLine("Threshold Count: " + (val).ToString("######0")); Common.printArray("MID2 :(LAST) ", mid2, ref sw); Common.printIndex("MID2 INDEX Print :(LAST) ", mid2, ref sw); }