For all initial guesses, the atom map is optimized one after the other, according to the given priority, for all sets of indistinguishable atoms being left and all sets of monovalent atoms. In this constrained optimization, only atoms within the same set are allowed to permute. For the example mentioned above, the mapping of carbon atoms in the sets S 5 , S 6 , and S 7 can therefore adapt to the respective preceding mappings. Each optimization step consists of an iterative steepest descent procedure where a penalty matrix P is constructed in each iteration, e.g., for the optimization of set S p :