  Modified Patankar--Runge--Kutta (MPRK) methods are linearly implicit time
integration schemes developed to preserve positivity and a linear invariant
such as the total mass in chemical reactions. MPRK methods are naturally
equipped with embedded schemes yielding a local error estimate similar to
Runge--Kutta pairs. To design good time step size controllers using these error
estimates, we propose to use Bayesian optimization. In particular, we design a
novel objective function that captures important properties such as tolerance
convergence and computational stability. We apply our new approach to several
MPRK schemes and controllers based on digital signal processing, extending
classical PI and PID controllers. We demonstrate that the optimization process
yields controllers that are at least as good as the best controllers chosen
from a wide range of suggestions available for classical explicit and implicit
time integration methods.
