Optimizing ion transport in a multi-reflection time-of-flight mass spectrograph by a modified Nelder--Mead simplex algorithm