I have a set $\{A_1, A_2, .. A_k\}$ of $n$ by $n$ real matrices and I know that they are 'perturbated versions' of a set of commuting matrices : $\{P_1,..,P_k\}$, by perturbated versions I mean that I have a bound on 
$\sum_i\|A_i-P_i\|\leq \epsilon$. My problem is that I want to find an epsilon perturbation of $\{A_1,...,A_k\}$ 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.