|XP is just a number|
I'm pretty sure that this is the optimal solution, but I'm too lazy to write down the complete mathematical proof.
The basic idea is that the terms represent the general cost difference of swapping the first and the second filter╣!
So by sorting you get a solution which can't be improved by a pairwise swapping and any permutation can be represented by a sequence of pairwise swaps.
╣) see restructured formula for c in Re^2: Evolving a faster filter? (combinatorics) and you will notice that these are the first elements and the rest is fix.
basic transformations lead to a simpler solution:
which can be precalculated to save calculation time
(the edge case of a division by zero must be handled as practically infinity)
In reply to Re^3: Evolving a faster filter? (optimal solution?)