Trajectory-oriented optimization of stochastic epidemiological models