A Bayesian approach for dynamic portfolio optimization of safety barriers