Beam-based correction and optimization for accelerators. (2019)