private void ThreadMethod(int start, int end, int min) { for (int i = start; i < end; i++) { int cCount = i; ClusterResult clusterresult = null; switch (this.MethodMode) { case 0: clusterresult = SingleStart(cCount, ref this.WaitObj.Flags[i - min]); break; case 1: clusterresult = SingleStartWithWeight(cCount, ref this.WaitObj.Flags[i - min]); break; } ClusterAssessReport_BWP clusterassessreport = Assess.GetBWP(Data, clusterresult, Distences); lock (this.SyObject) { this.FinalReport.HisResult.Add(clusterresult); this.FinalReport.HisReport.Add(clusterassessreport); if (clusterassessreport.AvgBWP > this.Score) { this.Score = clusterassessreport.AvgBWP; FinalReport.FanialResult = clusterresult; FinalReport.FanialReport = clusterassessreport; } } } if (Barobj != null) { Barobj.RemoveParticipant(); } }
public static ClusterAssessReport_BWP GetBWP(IDataTable <DataRow> data, ClusterResult result, double[,] distence) { int cCount = result.cCount; int dataCount = data.RowCount; int paraCount = result.Properties.Length; var classnumber = result.ClassNumbers; var properties = result.Properties; int[] eachClusterCount = result.CountEachCluster; double[,] bc = new double[dataCount, cCount]; double[] b = new double[dataCount]; double[] w = new double[dataCount]; double[] bwp = new double[dataCount]; double avgBwp = 0; ClusterAssessReport_BWP report = new ClusterAssessReport_BWP(); for (int i = 0; i < dataCount - 1; i++) { for (int j = i + 1; j < dataCount; j++) { int cj = classnumber[j]; int ci = classnumber[i]; double temp = distence[i, j]; int tempcountj = eachClusterCount[cj]; int tempcounti = eachClusterCount[ci]; if (ci == cj) { temp = temp / (tempcountj - 1); w[i] += temp; w[j] += temp; } else { bc[i, cj] += temp / tempcountj; bc[j, ci] += temp / tempcounti; } } } for (int i = 0; i < dataCount; i++) { var iclass = classnumber[i]; double tempb = Double.PositiveInfinity; for (int j = 0; j < iclass; j++) { double t = bc[i, j]; if (t < tempb && t != 0) { tempb = t; } } for (int j = iclass + 1; j < cCount; j++) { double t = bc[i, j]; if (t < tempb && t != 0) { tempb = t; } } b[i] = tempb; double tempw = w[i]; bwp[i] = (tempb - tempw) / (tempb + tempw); avgBwp += bwp[i]; } avgBwp = avgBwp / dataCount; report.AvgBWP = avgBwp; report.B = b; report.W = w; report.BWP = bwp; return(report); }