Optimal numerical control of single-well to cross-well chaos transition in mechanical systems