A new algorithm for calibrating local regime-switching models. (27th July 2020)