Here you can find the source of length(int[][] instance, int u)
public static double length(int[][] instance, int u)
//package com.java2s; //License from project: Open Source License public class Main { public static double length(int[][] instance, int u) { double length = 0; int numberOfMachines = instance.length; int middle = (numberOfMachines / 2) + 1; int var = 1; boolean useTheSameValue = numberOfMachines % 2 == 0; for (int m = numberOfMachines; m > 0; m--) { if (m >= middle) { // decrease var -= 2; length = length + (numberOfMachines - var) * instance[m - 1][u]; } else { // increase if (!useTheSameValue) { // when is a par we need to keep the same value var += 2; } else { useTheSameValue = false; }/*from ww w . ja v a 2 s . c o m*/ length = length - (numberOfMachines - var) * instance[m - 1][u]; } } return length; } }