I have a set {A1, A2 .. Ak} of n by n real matrices and I know that they are 'perturbated versions' of a set of commuting matrices : {P1,..,Pk}, by perturbated versions I mean that I have a bound on 
sum_i(norm(Ai-Pi)) leq epsilon. My problem is that I want to find an epsilon perturbation of {A1..Ak} so that they commute. It is clear that at least one such perturbation exists since they are perturbed versions of a commuting set. But my question is if there is any algorithm to find a permutation that makes the matrices in A commute.