private static void performShuffle(DependencyMatrix dependencyMatrix) { int matrixSize = dependencyMatrix.getSize(); for (int i = 0; i < matrixSize * 2; i++) { int randomIndex1 = Utils.getRandomInt(0, matrixSize - 1); int randomIndex2 = Utils.getRandomInt(0, matrixSize - 1); if (randomIndex1 != randomIndex2) { dependencyMatrix.replaceElements(randomIndex1, randomIndex2); } } }
private static double countTotalDistance(DependencyMatrix dependencyMatrix) { double result = 0; List<DsmRow> rows = dependencyMatrix.getRows(); for (int i = 0; i < rows.size(); i++) { DsmRow row = rows.get(i); List<DsmCell> cells = row.getCells(); for (int j = 0; j < cells.size(); j++) { if (i != j) { DsmCell cellFrom = row.getCells().get(j); int cellFromDependencyWeight = cellFrom.getDependencyWeight(); if (cellFromDependencyWeight > 0) { result += countDistanceToAnotherCells(rows, i, j, cellFromDependencyWeight); } } } } return result; }