| Algorithm 1: Calculates the neighbor distance |
| Require: y; μi; c |
| Ensure: Returns the neighbor distance, di(c). |
| Let i1, …, in be a permutation on 1, …, n such that, if |
| then u1 ≥ u2 ≥ ⋯ ≥ un. |
| Let j1, …, jn be a permutation on 1, …, n such that, if |
| then l1 ≤ l2 ≤ ⋯ ≤ ln. |
| Let uj and lj for k = 1, ⋯, n |
| Return r such that c − μi · y ∈ [Lr+1, Lr) ∪ (Ur, Ur+1] |