The objective function that measures deviations of MM from QM geometries is designed in the following way: MM geometry optimizations are first locally minimized starting from QM optimized structures, then MM and QM Cartesian coordinates are converted to lists of bond lengths, bond angles, and both proper and improper torsion angles. The difference between QM and MM optimized internal coordinates for a single molecule contributes to the objective function as: