public void copyEnergyFrom(DataV2 d) { for (int e = 0; e < timeslot.Length; e++) { timeslot[e] = d.timeslot[e]; } }
int IComparable.CompareTo(object o) { DataV2 data = (DataV2)o; if (uid != data.uid) { return(uid.CompareTo(data.uid)); } return(ttime.CompareTo(data.ttime)); }
public override bool Equals(object o) { DataV2 d = (DataV2)o; for (int e = 0; e < timeslot.Length; e++) { if (timeslot[e] != d.timeslot[e]) { return(false); } } return(true); }
public DataV2 Clone() { DataV2 tmp = new DataV2(timeslot.Length) { uid = uid, ttime = ttime, mainCluster = mainCluster, subCluster = subCluster, timeslot = (double[])timeslot.Clone() }; return(tmp); }
public List <DataV2> GetNewDatas() { if (this.isLastDay) { Console.WriteLine("모든 날짜에 대한 클러스터링을 진행했습니다."); return(null); } // 하루치씩 쪼개가지고 반환 List <DataV2> newDatas = new List <DataV2>(); DateTime nextDay = new DateTime(0); int idx = this.dayCheckIdx; // DayCheck do { if (idx == this.dayCheckIdx) { this.nowDay = DateTime.ParseExact(cell[idx, 1].ToString(), "yyyyMMdd", null); } else { try { if (this.nowDay != DateTime.ParseExact(cell[idx, 1].ToString(), "yyyyMMdd", null).Date) { break; } } catch (IndexOutOfRangeException e) { this.isLastDay = true; break; } } idx++; } while (true); // idx 까지가 다른 날짜 // isLastDay 가 true면 마지막 날짜 였고, 마지막 클러스터링을 하면 됨 Console.WriteLine(String.Format("-----{0} 데이터-----", this.nowDay.ToString("yyyyMMdd"))); if (this.isLastDay) { Console.WriteLine(String.Format("마지막 날짜 데이터")); } DataV2[] datas = new DataV2[user]; Parallel.For(0, datas.Length, (d) => datas[d] = new DataV2(this.timeslot)); /* * Console.WriteLine(this.dataStartColumn); * Console.WriteLine(this.column); * Console.WriteLine(String.Format("{0}-------{1}",this.dayCheckIdx, idx)); */ Parallel.For(this.dataStartColumn, column + 1, (c) => { for (int r = this.dayCheckIdx; r < idx; r++) { if (!cell[r, c].Equals("-")) { datas[c - this.dataStartColumn].timeslot[r - this.dayCheckIdx] = double.Parse(cell[r, c].ToString()) * 1000; } if (r + 1 == idx) { datas[c - this.dataStartColumn].uid = cell[3, c] + "-" + cell[4, c] + "-" + cell[5, c]; datas[c - this.dataStartColumn].ttime = DateTime.ParseExact(cell[r, 1].ToString(), "yyyyMMdd", null); } } }); if (!this.isLastDay) { this.dayCheckIdx = idx; } // 필요없는 데이터 거르기 newDatas = new List <DataV2>(datas); for (int d = 0; d < newDatas.Count; d++) { if (!newDatas[d].isValidated()) { newDatas.RemoveAt(d--); } } return(newDatas); }