Bayesian optimal design for changepoint problems