private void solve_sub_problem(double A_i, int yi, double C_yi, int active_i, double[] alpha_new) {

        int r;
        assert active_i <= B.length; // no padding
        double[] D = copyOf(B, active_i);
        // clone(D, B, active_i);

        if (yi < active_i) D[yi] += A_i * C_yi;

        // qsort(D, active_i, sizeof(double), compare_double);
        ArraySorter.reversedMergesort(D);

        double beta = D[0] - A_i * C_yi;
        for (r = 1; r < active_i && beta < r * D[r]; r++)
            beta += D[r];
        beta /= r;

        for (r = 0; r < active_i; r++) {
            if (r == yi)
                alpha_new[r] = Math.min(C_yi, (beta - B[r]) / A_i);
            else
                alpha_new[r] = Math.min(0.0, (beta - B[r]) / A_i);
        }
    }