Non-stationary Anderson acceleration with optimized damping