def delta(W, D, sol, i, j):
    """
    We compute the delta between two solution.
    We assurme that:
        - W ia the flow matrix
        - D is the distance matrix
        - sol is the solution
        - i is the index of first moved object
        - j is the index of second moved object
    We assume that W,D are numpy matrix
    Sol is a list.
    """
    res = 0
    # we reduce i,j because we count from 0
    j -= 1
    i -= 1
    for k in range(len(sol)):
        if k != i and k != j:
            res += (W[j, k] - W[i, k]) * (D[sol[i] - 1, sol[k] - 1] - D[sol[j] - 1, sol[k] - 1])
    return 2 * res