private void testPrepareTestsData() { participation = new Participation[10]; for (int i = 0; i < 10; i++) { participation[i] = new Participation(); participation[i].distance = rand.Next(0, 100); } }
private void countDistanceOfEachChromAndSaveToParticipation() { int distance; for (int i = 0; i < lengthOfPopulation; i++) { distance = 0; for (int j = 0; j < (countOfPoints - 1); j++) { int a = population[i][j]; int b = population[i][j + 1]; distance += distances[a][b]; } participation[i] = new Participation(); participation[i].idChrom = i; participation[i].distance = distance; } }
private void sort(int lo, int hi) { int i = lo; int j = hi; int half = (int)Math.Floor((lo + hi) / 2.0d); int x = participation[half].distance; do { while (participation[i].distance < x) { i++; } while (participation[j].distance > x) { j--; } if (i <= j) { Participation tmp = participation[i]; participation[i] = participation[j]; participation[j] = tmp; i++; j--; } } while (i <= j); if (lo < j) { sort(lo, j); } if (i < hi) { sort(i, hi); } }