private void changeClusterPosition() { List <CellGroup> clusterList = PublicParameters.networkCells; double avg = CellGroup.getAverageSensors(); for (int x = 0; x < clusterList.Count(); x++) { CellGroup oldCluster = PublicParameters.networkCells[x]; Point oldClusterLocation = oldCluster.clusterLocMargin; int oldNodesCount = oldCluster.clusterNodes.Count; if (oldNodesCount < avg) { //Consider changing the cluster //Construct 8 clusters and compare between each of them //Construct the 8 clusters by adding them to a temporary list in ReCheck for (int i = 1; i <= 8; i++) { CellGroup tempCluster = new CellGroup(oldClusterLocation, oldCluster.getID()); //Console.WriteLine("Old Position X: {0} Y: {1}", tempCluster.clusterPoint.X, tempCluster.clusterPoint.Y); tempCluster.incDecPos(i, (0.334)); // Console.WriteLine("New Position X: {0} Y: {1}", tempCluster.clusterPoint.X, tempCluster.clusterPoint.Y); tempCluster.findNearestSensorRecheck(false); } CellGroup maxCluster = new CellGroup(); maxCluster = maxCluster.getMaxSensors(); maxCluster.findNearestSensorRecheck(true); } } }
private static void getAfterAverage() { double avg = Math.Abs(CellGroup.getAverageSensors()); avg -= 2; double i = 0; double y = 0; foreach (CellGroup cell in PublicParameters.networkCells) { double count = cell.clusterNodes.Count; if (count > avg) { i += count; y++; } } AfterSmallAverage = Convert.ToInt32(i / y); //AfterSmallAverage = Math.Abs(i); }