Optimization of pacing algorithms to prevent and treat supraventricular tachyarrhythmias