Пример #1
0
        public static void run(string fLOF, double r, string fFastABOD, int topK, string fResult)
        {
            List<int> outlierLOF = readFile(fLOF, topK, r, true);
            List<int> outlierFastABOD = readFile(fFastABOD, topK, r, false);

            List<DPoint> resultList = new List<DPoint>();
            DPoint tmp;
            int index;

            for (int i = 0; i < outlierLOF.Count; i++)
            {
                index = getIndexOfMoteID(resultList, outlierLOF[i]);
                if (resultList.Count() == 0 || index == -1)
                {
                    tmp = new DPoint();
                    tmp.MoteID = outlierLOF[i];
                    tmp.NumLOF = 1;

                    resultList.Add(tmp);
                }
                else
                    resultList[index].NumLOF++;
            }
            for (int j = 0; j < outlierFastABOD.Count(); j++)
            {
                index = getIndexOfMoteID(resultList, outlierFastABOD[j]);
                if (resultList.Count() == 0 || index == -1)
                {
                    tmp = new DPoint();
                    tmp.MoteID = outlierFastABOD[j];
                    tmp.NumFastABOD = 1;

                    resultList.Add(tmp);
                }
                else
                    resultList[index].NumFastABOD++;
            }

            string fNoise = @"D:/noise.txt";
            List<int> noise = read_file(fNoise);
            for (int k = 0; k < noise.Count(); k++)
            {
                index = getIndexOfMoteID(resultList, noise[k]);
                if (index == -1)
                {
                    tmp = new DPoint();
                    tmp.MoteID = outlierFastABOD[k];
                    tmp.NumNoise = 1;

                    resultList.Add(tmp);
                }
                else
                    resultList[index].NumNoise++;
            }

            foreach (DPoint x in resultList)
                x.sumNum();

            resultList.Sort();
            resultList.Reverse();

            StreamWriter sw = File.AppendText(fResult);
            string str;
            int nLOF = 0, nFastABOD = 0, nTotal = 0, nDiff = 0;
            sw.WriteLine("======================================");
            sw.WriteLine("MoteID\tLOF\tFastABOD\tNoise\tSum");
            foreach (DPoint x in resultList)
            {
                if ((x.NumLOF == 0 && x.NumFastABOD == 1) || x.NumLOF == 1 && x.NumFastABOD == 0)
                    nDiff++;
                nFastABOD += x.NumFastABOD;
                nLOF += x.NumLOF;
                nTotal += x.Sum;

                str = String.Format("{0}\t{1}\t{2}\t{3}\t{4}", x.MoteID, x.NumLOF, x.NumFastABOD, x.NumNoise, x.Sum);
                sw.WriteLine(str);
            }

            str = "======================================"
                + "\r\nNum LOF\t" + nLOF
                + "\r\nNum Fast ABOD\t" + nFastABOD
                + "\r\nNum Different\t" + nDiff
                + "\r\nNum Total\t" + resultList.Count()
                + "\r\nDifference\t" + nDiff / nTotal;
            sw.WriteLine(str);

            sw.Flush();
            sw.Close();
        }
Пример #2
0
 public int CompareTo(DPoint other)
 {
     return(this.Sum.CompareTo(other.Sum));
 }
Пример #3
0
 public int CompareTo(DPoint other)
 {
     return this.Sum.CompareTo(other.Sum);
 }