public double getGlobalCost(SearchState state) {
   int[] permutations = state.getIArray();
   int[][] costMatrix = dataStorager.getCostMatrix();
   int totalLength = costMatrix[permutations[permutations.length - 1]][permutations[0]];
   for (int i = 1; i < permutations.length; i++) {
     totalLength += costMatrix[permutations[i - 1]][permutations[i]];
   }
   return totalLength;
 }