public R1pn Clone() { R1pn r = new R1pn(this.cp + 10); Array.Copy(this.r1pn, r.r1pn, cp); r.cp = cp; r.indexofbaseR1pn = indexofbaseR1pn; return(r); }
public void CopyFrom(R1pn r) { cp = r.cp; indexofbaseR1pn = r.indexofbaseR1pn; for (int i = 0; i < cp; i++) { r1pn[i] = r.r1pn[i]; } sorted = false; }
public R1pnList Clone() { R1pnList r = new R1pnList(); foreach (R1pn r1 in rList) { R1pn newr = r1.Clone(); r.Add(newr); } return(r); }
// Check if All values of r1 are '1', then return true private bool IsAllofR1pn_1(int index, R1pn r1) { for (int i = 0; i < r1.cp; i++) { if (m33.rawdata[index, r1.r1pn[i]] <= 0) { return(false); } } return(true); }
public bool IsExist(ref R1pn r1) { foreach (R1pn r in rList) { if (r.isSame(ref r1) == true) { return(true); } } return(false); }
// private void FirstMakeR1PN() { for (Int16 i = 0; i < m33.Cols; i++) { if (m33.spc[i] == m33.spcmax) { R1pn r1 = new R1pn(rd.tpsn); r1.Add(i); rlist.Add(r1); } } }
// private void FirstMakeR1PN() { for (Int16 i = 0; i < rd.Cols; i++) { if (rd.spc[i] == mid1.maxSPC) { R1pn r1 = new R1pn(rd.tpsn); r1.Add(i); rlist.Add(r1); } } }
// process a subset. private void Find_Next_R1pn_Set(R1pn r1) { // make subtable and SPC int[] spc = new int[m33.Cols]; Array.Clear(spc, 0, spc.Length); for (int i = 0; i < m33.Rows; i++) { if (IsAllofR1pn_1(i, r1)) { for (int j = 0; j < m33.Cols; j++) { if (m33.rawdata[i, j] > 0) { spc[j] += m33.rawdata[i, j]; } } } } //Common.printArray("Find_Next_R1pn_Set:SPC(1)", ref spc, ref sw); // clear prev reference R1pn prev = rlist.rList[r1.indexofbaseR1pn]; for (int i = 0; i < prev.cp; i++) { spc[prev.r1pn[i]] = 0; } //Common.printArray("Find_Next_R1pn_Set:SPC(2)", ref spc, ref sw); // get the spcs with the maximum value. int max = Common.MaxValue(ref spc); // make next R1pn with checking the same R1pn in the rlist. // put new R1pns' into the rnext list for (Int16 i = 0; i < spc.Length; i++) { if (spc[i] == max && max >= 1) // 중요한 부분임... threshhold값에 따라 결과가 많이 달라짐. { R1pn new1 = new R1pn(rd.tpsn); new1.CopyFrom(prev); new1.Add(i); if (!rnext.IsExist(ref new1)) { rnext.Add(new1); } } } }
// Make subset list from the R1pn. // for example, (11,25, 39, 20) => {(11,25,39,20), (25,39,20), (39,20), (20)} private void MakeSubsetofR1pn(ref R1pnList rsubset, int indexofbaseR1pn, R1pn r1) { int count = r1.cp; R1pn r2 = new R1pn(r1.r1pn.Length); r2.CopyFrom(r1); for (int i = 0; i < count; i++) { if (!rsubset.IsExist(ref r2)) //check if rsubset already has the r2. { R1pn new1 = new R1pn(r1.r1pn.Length); new1.CopyFrom(r2); new1.indexofbaseR1pn = indexofbaseR1pn; rsubset.Add(new1); } r2.ShiftLeft_1(); if (r2.cp <= 0) { break; } } }
public bool isSame(ref R1pn r1) { /* * if (!sorted) * { * r1pnSorted = new int[cp]; * Array.Copy(r1pn, r1pnSorted, cp); * Array.Sort(r1pnSorted); * sorted = true; * } * if (!r1.sorted) * { * r1.r1pnSorted = new int[r1.cp]; * Array.Copy(r1.r1pn, r1.r1pnSorted, r1.cp); * Array.Sort(r1.r1pnSorted); * r1.sorted = true; * } */ if (cp != r1.cp) { return(false); } for (int i = 0; i < cp; i++) { // if (r1pnSorted[i] != r1.r1pnSorted[i]) return false; if (r1pn[i] != r1.r1pn[i]) { return(false); } } if (indexofbaseR1pn != r1.indexofbaseR1pn) { return(false); } return(true); }
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 void Add(R1pn rp) { rList.Add(rp); }
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); }